How to save score of my game?

Anything and everything that's related to OGRE or the wider graphics field that doesn't fit into the other forums.
Post Reply
i7strelok
Gnoblar
Posts: 14
Joined: Tue Jan 24, 2017 10:31 am

How to save score of my game?

Post by i7strelok »

I calculate the score by ordering the die in my game, but how can I do to keep it (persistent). I think the easiest is a TXT file.
So I would need writeFile () and readFile () in addition to openFIle () and closeFIle () I suppose that also sizeFIle ()
Any Suggestions?
User avatar
EricB
Bronze Sponsor
Bronze Sponsor
Posts: 360
Joined: Fri Apr 09, 2010 5:28 am
Location: Florida
x 213
Contact:

Re: How to save score of my game?

Post by EricB »

Not really a question related to Ogre, but I would do it in something like XML. Specially if you're already using dotscene system (thus already have an xml lib included in your project.)

Benefits of XML over text file is organization. You could have high scores for different profiles as well as total high scores in an easily readable format.
Image
xrgo
OGRE Expert User
OGRE Expert User
Posts: 1148
Joined: Sat Jul 06, 2013 10:59 pm
Location: Chile
x 168

Re: How to save score of my game?

Post by xrgo »

I have used XML but now I use sqlite, but I store many many many things, if you only plan to store a single score or a few values a think txt is ok

edit: yes! my vote is for json, haven't use it much but seems really nice and files are very readeable
Last edited by xrgo on Wed Feb 01, 2017 1:53 pm, edited 1 time in total.
al2950
OGRE Expert User
OGRE Expert User
Posts: 1227
Joined: Thu Dec 11, 2008 7:56 pm
Location: Bristol, UK
x 157

Re: How to save score of my game?

Post by al2950 »

any form of database would be overkill I think, as for file format I dont think it matters, XML, JSON.... whatever, as long as you use a standard as there are plenty of parsers around. Dont role your own, it will quickly get annoying!
User avatar
EricB
Bronze Sponsor
Bronze Sponsor
Posts: 360
Joined: Fri Apr 09, 2010 5:28 am
Location: Florida
x 213
Contact:

Re: How to save score of my game?

Post by EricB »

xrgo wrote:I have used XML but now I use sqlite, but I store many many many things, if you only plan to store a single score or a few values a think txt is ok

edit: yes! my vote is for json, haven't use it much but seems really nice and files are very readeable
In GearCity I use SQLite, it's amazing. However the difference is, GC's save games get up into 100mb and over. I highly doubt i7strelok's highscore system is going get that large. (If it's networked, then maybe)

So I will have to lean with al2950 on this one. Formatted texted system is the way to go. As I recommended XML. JSON is another option, although personally I don't touch anything with the words "java" in it with a stick. (Yes, I know java and javascript are two different things. They both are horrible though. :D )
Image
frostbyte
Orc Shaman
Posts: 737
Joined: Fri May 31, 2013 2:28 am
x 65

Re: How to save score of my game?

Post by frostbyte »

Any Suggestions?
for such a small task this might be sufficient http://www.ogre3d.org/tikiwiki/All-purp ... ipt+parser
Dont role your own, it will quickly get annoying!
i'm actually using a xml library i wrote 10 years ago, its not that easy to write as one might assume,there are still some bugs :mrgreen: , lessoned learned- always use the most popular and most supported framework libraries, never roll your own
you want extra performance...just wait for hardware to get faster :D
the woods are lovely dark and deep
but i have promises to keep
and miles to code before i sleep
and miles to code before i sleep..

coolest videos link( two minutes paper )...
https://www.youtube.com/user/keeroyz/videos
Post Reply