Yoshi21137 wrote...
and it won't construct the world until whatever is wrong is fixed
tried the first option but it says there is also something wrong with:
<< Code Omitted >>
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* Write a description of class Knight here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class Knight extends Players
{
Main main = (Main)getWorld();
int kills = main.kills;
int bulletSpeed = 100;
int lives = ((Main)getWorld()).lives;
/**
* Act - do whatever the Knight wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public void act()
{
checkKeys();
looseHealth();
}
public void looseHealth()
{
if (canSee(GoblinShaman.class))
{
lives = lives-1;
}
}
public void checkKeys()
{
if (Greenfoot.isKeyDown("w"))
{
turn(-90);
move(5);
turn(90);
}
if (Greenfoot.isKeyDown("s"))
{
turn(90);
move(5);
turn(-90);
}
if (Greenfoot.isKeyDown("d"))
{
move(5);
}
if (Greenfoot.isKeyDown("a"))
{
move(-5);
}
if(Greenfoot.isKeyDown("enter") && getObjectsInRange(bulletSpeed, Bullet.class).isEmpty())
{
getWorld().addObject(new Bullet(), getX()+40, getY()+8);
}
}
}public void die()
{
if (canSee(Bullet.class))
{
(main).kills = (main).kills+1
main.removeObject(this)
}
}public void die()
{
if (canSee(Bullet.class))
{
(main).kills = (main).kills+1;
main.removeObject(this);
}
}(main).kills = (main).kills+1;
Main main = (main)getWorld();
public void die()
{
if (canSee(Bullet.class))
{
(main).kills = (main).kills+1;
main.removeObject(this);
}
}public void kill()
{
if (isTouching(GoblinShaman.class))
{
Main main = (Main)getWorld();
removeTouching(GoblinShaman.class);
main.kills = main.kills+1;
}
} int kills = 0;
/**
* Constructor for objects of class MyWorld.
*
*/
public Main()
{
super(1000, 650, 1);
prepare();
showText(""+lives, 73, 42);
showText(""+kills, 73, 66);
}