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

2020/11/11

I have this as my code, but my character doesn't seem to move

Agentsolo Agentsolo

2020/11/11

#
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) /** * Write a description of class enemy here. * * @author (your name) * @version (a version number or a date) */ public class enemy extends Actor { /** * Act - do whatever the enemy wants to do. This method is called when * the 'Act' or 'Run' button gets pressed . */ public class startenemy extends Actor { /** * Act - do whatever the startenemy wants to do. This method is called whenever * the 'Act' or 'Run' button gets pressed in the environment. */ int timer = 20; int speed = 1; public void move() { timer--; if (timer > 0) move(speed); if (timer == 0) speed = -2-Greenfoot.getRandomNumber(30); if (timer < 0 && timer == speed) { speed = 1-3*Greenfoot.getRandomNumber(2); timer = 2+Greenfoot.getRandomNumber(30); } } private int setRandomNumber(){ int num = Greenfoot.getRandomNumber(2); int numf=0; if(num==1){ num=1; } if(num==2){ num=-1; } return num; } public void flipLeft() { if (getRotation() == 0){ turn(180); getImage().mirrorVertically(); } } public void flipRight() { if (getRotation() == 180) { turn(180); getImage().mirrorVertically(); } } } }
syd syd

2020/11/11

#
You need a semicolon at the end of your public class for act.
syd syd

2020/11/11

#
Also, I'll stick around for like 10 minutes, so can you run it with the curly bracket and then tell me the result. (I meant to say curly bracket not semi colon sorryyy)
Agentsolo Agentsolo

2020/11/11

#
haha thank you ill try it
Agentsolo Agentsolo

2020/11/11

#
syd wrote...
You need a semicolon at the end of your public class for act.
where exactly do i add it. I don't see it
danpost danpost

2020/11/11

#
Agentsolo wrote...
where exactly do i add it. I don't see it
You seem to have a class inside a class -- and no act method to speak of.
You need to login to post a reply.