BBC BASIC for Windows
Programming >> Graphics and Games >> High Score Table
http://bb4w.conforums.com/index.cgi?board=graphics&action=display&num=1352572127

High Score Table
Post by Usama Amin on Nov 10th, 2012, 5:28pm

Hi Richard is it possible to store a variable which doesn't erase when BBC basic is closed e.g. for a high score leader board and can a high score table be created in BBC basic? smiley
Re: High Score Table
Post by admin on Nov 10th, 2012, 10:07pm

on Nov 10th, 2012, 5:28pm, Usama Amin wrote:
Hi Richard is it possible to store a variable which doesn't erase when BBC basic is closed?

The usual method would be to store the value either in the Windows Registry or in an INI file (or indeed in any kind of data file). For the use of INI files see this Wiki article:

http://bb4w.wikispaces.com/Reading+and+writing+.INI+data+files

Of course a disadvantage of storing a High Score Table as 'plain text' in the Registry or an INI file is that it would be easy for somebody to edit it to give themselves a very high score! Therefore in that case you may want to encrypt the data before storing it.

Richard.
Re: High Score Table
Post by Usama Amin on Nov 11th, 2012, 09:37am

Ok thanks how would one go about encrypting an .ini file?
Re: High Score Table
Post by admin on Nov 11th, 2012, 9:33pm

on Nov 11th, 2012, 09:37am, Usama Amin wrote:
Ok thanks how would one go about encrypting an .ini file?

You could use any kind of encryption that you consider to be adequately secure, I have no specific suggestions. You could try asking other games writers what they have used (but for obvious reasons they might not want to reveal too much detail!).

If the encryption produces an output that still looks like 'text' you can store it in the INI file like any regular string. If the encryption creates 'binary' data you can store it in the INI file using WritePrivateProfileStruct.

Richard.
Re: High Score Table
Post by Usama Amin on Nov 12th, 2012, 7:27pm

Thanks I just multiplied it by a really large number when writing to the ini file and divided by the same number when reading worked well enough grin
Thanks for the help Richard smiley
Re: High Score Table
Post by admin on Nov 13th, 2012, 08:04am

on Nov 12th, 2012, 7:27pm, Usama Amin wrote:
I just multiplied it by a really large number when writing to the ini file and divided by the same number when reading worked well enough

Works well enough until somebody playing your game reads this forum..... grin

Richard.
Re: High Score Table
Post by Usama Amin on Nov 13th, 2012, 08:34am

Haha grin