This site requires JavaScript, please enable it in your browser!
Greenfoot back
vdk
vdk wrote ...

2014/4/21

Ping Pong

vdk vdk

2014/4/21

#
I'm making a kind of pingponggame and I want that if the computer or the player has a score of 5, game over appears. This is my code for my counter... import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) import java.awt.Color; public class Counter extends Actor { public LeftBat linkerbat; public RightBat rechterbat; private static final Color defaultColor = new Color(255, 255, 255); private int count_score = 0; public void act() { setImage(new GreenfootImage(linkerbat.getScore() + "-" + rechterbat.getScore(),30,Color.BLACK,null)); gameOver(); } public Counter(LeftBat lb, RightBat rb) { linkerbat = lb; rechterbat = rb; } public void gameOver() { if ( if (count_score ==5) { Greenfoot.stop(); } } }
You need to login to post a reply.