Hello to everyone,i need ur all help and thank you very much. Pls be patient and see my program like below
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* Write a description of class Robot here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class Robot extends Runner
{
/**
* Act - do whatever the Robot wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
boolean moving=true;
public Robot()
{
}
public Robot(int dx, int dy, boolean runningStatus)
{
super(dx,dy,runningStatus);
}
/*public Robot(boolean runningStatus)
{
super(runningStatus);
}*/
public void runningAct()
{
if(moving)
{
super.runningAct();
moving = false;
}
}
public void setMoving(boolean moveAllowed)
{
moving = moveAllowed;
}
}
the question is when i done all like above i run my project,i click the tile several time and the robot will above to horizontally to the right a pace of 5 unit. But i tried many times still the robot can move anymore. actuaaly i wan upload picture but i don know how to upload. hope u all can help me
import greenfoot.*;
import java.awt.Color;
/**
* Write a description of class MyWorld here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class MyWorld extends TK2934World
{
/**
* Constructor for objects of class MyWorld.
*
*/
public MyWorld()
{
super(750, 580);
displayTimer();
resetTimer(300);
startTimer();
MoveRightTile r = new MoveRightTile();
addObject(r,500,300);
//MoveLeftTile l = new MoveLeftTile();
//addObject(l,400,300);
Robot robot = new Robot(5,0,true);
addObject(robot,50,100);
robot.setMoving(false);
}
public void world_act()
{
if(timesUp())
{
displayMessage("Time's Up",Color.red);
}
}
public void moveRobot()
{
Robot robot = new Robot(5,0,true);
robot.setMoving(true);
}
}import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
import java.awt.Color;
/**
* Write a description of class MoveRightTile here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class MoveRightTile extends Tile
{
/**
* Act - do whatever the MoveRightTile wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public void clickedAct()
{
MyWorld my = new MyWorld();
my.moveRobot();
}
}
