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

2014/11/16

Hey i need some help! :)

Erdrag Erdrag

2014/11/16

#
Hey, im new to programming and im trying to program my ants to go and find food, how can i code so whenever a food pops up in the game, a ant goes out from the Anthill and tries to get the food? // Erdrag
danpost danpost

2014/11/16

#
From what you have given, it would be correct to say that when the number of food objects in the world is incremented, one ant from within the anthill should venture out to find it. So, there should be a one-to-one correlation between the number of ants outside the anthill and the number of food objects in the world. This last statement should then be the basis on how to program it (this can be done in your world subclass act method -- or a method it calls).
Erdrag Erdrag

2014/11/16

#
I searched on google, and i saw that you can make food appear on the screen at random times, and a group of ants go out and take the food then head back home, everytime food appears on the screen, how to i code this? ive looked everywhere but i cant find it. if you know the code, i would be gratefull if you could write it, so i can learn it :) as i said im new to this
danpost danpost

2014/11/16

#
What parts of this are you having problems with? and what parts can you already do? (1) Do you know how to create an object and add it into a world programmatically (without manually clicking one into the world); (2) Do you know how to create a random number; (3) If yes to (2), do you know how to random pick any location within a world; (4) Do you have any idea where to code to randomly add food into the world should go.
Erdrag Erdrag

2014/11/25

#
You need to login to post a reply.