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

2014/4/30

Codes for making a Scorecounter

1
2
Neymar.Jr Neymar.Jr

2014/4/30

#
Wanting The codes for making a scoreboard in greenfoot
danpost danpost

2014/4/30

#
What all do you want the scoreboard to display? will it be a running counter during gameplay or a final scoreboard after the game is over?
Neymar.Jr Neymar.Jr

2014/5/1

#
I want to display the score of two players during the game is running
danpost danpost

2014/5/1

#
From the menubar, select 'Edit>Import class...' , select the 'Counter' class and click the 'Import' button. Then create two instances of the Counter class and pass one to each player, when creating them, to hold and use.
Neymar.Jr Neymar.Jr

2014/5/1

#
But how do I link it to the player, For example i want it to add like 75 points when the bullet collides with the enemy and is destroyed
danpost danpost

2014/5/1

#
You can pass the player's counter on to the bullets they create; so, the bullets know which counter to add the score to.
Neymar.Jr Neymar.Jr

2014/5/1

#
and the code for that would be
danpost danpost

2014/5/1

#
What do you have for creating the players and the counters in your world class? What do you have in the Player classes as far as the counters are concerned?
Neymar.Jr Neymar.Jr

2014/5/1

#
i have nothing for the counters, I only imported the counter and not sure what to do next to get it working
Neymar.Jr Neymar.Jr

2014/5/1

#
Its okay everything is fine but I want to know how to carry on the counter every level rather then loosing the current score then making a new counter next level.
Neymar.Jr Neymar.Jr

2014/5/2

#
It works but every level it gets created a new one but looses the current score. How do I make it carry on the counter rather then making one every level.
danpost danpost

2014/5/2

#
What is the name of the world you are in, and what is the code you are using to go to the next level?
Neymar.Jr Neymar.Jr

2014/5/2

#
the name is Level1 and the code is
if(isLevelCompleted()) {
            Greenfoot.setWorld(new Level2(score));
        }
danpost danpost

2014/5/2

#
Alright. What are you doing with the 'score' value that is being passed to the Level2 constructor? (in your Level2 class code, show section that starts 'public Level2(int score)' ).
Neymar.Jr Neymar.Jr

2014/5/2

#
 public Level2(ScoreManager score) {
        super(new LevelInfo(
            10,          // Total enemies
            3,           // Enemy max health
            6,           // Enemy speed
            100,         // Enemy value
            Color.GREEN  // Background color
        ), score);
    }
There are more replies on the next page.
1
2