07 June 2014, 20:08 | #1 |
Registered User
Join Date: Mar 2012
Location: UK
Posts: 1,893
|
Saving Highscore to Disk in Blitz Basic
Hi - my Blitz Basic Flappy Bird clone is almost complete and I would like to be able to save a highscore to disk. Have had a look through the documentation but as usual Blitz is a complete mystery.
I guess I need to open files and put values in them but really haven' a clue. Any help would be much appreciated. |
07 June 2014, 21:11 | #2 |
Moderator
Join Date: Jul 2004
Location: Norwich, Norfolk, UK
Age: 37
Posts: 11,167
|
This is how I stored my high scores in my game Downfall - full source is on the site if you wish to take a peek
I set my scores to be stored in an array (holding 20 entries) which contained the name and the score of the player. The save routine only saved it if the scores had changed since the last load when the game was quit so you might not want to do it exactly the same way but hopefully it gives you a bit of an idea. Code:
.loadhighscores If OpenFile(0,"Data/downfall.highs")=-1 ; open our file if it exists For n=0 To 19 Fields 0,highs(n)\name,highs(n)\score ; read all array data Next n EndIf Get 0,0 ; transfer data to array CloseFile 0 Return .savehighscores AMIGA If chg=1 ; If highscore file has changed dummy=OpenFile(0,"Data/downfall.highs") ; create new file, or overwrite existing one For n=0 To 19 Fields 0,highs(n)\name,highs(n)\score ; take all highscore array data Next n Put 0,0 ; write array data to our file CloseFile 0 EndIf Return |
07 June 2014, 21:28 | #3 |
Registered User
Join Date: Mar 2012
Location: UK
Posts: 1,893
|
Thanks Graham - this looks very helpful.
|
08 June 2014, 11:35 | #4 | |
Registered User
Join Date: Mar 2012
Location: UK
Posts: 1,893
|
Amazing - took your code and modified it like this and it worked first time! Simples!!!
Quote:
|
|
08 June 2014, 12:28 | #5 |
Moderator
Join Date: Jul 2004
Location: Norwich, Norfolk, UK
Age: 37
Posts: 11,167
|
Excellent - really glad you got it to work
|
08 June 2014, 13:17 | #6 |
Registered User
Join Date: Mar 2012
Location: UK
Posts: 1,893
|
We should try and get all the Blitz Coders to pool their knowledge as it does load's but documentation and examples are very scarce. You really need to persevere to get anywhere.
|
08 June 2014, 17:34 | #7 | ||
Registered User
Join Date: Nov 2010
Location: Invercargill, New Zealand
Posts: 176
|
Quote:
|
||
08 June 2014, 18:17 | #8 |
Registered User
Join Date: Mar 2012
Location: UK
Posts: 1,893
|
That's a good question? Have no idea what would happen. :-|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Blitz basic 2 Help | Havie | Coders. Blitz Basic | 30 | 08 September 2013 09:15 |
Minskies Furballs CD32 - highscore saving patch needed! | Heavy Stylus | support.Games | 1 | 20 August 2008 01:54 |
blitz basic | petza | request.Apps | 11 | 08 April 2007 01:49 |
Blitz Basic 2 anyone? | jobro | request.Apps | 12 | 28 November 2005 18:15 |
Blitz Basic 2 | LaundroMat | Retrogaming General Discussion | 5 | 24 July 2001 08:10 |
|
|