Game in a Game efficient possible?

hi everyone,



does somebody now if its possible, when jme is used as "host" or primary game, that "mini" games

can be played inside the host (jme) game.



for example:

i use jme and have a world(scene), say a game hall, where i can go to virtual arcade computers and

play mini games like pacman which a programmed in java2d.



i found a thread here which describes how to display java2d drawings with bufferedimages which are

drawn in jme as texture.

(see http://www.jmonkeyengine.com/wiki/doku.php?id=using_java2d_to_create_the_hud_texture)



so it is theoretical possible to programm a game (or animation) in java2d and show it in jme.

but the question is, is this performant? as stated in the link above, it should not be used to much in short time…

but a game must be drawn at least 30 times a second, in the worst case as big as the screen resolution is set to.

can this be implemented in a performant way?



the next question is, if i can use jme as host AND for the mini games.

maybe this can be done with multiple scene graphs where a scene is another game which is attached to the main game node somewhere.  :mrgreen:



complicated stuff  :smiley:

Use GameStates and it's relatively simple.

i guess this is your answer to the second question.

so depending on the gamestate,  i use another scene node for each game… e.g. a node for thepacman game?

this would work if i totally change the game mode to only ONE game at the same time, so when i trigger the mini game i see ONLY the mini game…

but what if i am not close to the game spot (the arcade computer)…

what if i look at 2 computers? then there are 2 gamestates for 2 games which i must see at the same time…


You can have as many game states running at a time as you want…that's no problem.

what is a "game state" in your meaning?



in my understanding this is a unique state where the application actually is…

like:


  • intro
  • main menu
  • game
  • ingame menu
  • exit





    thought there can only be ONE state at the same time…

    can you explain a bit more detailed what you mean :)?

Check this out:



http://www.jmonkeyengine.com/wiki/doku.php?id=standardgame_gamestates_and_multithreading_a_new_way_of_thinking



There is actually something in jME called a GameState that has has its own update and render methods. Typically it will have its own rootNode and if multiple are enabled at the same time they will simply render together.

in which order are multiple active gamestates drawn?

what happens if they overlap?.. if box A from gamestate A is in same location like sphere b from gamestate b.



are there any complete tutorials, how to use the new game state system like you described in your article?

maybe in svn?





does someone have an answer to part 1 of my questions… how java2d games perform in a jme game.

Drawing java2d to a texture and display that is not really performant. You can use OpenGL 2D drawing functions if you want it performant. Or you can use jME in a canvas and hide that canvas to show your java2d game. Both should be nice, the latter is probably much less work.

If you newly create those minigames consider implementing them with jME (e.g. use Quads as sprites etc.). Then the GameStates may come in handy, as darkfrog suggests.

As I understand it, it doesn't matter what order your gamestates are in as when they are actually drawn they will be drawn with correct depth. So if you have an object in one scene that should be behind an object in another scene (gamestate) it will work like they were in the same scene.