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

2015/9/21

Need Help With a Game

SonofArith SonofArith

2015/9/21

#
The basic premise of my game is very simple; you are a seal, and you are trying to eat grapes and kill camels. You have to hold space to kill the camels, and if you don't they kill you. I want there to be a cool down time for the space bar press, so you can hold it for 3 seconds, then you have to wait two or something like that. This is the code for my seal, and the spacebar: public void nom() { Actor camel; camel = getOneObjectAtOffset(0, 0, camel.class); if(Greenfoot.isKeyDown("space")) { if(camel != null) { World world; world = getWorld(); world.removeObject(camel); area1 area1 = (area1)world; counter counter = area1.getCounter(); counter.addScore(); camelseaten++; if(camelseaten == 10) done(); } } Actor grape; grape = getOneObjectAtOffset(0, 0, grape.class); if(grape != null) { World world; world = getWorld(); world.removeObject(grape); area1 area1 = (area1)world; counter counter = area1.getCounter(); counter.addScore(); grapeseaten++; } } I also have a score counter for the grapes and the camels. Tell me if you need anything else.
danpost danpost

2015/9/21

#
Please be a bit more specific. You need to determine and relay the following: * what conditions are required to begin the "re-charging" (specify all that apply) * what conditions are required to allow the space to trigger the killing of camels (specify all that apply) * what actions are taken (as far as anything that applies) when the "space" key is released (specify for all ranges of the timer (obviously you will need a timer) Give all actions and what conditions are required to begin those actions for the timer. If the timer is to count act cycles (which is probably best), three seconds would be about 150 cycles (provided the scenario is running at standard speed -- speed slider around the middle of the bar). Use checks on the value of the timer as conditions for actions to take (i.e only allow the pressing of "space" to trigger killing camels when the value of the timer is 150).
You need to login to post a reply.