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

2023/9/25

I am trying to use the wait(); command but I am not able to work this out

Lolan Lolan

2023/9/25

#
I'm trying to make a zombie survival game when you shoot zombies with a gun. but the problem is that my gun doesn't have a timer on it and just continually shoots. Is anyone able to help me? Code for the gun \/ \/ \/ public void act { //Shooting code here \/ \/ \/ if (Greenfoot.isKeyDown("space")){ fire(); wait(10); } } // fire the bullet public void fire() { Bullet bullet = new Bullet(); getWorld().addObject(bullet, getX(), getY()); } } All the other code works, its just that the wait command doesn't work.
danpost danpost

2023/9/25

#
Lolan wrote...
All the other code works, its just that the wait command doesn't work.
Do not use the wait command. That is mainly for developers (not programmers). Add an int field to count act cycles to make the delay between shots.
Lolan Lolan

2023/9/25

#
Thank you! but are you able to provide a example? Thank you!
Lolan Lolan

2023/9/25

#
never mind. I managed to do it! Thank you very much for the help! have a great day (:
You need to login to post a reply.