Subscribe to GameFromScratch on YouTube Support GameFromScratch on Patreon

28. April 2012

 

I am going to continue to develop a number of PlayStation Suite SDK tutorials and finding them could start getting confusing.  Therefore I have put together an index page off all tutorials I have created and will continue to update it as I create more.  Tutorials are ordered in more or less chronological order that a developer should read them in.  I will put this in the side bar shortly, for now you can access the PS tutorial index here.

Programming ,

27. April 2012

 

 

The LUA based Corona SDK is one of those things I have really been intending to check out forCoronaBook a very long time now.  One of the biggest reasons I haven’t looked closer ( other than time ) was the complete lack of published materials.  Today however, I logged in to Safari and low and behold, Corona SDK Mobile Game Development is right there in the new releases section.

 

 

This is perhaps the worst timing ever, I am still throwing myself quite fully at PlayStation SDK development as well as working on a Titanium based app… but, but… this is shiny and new! (well, the book is new anyways…)

 

 

Actually, Corona and more specifically LUA are two products I have heard nothing but rave reviews of, so this certainly is of interest to me.  I’ve skim read the book and it seems quite impressive.  If I dive in, I will be sure to put up a review.  I have to say, I am quite impressed with Packt press lately and the range of books they are putting out.  The book is also available on Amazon but oddly enough shows a May 31st publish date( it’s April 27th at the time of this post), but also lists it as being in stock so I am guessing it’s available to order.

 

 

Have you worked with LUA/Corona?  Is the hype justified? Is it substantially better than the free Moai SDK, which is also LUA based?

General

27. April 2012

 

 

This is the release of Blender I have been waiting a long time for, as this is the release where BMesh has finally been integrated into Blender!  For those of you unaware of what exactlyblender_263 BMesh brings to the table, take a quick look at this post.  Having worked in Wings for so long, and Nendo before that, I have been dying to see ngon support added to Blender.

 

 

 

Expect things to be a bit buggy for a while, the switch to the BMesh engine is a pretty massive change.  That said, expect to see new and more powerful tools coming out, as in many ways BMesh impacts Blender developers as much as it does end users.

 

 

KnifeTool

 

 

 

However, it isn’t only about BMesh.  Cycles has also received a lot of love in the 2.63 release, with new rendering passes for Ambient occlusion and shadows, as well as a mask layer for “masking out” objects in the scene.  Environment mapping has also been improved to support float precision textures.  A mirror ball project mode has been added as well, but frankly, I don’t really understand the use.  Additionally, there is now a panoramic camera, which will render a panoramic view of the scene around the camera’s location.  There have also been improvements to viewport rendering, allowing it to show background images as well as the ability to show the currently active rendering layer in the viewport.

 

 

There are other features as well, including the ability to hide portions of geometry while sculpting, a very handy feature.  There were some additions to the motion tracking tools, as well as over 150 bug fixes.

 

 

One of the biggest releases in a very long time and the one I’ve been most eager to receive.  Kudos to the Blender team for this excellent release.

 

Go download it now!

Art, News

26. April 2012

 

I am noticing from search traffic that this is an extremely common question, people seem to want to know if you can use C++ with the PS Studio SDK.VitaCpp

 

 

Simple answer and you aren’t going to like it.

 

 

No, no you can’t.

 

 

 

I wouldn’t hold your breath either, it’s the mono runtime behind the scenes that is providing the portability across devices.  If you want native C++ support you need to have access to the full development suite.  Even becoming a PSN developer to develop PSN Mini games requires well over 1000$.

 

 

 

If for some reason you prefer C++’s syntax over C# ( this may in fact be a sign of insanity by the way… ), you *might* and I emphasize *might* be able to take advantage of this project CPlusPlus, at some point, but even then you would have to write pure CIL code.  Without native access, there would be very little point using C++ in this situation.

 

 

 

Therefore for all intents and purposes, no you cannot use C++ with PlayStation Suite. C# is the only game in town and I wouldn’t expect to see that change any time soon. 

Programming , ,

26. April 2012

 

In this tutorial we are going to manually manage the game loop manually.  Additionally we are going to look at the various ways of handling input from the gamepad.  This tutorial builds on the code we developed in the previous tutorial.  As you may recall, we created a “Hello World” sprite and centered it to the camera.  This time, we are going to give the user the ability to control the sprite’s position and size using the gamepad.

 

 

Let’s get straight to the code:

 

using System; using System.Collections.Generic; using Sce.Pss.Core; using Sce.Pss.Core.Environment; using Sce.Pss.Core.Graphics; using Sce.Pss.Core.Input; using Sce.Pss.HighLevel.GameEngine2D; using Sce.Pss.HighLevel.GameEngine2D.Base; using Sce.Pss.Core.Imaging; namespace HelloWorld { public class AppMain { public static void Main (string[] args) { Director.Initialize(); Scene scene = new Scene(); scene.Camera.SetViewFromViewport(); var width = Director.Instance.GL.Context.GetViewport().Width; var height = Director.Instance.GL.Context.GetViewport().Height; Image img = new Image(ImageMode.Rgba,new ImageSize(width,height),new ImageColor(255,0,0,0)); img.DrawText("Hello World", new ImageColor(255,0,0,255), new Font(FontAlias.System,170,FontStyle.Regular), new ImagePosition(0,150)); Texture2D texture = new Texture2D(width,height,false,PixelFormat.Rgba); texture.SetPixels(0,img.ToBuffer()); img.Dispose(); TextureInfo ti = new TextureInfo(); ti.Texture = texture; SpriteUV sprite = new SpriteUV(); sprite.TextureInfo = ti; sprite.Quad.S = ti.TextureSizef; sprite.CenterSprite(); sprite.Position = scene.Camera.CalcBounds().Center; scene.AddChild(sprite); Director.Instance.RunWithScene(scene,true); bool gameOver = false; while(!gameOver) { Sce.Pss.HighLevel.GameEngine2D.Director.Instance.Update(); if(Input2.GamePad.GetData(0).Left.Release) { sprite.Rotate(Sce.Pss.HighLevel.GameEngine2D.Base.Math.Deg2Rad(90)); } if(Input2.GamePad0.Right.Release) { sprite.Rotate(Sce.Pss.HighLevel.GameEngine2D.Base.Math.Deg2Rad(-90)); } if((Sce.Pss.Core.Input.GamePad.GetData(0).Buttons & GamePadButtons.Up) == GamePadButtons.Up) { sprite.Quad.S = new Vector2(sprite.Quad.S.X += 10.0f,sprite.Quad.S.Y += 10.0f); sprite.CenterSprite(); } if((Sce.Pss.Core.Input.GamePad.GetData(0).Buttons & GamePadButtons.Down) == GamePadButtons.Down) { sprite.Quad.S = new Vector2(sprite.Quad.S.X -= 10.0f,sprite.Quad.S.Y -= 10.0f); sprite.CenterSprite(); } if(Input2.GamePad0.Circle.Press == true) gameOver = true; Sce.Pss.HighLevel.GameEngine2D.Director.Instance.Render(); Sce.Pss.HighLevel.GameEngine2D.Director.Instance.GL.Context.SwapBuffers(); Sce.Pss.HighLevel.GameEngine2D.Director.Instance.PostSwap(); } Director.Terminate(); } } }

 

 

 

The top portion of the code is completely unchanged, our new additions start at the line:

Director.Instance.RunWithScene(scene,true);

 

The key addition here is the second parameter “true”.  This bool is telling the Director singleton that we are going to handle the game loop ourselves, this means we need to call 4 methods manually ( described in a moment ).  Next up we create a bool gameOver, which is going to control when we exit our game loop.  Obviously we don’t want to exit right away, so we default it to false.  Speaking of game loops, that’s what the while line does, loops over and over until gameOver is set to true.

 

Now in each iteration of our loop, there are four methods we have to call, Update(), Render(), GL.Context.SwapBuffer() and PostSwap().  Update() tells the director we have moved on to the next frame, Render() draws the frame, SwapBuffers displays what Render() drew on the backbuffer to the screen (makes it visible) and finally PostSwap() tells the director we’ve finished swapping buffers and it must be called after SwapBuffers().  Those four combined represent a complete game loop, all the rest of the code handles input from the game pad.

 

Just to make something perfectly clear here, I am using 3 different ways to check for input, *you won’t do this in your code*.  I am just doing it to illustrate all of your different options in one example.  You should just pick one ( probably Input2 ) and use only it.  Lets look at them one at a time.

 

if(Input2.GamePad.GetData(0).Left.Release) { sprite.Rotate(Sce.Pss.HighLevel.GameEngine2D.Base.Math.Deg2Rad(90)); }

 

 

This method is the most likely way you will deal with Input.  Input2 is a wrapper around the Input object to make things a bit simpler.  GetData takes a parameter telling it which control ( controller 1, controller 2, etc ) you want to poll, returning a GamePadData object, representing the state the controller is in.  We are then checking if the “Left” button has been released.  In the case Left is released, we then rotate our sprite 90 degrees.  Rotate takes an angle value in radians, so we use the Math.Deg2Rad() helper function to convert from degrees to radians.  Of course you could have passed the radian value in instead of converting, 1.5709633 is 90 degrees in radians, it’s just a bit harder to look at.

 

if(Input2.GamePad0.Right.Release) { sprite.Rotate(Sce.Pss.HighLevel.GameEngine2D.Base.Math.Deg2Rad(-90)); }

 

 

This if statement is almost identical to the last one, but instead of using GetData(0), we use a handy alias (GamePad0) that represents exactly the same thing.  The only other difference is, in this case we are checking to see if the “Right” button has been released, and we are rotating by a negative value ( the other way ) if it is.

 

 

if((Sce.Pss.Core.Input.GamePad.GetData(0).Buttons & GamePadButtons.Up) == GamePadButtons.Up) { sprite.Quad.S = new Vector2(sprite.Quad.S.X += 10.0f,sprite.Quad.S.Y += 10.0f); sprite.CenterSprite(); } if((Sce.Pss.Core.Input.GamePad.GetData(0).Buttons & GamePadButtons.Down) == GamePadButtons.Down) { sprite.Quad.S = new Vector2(sprite.Quad.S.X -= 10.0f,sprite.Quad.S.Y -= 10.0f); sprite.CenterSprite(); }

 

 

This time we are using Input directly, using Input instead of Input2.  As you can see, the results are a bit more “raw”.  In this case we have to use bit masking to determine if a given button is pressed and there is no Released option.  In this case we are checking for the “Up” and “Down” buttons.  In the event that the user is pressing Up or Down, we are modifying the Scale of the quad our hello texture is pasted on.  Remember initially Quad.S is equal to the size of the screen in pixels.  If we press Up, we scale the image up 10 pixels in size, if we press down, we shrink it by 10 pixels in size.

 

 

Finally, we check ( using the Input2 method ), if the user has pressed the Circle button, in which case we set gameOver to true, causing our loop to exit and our program to end.

 

 

One thing to notice at this point is how we scaled the sprite.  Unlike rotate, we didn’t call a method, instead we modified the Quad.S(cale) property.  The actual transformation matrix of a node ( which SpriteUV is derived from ) is actually determined combining the Position, Scale, Skew and Rotation+Angle+RotationNormalize properties.  Therefore modifying any of these properties will translate the node accordingly.

 

 

Now run our game, if we press left or right, we rotate 90 degrees, while pressing up or down scales the images.  Finally press Circle to exit.

 

 

helloworld2

 

 

One last thing I suppose needs covering… how exactly do you press Left, Right, or Circle on the simulator?

Left directional key
Cursor key: ←

Up directional key
Cursor key: ↑

Right directional key
Cursor key: →

Down directional key
Cursor key: ↓

Square button
Alphabet: A

Triangle button
Alphabet: W

Circle button
Alphabet: D

Cross button
Alphabet: S

SELECT button
Alphabet: Z

START button
Alphabet: X

L button
Alphabet: Q

R button
Alphabet: E

 

 

Sadly, you cannot currently emulate the analog sticks using the simulator.  Obviously you can on the Vita device.

 

EDIT: Oops, forgot to include the project source code, which you can download here.

Programming , , ,

Month List

Popular Comments

LWJGL 3.1 Released
Subscribe to GameFromScratch on YouTube Support GameFromScratch on Patreon


Home > >

31. October 2016

 

LWJGL, the Light Weight Java Game Library, is a low level game framework for Java layered over top of libraries such as OpenGL, CL, AL and Vulkan.  It has been used by a number of game engines including LibGDX and jMonkeyEngine to provide performant cross platform 3D support in Java.  LWJGL just released version 3.1, updating several of the underlying bindings, making various improvements and several bug fixes.

 

From the release notes:

Bindings
  • Bindings have been split into modules and are available as separate artifacts. (#100)
    • The download configurator on the website can be used to customize LWJGL builds and Maven/Gradle projects.
  • Added LMDB bindings.
  • Added Nuklear bindings. (#101)
  • Added Tiny File Dialogs bindings.
  • Added bgfx bindings. (#240)
  • Added support for new EGL, OpenCL, OpenGL, OpenGL ES and Vulkan extensions.
  • Updated all bindings to latest versions.
  • Vulkan javadoc is now almost identical to the Vulkan man pages, with links to the online Vulkan specification.
Improvements
  • Generator: Removed buffer object binding checks. (#197)
  • Generator: Added support for mapping byte/short parameters to int.
  • Generator: Added support for va_list parameters.
  • Generator: Reduced bytecode size of generated methods.
  • Generator: The Vulkan bindings are now automatically generated.
  • Optimized strlen methods used internally by LWJGL.
  • Optimized misaligned memSet and memCopy.
  • Added support for stack allocations with custom alignment.
  • Removed allocation functionality from read-only, externally managed structs.
  • Improved library loading diagnostics and added Configuration.DEBUG_LOADER option.
  • Libraries extracted by the SharedLibraryLoader are now locked to avoid conflicts with other processes (e.g. antivirus software). (#225)
  • Simplified javadoc of unsafe versions.
Fixes
  • Callback instances are now tracked when the DEBUG_MEMORY_ALLOCATOR option is enabled.
  • Fixed realloc tracking in the debug allocator.
  • Shared libraries that ship with LWJGL are now always preferred over system libraries.
  • Fixed return type of functions that return pointer to boolean.
  • stb_image: Fixed result auto-sizing of stbi_load* functions.
  • Functions that deallocate memory no longer have Java array overloads.
  • Fixed memSet bugs.
  • Fixed Java array overload generation for functions with multiple auto-size-result parameters.
  • Fixed custom checks in Java array overloads.
  • Fixed lookup of Critical JNI natives on Windows x86.
  • Disabled Critical JNI natives for functions affected by JDK-8167409 on Linux & MacOS.
Breaking Changes
  • xxHash: Added support for stack allocation of streaming hash state. Opaque handles have been replaced by the XXH*State structs.
  • NanoVG: Dropped version suffixes from NanoVGGL classes.
  • Mapped more integer parameters and return values to Java booleans, that were missed while working on #181.
  • Dropped VKUtil class and moved the version macros to VK10.

The LWJGL project is open source and available on Github here.

blog comments powered by Disqus

Month List

Popular Comments