scoreboard

How do I do a scoreboard for a game like pong?

An ScoreBoard class for your game? Think about your game mechanics and add that class with that behavior. As a ScoreBoard is usually a singleton, create it that way and add the AddScore(Player, Points) to be added to an array of best 10 players. To Show the scoreboard you can create a Show/Display and voil… Xojo is a mavel OOP software and best is to follow pure OOP paradigms.

Can you give me an example code using ‘pongball’ and ‘paddle’?

Don’t really understand… An ScoreBoard just holds info about the best players/(hits-misses). Don’t understand the relationship with pongball and paddle. Those are actually different classes.

If PongBall is not hit by paddle and you have 0 lives, just add it to ScoreBoard class. Just get the most 10th best players and you have an scoreboard working.

[quote=167258:@Amando Blasco]Don’t really understand… An ScoreBoard just holds info about the best players/(hits-misses). Don’t understand the relationship with pongball and paddle. Those are actually different classes.

If PongBall is not hit by paddle and you have 0 lives, just add it to ScoreBoard class. Just get the most 10th best players and you have an scoreboard working.[/quote]

so
if (Pongball < 0) then
lives = 0
end if

?

I might have understood the question wrong, the question is “Add a score for each player. The game starts again after a player reaches 5 points.”

I am doing a pong game and in that I’ve already had the pongball and both paddles but what I don’t know is the score board and how to reset the game automatically after the five points have been scored.

I would do it like:

Score.GetInstance.Add(PlayerName, Score) This is a Singleton (a class instance we only need once per app roughly)

To Show the Score

Score.GetInstance.Show()

a Property like an array of pairs for player and score.

There is a Xojo example pattern about Singletons (quite easy/common pattern).

If Lives = 0 then
Score.GetInstance.Add(Player,Score)

To Show:

Score.GetInstance.Show(max as integer = 5)

[quote=167264:@Amando Blasco]I would do it like:

Score.GetInstance.Add(PlayerName, Score) This is a Singleton (a class instance we only need once per app roughly)

To Show the Score

Score.GetInstance.Show()

a Property like an array of pairs for player and score.

There is a Xojo example pattern about Singletons (quite easy/common pattern).

If Lives = 0 then
Score.GetInstance.Add(Player,Score)

To Show:

Score.GetInstance.Show(max as integer = 5)[/quote]

I’m pretty sure this works, but I’ll check it tomorrow.

Thank you so very much for the help, I appreciate it.

Thank you :).

[quote=167264:@Amando Blasco]I would do it like:

Score.GetInstance.Add(PlayerName, Score) This is a Singleton (a class instance we only need once per app roughly)

To Show the Score

Score.GetInstance.Show()

a Property like an array of pairs for player and score.

There is a Xojo example pattern about Singletons (quite easy/common pattern).

If Lives = 0 then
Score.GetInstance.Add(Player,Score)

To Show:

Score.GetInstance.Show(max as integer = 5)[/quote]

Sorry, I forgot to ask where to put this? Would it be in keydown window?

It depends how you design your application. I recommend to look at the examples folder of your Xojo installation. There are nice games created that you can have a look and get ideas, new concepts (specially people new to OOP)

A GameLogic class would be nice to handle all your game rules. If the ball hits a wall, you can create an Event and in that Event, add Score. Another would be if the ball hits he paddle ( increase speed, change angle, etc), GameOver, etc.

[quote=167396:@Amando Blasco]It depends how you design your application. I recommend to look at the examples folder of your Xojo installation. There are nice games created that you can have a look and get ideas, new concepts (specially people new to OOP)

A GameLogic class would be nice to handle all your game rules. If the ball hits a wall, you can create an Event and in that Event, add Score. Another would be if the ball hits he paddle ( increase speed, change angle, etc), GameOver, etc.[/quote]

Thank you, I will gladly look at the examples folder.

Thank you for being really helpful, I appreciate it.