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

2014/10/24

I need help making a scoreboard.

zekromslayer zekromslayer

2014/10/24

#
hey guys, im new to greenfoot and i want to know how to add a scoreboard to a simple game the Oracle taught me. Please hel
import greenfoot.*;  // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)

/**
 * Write a description of class Ball here.
 * 
 * @author (your name) 
 * @version (a version number or a date)
 */
public class Ball extends Actor
{
    /**
     * Act - do whatever the Ball wants to do. This method is called whenever
     * the 'Act' or 'Run' button gets pressed in the environment.
     */
    public void act() 
    {
        // Add your action code here.
        setRotation(0);
        if(Greenfoot.isKeyDown("d"))
            {move(5);}
            if(Greenfoot.isKeyDown("a"))
            {move(-5);}
        setRotation(90);
            if(Greenfoot.isKeyDown("w"))
            {move(-5);}
            if(Greenfoot.isKeyDown("s"))
            {move(5);}
       removeTouching(null);           
    }    
}}
p!
zekromslayer zekromslayer

2014/10/24

#
help*
Super_Hippo Super_Hippo

2014/10/25

#
I don't see any attempt in this code. You can import the Scoreboard class and follow the instructions there.
zekromslayer zekromslayer

2014/10/27

#
where do i get that?
danpost danpost

2014/10/27

#
By 'scoreboard', do you mean something that displays a running score during the game? or something that displays a final score after the game? or something that displays a list of high scores by multiple users after the game?
jimboweb jimboweb

2014/11/10

#
If you want to keep score during the game, I have made a downloadable ScoreBoard class that you might find useful. You can find the class here: http://mrstewartslessons.com/useful_class_scoreboard.html Simply download the class into your Greenfoot project folder. Close Greenfoot and open it again and you'll see the ScoreBoard class among your actors. Open its code window and change 'Source Code' to 'Documentation' and you'll see directions as to how to use it in your actor's code. It has various constructors that allow you to set the size, the color and the location on the screen, and various methods for increasing, decreasing and resetting the score. Hope it helps.
You need to login to post a reply.