Need some advice

Hi would like to ask some advice. I just finished reading all the documentation and would like to make my first project in jMonkey.
I decided to make a spaceship game similiar to: aero fighter (For those unfamiliar with the game or do not remember: http://www.youtube.com/watch?v=t5M4zvO3qa8 )

My big problem is how to implement the scenario. What is the best way to do this? remember that I am new in using jMonkey.

Should I use skybox? or just use a plane at bottom with a picture?

Any advice will be well received.

I’m not sure what to do for the background (to make it infinitely scrollable), though i dont think a skybox is what you want as they dont really behave that way. Youd probably want several background textures that can be tiled, and you can load the next part of the level as you get close. There might be better solutions.

if i did this game i’d probably add all the game objects to the gui node, since its more of a 2d game.

@toolforger is currently in the progress of making a tutorial for a 2D shoot-em-up (but of a different style) you could probably look at the current progress of his tutorial for some ideas though as I’m sure a lot would cary over : http://hub.jmonkeyengine.org/forum/topic/monkey-blaster-toolforger-edition-p1/

Yeah. I was initially hesitant to abuse guiNode for 2D games, but it’s already prepared for 2D display (camera, perspective, culling off, parallel perspective, somethine else I forgot - it’s quite a list), and you can still put your GUI stuff in front of the game itself so it’s not that you’ll be losing anything.

Skyboxes are supposed to be at a “large” distance, so they never change their appearance unless you exchange the texture (which means you transfer the bitmap to the GPU).
Just use moving images.

The tutorial keeps everything at the Z=0 plane. You should be able to get multiple planes by associating a different Z value with each.
Easiest way is to generally use Vector3f to place stuff. The demo uses Vector2f because it doesn’t need Z.

Have fun!

play with the Z plane was the first idea that came to mind. But then I came the question of how to generate the sensation of movement.

Any advice?

PD: I’ll check your tutorial.

Just use a background image that’s larger than the visible screen, and move it downwards (i.e. modify its Y position via setLocalTranslation).

The Z plane is just to create the proper layering.
Normal GUI stuff (Nifty etc.) tends to be at Z=0, and I dimly remember that valid Z coordinates for the gui node are between -1 and +1 (stuff outside gets culled I think).
Not sure whether Z grows towards the player or away from him, if it’s away then I’d put shots at 0.1, enemy planes at 0.2, and enemy bosses at 0.3 (planes fly “over” the boss). Use other Z layer values as the need arises, just have a clear plan what’s going to be displayed at what layer.

TBH I wouldn’t use the GUI node for this. After all you want your planes and suchlike to be moving (or at least using) 3d.

For the background just create a quad filling the camera and either slide the texture over it or slide the quad and tile in a new one at the top as they reach the end of the previous one. (The second approach is probably simpler).

I think guiNode if good enough if all game objects can be displayed as sprites.
If you want to show off different sides of a 3D model depending on perspective, then you’d need rootNode.

in a first approach i want make it as simple as possible, but eventually the ship model could have 3D movements, maybe some special ability as dodge attacks or something similiar

Well, if you need to show left side and right side, and sprite exchange would be more work than making a 3d model, then you’d probably better stick with a full 3d scene and use rootNode.

Now the question is: How do you set up camera and perspective and everything if the screen size isn’t predetermined?
Also, you’d want to stick with parallel projection.

The idea is that the camera is viewed from above, as in the Aero fighter game or the game 1942. But eventually the ship will make 3D moves.
In one of the tutorials shows how to set the camera view to an orthogonal view, but i don’t know if that is not enough.

You’ll want to set up the camera so that the background fills the screen exactly.
And you’ll want to disable the flycam appstate so the players don’t inadvertently modify the camera settings.

@toolforger said: You'll want to set up the camera so that the background fills the screen exactly. And you'll want to disable the flycam appstate so the players don't inadvertently modify the camera settings.

…actually, remove it completely. You can do this by just not adding it in the first place (in the super() call) or by detaching it in simpleInitApp().

I would take this approach:

Render everything Off-screen and use the output of the frame buffers to display on quads in the GUI node.

This way you have the following:

The ability to use paging for background tiles, build them as you need (attach/dettach specific objects, etc).
The player and enemy ships can rotate in 3d even though they are presented in 2d.

I have an example out here somewhere that used this technique for the player ship… and rotated the off-screen camera around the rendered object to bank the ship left and right based on joystick axis.

Anyways… this allows you to build your entire game leveraging the 3d aspect of JME in a platformer type 2d game.

I found it… so you don’t have to go looking for it:

[video]http://youtu.be/S4Jdgo8Eh5Y[/video]

I’m rotating the images just around the Z axis, so I don’t need offscreen rendering.
See - YouTube for an example.

Those blue shots are Picture objects with their localRotation modified. Which works but doesn’t allow setting the color independently of the image.

@toolforger said: I'm rotating the images just around the Z axis, so I don't need offscreen rendering. See https://www.youtube.com/watch?v=4J9uhFx_M_8 for an example.

Those blue shots are Picture objects with their localRotation modified. Which works but doesn’t allow setting the color independently of the image.

Write a custom shader and use black-white Textures…

Should only be a four-liner fragmentshader…

[java]
uniform vec4 inColor;
uniform sampler2d inTexture;
in vec2 texCoord;
void main(){
glFragColor=vec4(texture2D(inTexture,texCoord).xyz*inColor.xyz,1);
}

[/java]

//just wrote blindly here… but should be very similar

@zzuegg said: Write a custom shader and use black-white Textures..

Should only be a four-liner fragmentshader…

[java]
uniform vec4 inColor;
uniform sampler2d inTexture;
in vec2 texCoord;
void main(){
glFragColor=vec4(texture2D(inTexture,texCoord).xyz*inColor.xyz,1);
}

[/java]

//just wrote blindly here… but should be very similar

…or just use Unshaded.j3md which does pretty much exactly this though it will also let you set alpha with the color.

1 Like
@t0neg0d said: I found it... so you don't have to go looking for it:

[video]http://youtu.be/S4Jdgo8Eh5Y[/video]

if you do not mind, I would like to see the source code for this example.

Thank you. -

@hickaru said: if you do not mind, I would like to see the source code for this example.

Thank you. -

You have access to it… it was created using the tonegodGUI plugin. I used the OSRViewPort with it. Though, for your particular case, I would just kype the source code and and make it a bit more specific for your purposes.

@toolforger said: I'm rotating the images just around the Z axis, so I don't need offscreen rendering. See https://www.youtube.com/watch?v=4J9uhFx_M_8 for an example.

Those blue shots are Picture objects with their localRotation modified. Which works but doesn’t allow setting the color independently of the image.

Hey… off topic, but I saw a more recent vid of this. Starting to look cool =)