im having a issue where my if loop ain't working
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* Write a description of class mouse here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class mouse extends Actor
{
int speed = 2;
static String shootkey = "Q";
boolean shots = false;
int runonce = 0;
int x2 = 50;
/**
* Act - do whatever the mouse wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public void act()
{
PlayerStuff();
devstats();
}
void devstats()
{
//getWorld().showText("shots"+ shots, 100, 100);
}
void PlayerStuff()
{
Movement();
Weapons();
}
void Movement()
{
turnTowards(Greenfoot.getMouseInfo().getX(), Greenfoot.getMouseInfo().getY());
if (Greenfoot.isKeyDown("w"))
{
move(speed);
}
if (Greenfoot.isKeyDown("S"))
{
move(-speed);
}
}
void Weapons()
{
Pistols(P_1911.class,5,10,50);
}
void Pistols(Class x,int dam,int ItemSpeed,int cooldown)
{
int oldcooldown = cooldown;
if (cooldown >= 0)
{
getWorld().showText("timer"+ cooldown, 100, 100);
cooldown = cooldown - 1;
getWorld().showText("timer"+ cooldown, 100, 100);
}
if(isTouching(x))
{
Actor Item = (Actor)getWorld().getObjects(x).get(0);
Item.setLocation(getX(), getY());
if (Greenfoot.isKeyDown(shootkey)){
shots = true;
}else{shots = false;}
}
if (shots == true)
{
if (runonce == 0){
good bullet = new good();
getWorld().addObject(bullet, getX(), getY());
//end
runonce = 1;
}
}
}
}
