I am in the middle of making a simpler clone of the game Bejeweled, so far pretty much all i have is so my grid world(Bejeweled_World) gets populated properly so that no more than 2 in a straight line spawn e.g.
Now what i'm trying to do is make it possible to select one of the tiles in the grid and then switch it out with another one, either left, right, up or down. The code that I've tried so far is this:
This code i just put into one of my tile actors the actor called 'Sword'
Now what i'm trying to do is make it possible to select one of the tiles in the grid and then switch it out with another one, either left, right, up or down. The code that I've tried so far is this:
public class Sword extends Actor
{
public Sword()
{
getImage().scale(40, 40);
}
public int state = 0;
public void act()
{
if (state == 0)
{
if (Greenfoot.mousePressed(this))
{
state = 1;
}
}
else if (state == 1)
{
movement();
}
}
public void movement()
{
if (Greenfoot.isKeyDown("w") && Greenfoot.isKeyDown("a") && Greenfoot.isKeyDown("s") && Greenfoot.isKeyDown("d"))
{
setLocation(getX(), getY() - 1);
state = 0;
}
}
}
