This site requires JavaScript, please enable it in your browser!
Greenfoot back
ThatCodingGuy

ThatCodingGuy

Welcome to my page

ThatCodingGuy's scenarios

play SubmArena

ThatCodingGuy's collections

This user has no collections

Recent Comments

ThatCodingGuy

2014/3/21

Im sorry, I didnt realize I had done that
ThatCodingGuy

2014/3/20

Actually i am using the "isKeyDown" method. Here is the code for the submarine import greenfoot.*; public class Submarine extends Movement { private int gunReloadTime = 200; private int reloadDelayCount = 0; public void act() { move(); reloadDelayCount++; } public void move() { if(Greenfoot.isKeyDown("up")) //The different moving keys { move(3); } if(Greenfoot.isKeyDown("down")) { move(-3); } if(Greenfoot.isKeyDown("right")) { turn(3); } if(Greenfoot.isKeyDown("left")) { turn(-3); } if(Greenfoot.isKeyDown("shift")) { shoot(); } } public void setGunReloadTime(int reloadTime) //Defines the reload time { gunReloadTime = reloadTime; } public void shoot() { if(reloadDelayCount >= gunReloadTime) //Fires a torpedo { getWorld().addObject(new Torpedo(getRotation()), getX(), getY()); reloadDelayCount = 0; Greenfoot.playSound("fire.wav"); } } }