Dock Sidebar
Home
Forum
Showcases
Articles / Tutorials
Code Snippets
Links
Blogs
Newsletter
Wed. Workshop
Search
FAQs
About
Member List
Dev Tools
Log in
Username
Password
Log In
Forgot your Password?
Register
Username
Email
Register
Recent Uploads
Jayenkai
02a53512-a ... e63e w mp4
Jayenkai
3476630353 ... 303815 mp4
Jayenkai
3476620792 ... 269444 mp4
Jayenkai
6747d2df-4 ... fcb7a6 mp4
Jayenkai
AI Vid - R ... way v2 mp4
Jayenkai
AI Vid - Runway
Jayenkai
AI Vid - Pollo mp4
Jayenkai
AI Vid - Kling 3 mp4
Jayenkai
AI Vid - Kling 2 mp4
Jayenkai
AI Vid - Kling 1 mp4
Undock Sidebar
QOTD - February 2025
cyangames
(Tue 01:49)
SnackVerse
Jayenkai
(Mon 13:37)
AI Video Testing
Jayenkai
(Sun 15:42)
Happy Birthday, HoboBen
steve_ancell
(Sat 17:56)
JSE Gui
Jayenkai
(Sat 07:27)
AI Waffle
cyangames
(Thu 06:59)
ST Picard
spinal
(Wed 14:19)
Suno/Bing Tunes
Jayenkai
(Wed 01:49)
Sonauto
Jayenkai
(Mon 16:33)
AGameAWeek 2025
Jayenkai
(Mon 12:55)
Civilization VR
HoboBen
(Mon 05:29)
Aseprite
9572AD
(Sun 13:09)
Conspiracy - Aliens
steve_ancell
(Sat 05:32)
2025 Prices
cyangames
(Fri 03:27)
Making Pebble Content
Jayenkai
(Fri 01:21)
Huawei Band 9
Jayenkai
(Wed 13:46)
Happy Birthday, Afr0
steve_ancell
(Mon 16:52)
Feeling Hot
therevillsgames
(Sun 23:46)
JSE - Sound Stress Test
Jayenkai
(Sun 14:47)
Back to Windows
Dan
(Sat 01:02)
QOTD - January 2025
spinal
(Fri 04:17)
Riffusion
Jayenkai
(Thu 16:55)
Bad Adverts
Jayenkai
(Wed 09:52)
DeepSeek AI
cyangames
(Tue 04:24)
Link - Handy Dev-Tool Guide
dna
(Sat 16:43)
My Threads
|
More
-=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- (c) WidthPadding Industries 1987
0|448|0
-=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=-
SoCoder
->
Snippet Home
->
Misc
MikeT
Created : 12 December 2006
System : Windows
Language : Blitz
Highscore Functions
Functions for loading,saving,sorting etc. highscores
here's the functions..
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Highscores Handling procs ;; ;; by Mike Tilley ;; ;; Sunset Kangaroo 2006 ;; ;; ;; IMPORTANT ALL SCORES ARE INTEGERS AND ALL NAMES ARE STRINGS ;; please see attached example of use ;; ;; Functions ;; ;; **************************************************************** ;; setupHighscores(file$) ;; sets up highscore file. ;; args: file$ is name of file ;; IMPORTANT please look at function and ammend the table as you need ;; ****************************************************************** ;; ;; ****************************************************************** ;; sortHighscores(player$,pscore) ;; sorts highscores into order. ;; args: player$ is player name, pscore is player score ;; ****************************************************************** ;; ;; ****************************************************************** ;; checkHighscores(pscore) ;; checks highscores to see if players score is worthy of entry ;; and returns true if it is or false if it isn't ;; args: pscore is the player score ;; used like this : ;; If checkHighscores(player_score)=True Then ;; do whatever - e.g. get players name ;; sortHighscores(player_name$,player_score) ;; End If ;; ****************************************************************** ;; ;; ****************************************************************** ;; deleteHighscores() ;; deletes all highscore types from memory ;; ****************************************************************** ;; ;; ****************************************************************** ;; saveHighscores(file$) ;; saves highscores to file. ;; args: file$ is name of file ;; ****************************************************************** ;; ;; ****************************************************************** ;; loadHighscores(file$) ;; loads highscores from file. ;; args: file$ is name of file ;; ****************************************************************** ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Const tablesize=10; 10 is size of table Change this to change size of table Type Highscore Field name$ Field score End Type ;; change number in brackets to have diffent size score table ;; must match size in setupHighscores Global hi.Highscore Dim highscores.Highscore(tablesize) ;; sets up highscore file. ;; args: file$ is name of file Function setupHighscores(file$) ;; if file doesn't exist then set up a new highscore table and file If Not FileType(file$)=1 Then fileout=WriteFile(file$) ;************************************************************** ;;put whatever scores and names you want in here ;;for larger or smaller tables add or remove pairs of lines ;; must have same number of entries as tablesize const above WriteString(fileout,"Mike1") WriteInt(fileout,10000) WriteString(fileout,"Mike2") WriteInt(fileout,8000) WriteString(fileout,"Mike3") WriteInt(fileout,7000) WriteString(fileout,"Mike4") WriteInt(fileout,6500) WriteString(fileout,"Mike5") WriteInt(fileout,6000) WriteString(fileout,"Mike6") WriteInt(fileout,5000) WriteString(fileout,"Mike7") WriteInt(fileout,3500) WriteString(fileout,"Mike8") WriteInt(fileout,3000) WriteString(fileout,"Mike9") WriteInt(fileout,2000) WriteString(fileout,"Mike10") WriteInt(fileout,1000) ;********************************************************* CloseFile(fileout) EndIf End Function ;; loads highscores from file. ;; args: file$ is name of file Function loadHighscores(file$) filein=ReadFile(file$) For a = 1 To tablesize hi.Highscore=New Highscore hi\name$=ReadString(filein) hi\score=ReadInt(filein) Next CloseFile(filein) End Function ;; saves highscores to file. ;; args: file$ is name of file Function saveHighscores(file$) fileout=OpenFile(file$) While num <tablesize For hi.Highscore=Each Highscore WriteString(fileout,hi\name$) WriteInt(fileout,hi\score) num=num+1 Next Wend CloseFile(fileout) deleteHighscores() End Function ;; sorts highscores into order. ;; args: player$ is player name, pscore is player score Function sortHighscores(player$,pscore) tempname$="" tempscore=0 For hi.Highscore=Each Highscore If pscore>=hi\score Then tempname$=hi\name$ tempscore=hi\score hi\name$=player$ hi\score=pscore player$=tempname$ pscore=tempscore End If Next End Function ;; checks highscores to see if players score is worthy of entry ;; and returns true if it is or false if it isn't ;; args: pscore is the player score ;; used like this : ;; If checkHighscores(player_score)=True Then ;; do whatever ;; sortHighscores(player_name$,player_score) ;; End If Function checkHighscores(pscore) yes=False For hi.Highscore=Each Highscore If pscore>=hi\score Then yes=True End If Next Return yes End Function ;; deletes all highscore types from memory Function deleteHighscores() Delete Each Highscore End Function
--v
and heres a quick example of their use....
Include "highscorefunctions.bb" Graphics 640,480,32,2 Const name$="Fred" ; name for testing Const score=5500 ; score for testing setupHighscores("Hightest.dat") loadHighscores("Hightest.dat") Print"set up table" Print For hi.Highscore=Each Highscore Print(hi\name$)+" "+(hi\score) Next If checkHighscores(score)=False Then Print Print("not changed") saveHighscores("Hightest.dat") End If If checkHighscores(score)=True Then Print Print("changed") sortHighscores(name$,score) saveHighscores("Hightest.dat") End If Print Print"new table" Print loadHighscores("Hightest.dat") For hi.Highscore=Each Highscore Print(hi\name$)+" "+(hi\score) Next Print Print"Press any key to exit" WaitKey()
--v
hope they help someone out. If you do end up using them in a game please give me a little credit
- ta
Comments
Copyright
Jayenkai
- 2017+ | Thanks to
Shroom_Monk
for CSS/Dev Tips | Uses a Jay-Tweaked version of
CBParser
.
Page Took : 0.101