does anyone know how to make gameover on the screen when the player 1 score 10 and player2 score 20 and how to disappear and appear objects from opposite side
private void wrapEdges() { int r = getRotation(); if (getX() == getWorld().getWidth()-1 && (r > 270 || r < 90)) setLocation(0, getY()); if (getX() == 0 && r > 90 && r < 270) setLocation(getWorld().getWidth()-1); if (getY() == getWorld().getHeight()-1 && r < 180) setLocation(getX(), 0); if (getY() == 0 && r > 180) setLocation(getX(), getWorld().getHeight()-1); }
wrapEdges();
if (Greenfoot.getRandomNumber(180) == 0) turn (Greenfoot.getRandomNumber(180)-90);
Actor player_1 = getOneIntersectingObject(player1.class); if (player_1!=null) { if(isTouching(player1.class)) { turn(90+Greenfoot.getRandomNumber(180));\ } } Actor player_2= getOneIntersectingObject(player2.class); if (player_2!=null) { if(isTouching(player2.class)) { turn(90+Greenfoot.getRandomNumber(180)); } } if(isAtEdge()){ turn(90+Greenfoot.getRandomNumber(180)); } } private void wrapEdges() { int r = getRotation(); if (Greenfoot.getRandomNumber(180) == 0) turn (Greenfoot.getRandomNumber(180)-90); if (getX() == getWorld().getWidth()-1 && (r > 270 || r < 90)) setLocation(0, getY()); if (getX() == 0 && r > 90 && r < 270) setLocation(getWorld().getWidth()-1); if (getY() == getWorld().getHeight()-1 && r < 180) setLocation(getX(), 0); if (getY() == 0 && r > 180) setLocation(getX(), getWorld().getHeight()-1); }
if(ball.ycoordinate>y) { setLocation(x , y + 5); } if(ball.xcoordinate<y)[quote]actor class[/quote] { setLocation(x, y - 5); } }
public void(){ int x,y; if(ball.ycoordinate>y) { setLocation(x , y + 5); } if(ball.xcoordinate<y)[quote]actor class[/quote] { setLocation(x, y - 5); } } the class code of ball
Actor player_1 = getOneIntersectingObject(player1.class); if (player_1!=null) { if(isTouching(player1.class)) { turn(90+Greenfoot.getRandomNumber(180));\ } } Actor player_2= getOneIntersectingObject(player2.class); if (player_2!=null) { if(isTouching(player2.class)) { turn(90+Greenfoot.getRandomNumber(180)); } } if(isAtEdge()){ turn(90+Greenfoot.getRandomNumber(180)); } } private void wrapEdges() { int r = getRotation(); if (Greenfoot.getRandomNumber(180) == 0) turn (Greenfoot.getRandomNumber(180)-90); if (getX() == getWorld().getWidth()-1 && (r > 270 || r < 90)) setLocation(0, getY()); if (getX() == 0 && r > 90 && r < 270) setLocation(getWorld().getWidth()-1); if (getY() == getWorld().getHeight()-1 && r < 180) setLocation(getX(), 0); if (getY() == 0 && r > 180) setLocation(getX(), getWorld().getHeight()-1); }
public void(){ int x,y; if(ball.ycoordinate>y) { setLocation(x , y + 5); } if(ball.xcoordinate<y)[quote]actor class[/quote] { setLocation(x, y - 5); } }
public class ball1 extends Actor { /** * Act - do whatever the ball1 wants to do. This method is called whenever * the 'Act' or 'Run' button gets pressed in the environment. */ public int direction = 10; public void act() { move(direction); wrapEdges(); Actor player_1 = getOneIntersectingObject(player1.class); if (player_1!=null) { if(isTouching(player1.class)) { turn(90+Greenfoot.getRandomNumber(180));\ } } Actor player_2= getOneIntersectingObject(player2.class); if (player_2!=null) { if(isTouching(player2.class)) { turn(90+Greenfoot.getRandomNumber(180)); } } if(isAtEdge()){ turn(90+Greenfoot.getRandomNumber(180)); } } private void wrapEdges() { int r = getRotation(); if (Greenfoot.getRandomNumber(180) == 0) turn (Greenfoot.getRandomNumber(180)-90); if (getX() == getWorld().getWidth()-1 && (r > 270 || r < 90)) setLocation(0, getY()); if (getX() == 0 && r > 90 && r < 270) setLocation(getWorld().getWidth()-1); if (getY() == getWorld().getHeight()-1 && r < 180) setLocation(getX(), 0); if (getY() == 0 && r > 180) setLocation(getX(), getWorld().getHeight()-1); }