This site requires JavaScript, please enable it in your browser!
Greenfoot back
agray11202
agray11202 wrote ...

2017/12/2

Making my first game!

agray11202 agray11202

2017/12/2

#
My game is basically two characters going around and collecting different foods to assemble a burger. Once they have all the necessary elements, they go to the burger shop and create a burger, then eat it! Just have a few questions about what methods/codes to use: -How do I make the actors in my class randomly pop up? -Is it possible for one actor to call another actor to appear in the game? -Is it possible to put all of the ingredients I have touched into an if/then statement? (like if one actor has touched a specific amount of other actors do..., else...)
MarioLuigi MarioLuigi

2017/12/2

#
agray11202 wrote...
Is it possible for one actor to call another actor to appear in the game?
You can use the method Greenfoot.getRandomNumber(int) to generate a random integer. The number will be generated between 0 and the number in brackets. You can use this number to spawn an object at a random point.
agray11202 wrote...
Is it possible for one actor to call another actor to appear in the game?
getWorld().addObject(new yourObject(), x-coordinate, y-coordinate)
danpost danpost

2017/12/2

#
agray11202 wrote...
How do I make the actors in my class randomly pop up?
Let your world control that through its act method.
Is it possible for one actor to call another actor to appear in the game?
If you mean create another actor and add it into the world -- no problem:
getWorld().addObject(new ActorClassName(), 0, 0); // can be placed wherever
Is it possible to put all of the ingredients I have touched into an if/then statement? (like if one actor has touched a specific amount of other actors do..., else...)
It is possible to track which actors, or type of actors, have been touched. An int field or multiple boolean fields will probably be required.
You need to login to post a reply.