I'm making a lightcycles game and i dont know how to make the game end if one of the Lightcycles touches the other ones' trail. Any ideas?
public void act() { GreenfootImage img = getWorld().getBackground(); if (img.getColorAt(getX(), getY()) == trailColor){ Greenfoot.stop(); } else{ img.setColor(trailColor); img.fillRect(getX(), getY(), trailWidth, trailHeight); getWorld().setBackground(img); getWorld().repaint(); move(3); }
if (trailColor.equals(img.getColorAt(getX(), getY()))){
if (trailColor.equals(img.getColorAt(getX(), getY()))){
if (trailColor.equals(img.getColorAt(getX(), getY()) == color.RED)){ Greenfoot.stop(); }