hello, I am currently working on a game where the objective of the game is to collect as many points as you can. However im finding it challenging to move the player because it is not just a simple "move()" command. If anyone has played the tron light bike game that would be very helpful because I want my character to move like that, this is my code so far:
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* Write a description of class blueBlock here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class blueBlock extends PlatformMover
{
/**
* Act - do whatever the blueBlock wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public blueBlock()
{
setDirection(EAST);
}
public void act()
{
Control();
}
public void Control()
{
if(Greenfoot.isKeyDown("up"))
{
turn(getRotation() + 90);
}
if(Greenfoot.isKeyDown("down"))
{
turn(getRotation() - 90);
}
if(Greenfoot.isKeyDown("left"))
{
move(-3);
}
if(Greenfoot.isKeyDown("right"))
{
move(3);
}
}
And in my platform mover class i have :
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* Write a description of class PlatformMover here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class PlatformMover extends Actor
{
public static final int EAST = 0;
public static final int WEST = 1;
public static final int NORTH = 2;
public static final int SOUTH = 3;
/**
* Act - do whatever the PlatfromMover wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public int direction;
public void act()
{
}
public void setDirection(int direction)
{
this.direction = direction;
switch(direction)
{
case SOUTH:
setRotation(90);
break;
case EAST:
setRotation(0);
break;
case NORTH :
setRotation(270);
break;
default :
break;
}
}
}
All my actor does right now is go up and down and turn up and down