Game Leaderboard Logic
Game Leaderboard Logic
Game Leaderboard Logic
Game Leaderboard Logic
Game Leaderboard Logic
Game Leaderboard Logic Game Leaderboard Logic Game Leaderboard Logic Game Leaderboard Logic Game Leaderboard Logic Game Leaderboard Logic Game Leaderboard Logic Game Leaderboard Logic
Game Leaderboard Logic Game Leaderboard Logic
Game Leaderboard Logic
Go Back  Xtreme Visual Basic Talk > > > Game Leaderboard Logic


Reply
 
Thread Tools Display Modes
  #1  
Old 11-14-2011, 01:40 AM
JoshReed JoshReed is offline
Newcomer
 
Join Date: Nov 2011
Posts: 2
Default Game Leaderboard Logic


I'm covering a class where one student is building a game in VisualBasic. The game operates fine, but he is having issues with the Leaderboard. Together we've worked out how to compare and log high scores and then print them to screen in the correct order, but we can't seem to implement this when the new score is THE SAME as a previous score. We can't seem to figure out the code for JOINT high scores.

Has anybody got any idea's for how we can fix this please? I'm sure this is just a logic issue with how we've gone about this, but I'm out of my depth.

Thank you.
Reply With Quote
  #2  
Old 11-14-2011, 04:38 AM
TheRealTinTin's Avatar
TheRealTinTin TheRealTinTin is offline
Junior Contributor
 
Join Date: Nov 2008
Location: Glasgow, UK
Posts: 383
Default

Hi Josh and welcome to XVBT.

Perhaps a snippet of the code you have came up with might help shed some light on what the problem might be? It would also make people more willing to help - no one can help when they don't really know the problem!
__________________
Artificial Intelligence is no match for natural stupidity
Reply With Quote
  #3  
Old 11-14-2011, 08:53 AM
JoshReed JoshReed is offline
Newcomer
 
Join Date: Nov 2011
Posts: 2
Default

Thanks TheRealTinTin!

Basically we've constructed the Leaderboard Logic around a series of If loops. I'm sure there will be a smarter way of doing this, but I felt more comfortable with this approach whilst we were getting out heads around the problem. It's been a few years since I've done any programming and it's not really my field.

intstore0 = the new score from the game
The code compares the new score to see if it's greater than the previous score stored in each respective 1st, 2nd, 3rd, etc position from the Leaderboard (a series of If loops for each comparison). If the new score fits the criteria for one of the If loops then it will action the code within the loop. So it will put the newscore in the correct place and re-shuffle the previous scores (which have been kept in a "store" buffer) to their new correct position. Once this has happened the positions on the Leaderboard are backed up in the "store" ready for the next game.


Please find a snippet of code below:

If intstore0 > intstore1 Then
int1st = intstore0
int2nd = intstore1
int3rd = intstore2
int4th = intstore3
int 5th = intstore4

Lbl1st = textName.Text
Lbl2nd = onename
Lbl3rd = twoname
Lbl4th = threename
Lbl5th = fourname

Any help would be greatly appreciated- thank you.
Reply With Quote
  #4  
Old 11-14-2011, 03:31 PM
passel's Avatar
passelGame Leaderboard Logic passel is offline
Sinecure Expert

Super Moderator
* Guru *
 
Join Date: Jun 2003
Location: Upstate New York, usa
Posts: 8,026
Default

For a tie, the general rule is the second person to reach that score goes under the first person to reach that score.
So, for simplicity, you should simply start at the end of the list, not the top.
If the new score is not higher than the bottom score it won't make the list (doesn't matter if you tie the bottom high scorer).
If the new score is higher than the bottom score, you know it belongs somewhere on the list, so now you just work your way up the list i.e.
If the new score is higher than next highest, move the next highest down, and check then next.
If the new score is not higher than the next highest, then write it in the slot you are currently at.
If you reach the top of the list, and the new score is higher, then you will move the top down and write the new score there.

That logic will automatically write a new tied score beneath the previous scorer with the same value, shift the needed players down, and be done with it in one pass.

If would help if you used an array to store the scores and names, rather than uniquely named variables, that way you could handle any desired number of high scorers using the same code, in a loop, rather than several lines of code for each place.
__________________
There Is An Island Of Opportunity In The Middle of Every Difficulty.
Miss That, Though, And You're Pretty Much Doomed.

Last edited by passel; 11-15-2011 at 08:48 AM. Reason: Changed "down" to "done"
Reply With Quote
  #5  
Old 11-15-2011, 03:22 AM
TheRealTinTin's Avatar
TheRealTinTin TheRealTinTin is offline
Junior Contributor
 
Join Date: Nov 2008
Location: Glasgow, UK
Posts: 383
Default

Quote:
Originally Posted by passel View Post
If would help if you used an array to store the scores and names
As Passel suggests, an array would be your best option. This would shorten your code and make it easier to manage/amend if you wanted to change from say Top 10 to Top 100, not to mention easier to read also
__________________
Artificial Intelligence is no match for natural stupidity

Last edited by passel; 11-15-2011 at 08:49 AM. Reason: Changed "ready" to "read"
Reply With Quote
Reply

Tags
high, joint, leaderboard, score


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
Game Leaderboard Logic
Game Leaderboard Logic
Game Leaderboard Logic Game Leaderboard Logic
Game Leaderboard Logic
Game Leaderboard Logic
Game Leaderboard Logic Game Leaderboard Logic Game Leaderboard Logic Game Leaderboard Logic Game Leaderboard Logic Game Leaderboard Logic Game Leaderboard Logic
Game Leaderboard Logic
Game Leaderboard Logic
 
Game Leaderboard Logic
Game Leaderboard Logic
 
-->