HOW DO YOU SAVE HIGH SCORES!

Creating Games? Developing something for fun?

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
nicholas.aycockGA5787
Posts: 11
Joined: Mon Jan 16, 2012 10:40 am

HOW DO YOU SAVE HIGH SCORES!

Post by nicholas.aycockGA5787 » Mon Jan 30, 2012 5:07 am

In the making of the game galactic gauntlet the academy shows you basically everything except how to save the high scores. So my question is HOW DO YOU DO IT?
thanks in advance for any help.

spencer
Posts: 71
Joined: Mon May 09, 2011 3:01 pm

Re: HOW DO YOU SAVE HIGH SCORES!

Post by spencer » Tue Jan 31, 2012 3:50 am

There is a great tutorial LiveCode Lessons | How To - Step-By-Step Guides To Tasks In LiveCode | How do I save custom properties in a standalone application?


http://lessons.runrev.com/s/lessons/m/4 ... pplication



on saveHighestScore
## where are we?
if the cSkin of card "gamecard" is "spaceskin" then
put "balloonskin" into tCard
else
put "spaceskin" into tCard
end if

## Is the current score the highest?
put fld "scorefield" into tCurScore
put the cMaxScore of card tCard into tMaxScore

if tCurScore > tMaxScore then
## play some flourish sound
answer "Your"&& tCurScore && "is the highest score!"
##save the new highest (maximum) score as a property of the skin we are in
set the cHighScore of card tCard to tCurScore
end if

end saveHighestScore

spencer
Posts: 71
Joined: Mon May 09, 2011 3:01 pm

Re: HOW DO YOU SAVE HIGH SCORES!

Post by spencer » Wed Feb 01, 2012 7:29 pm

So now I'm doing the lesson, following the directions, and getting an error message that it can't find the stack I've created after saving it as a standalone. I created the launcher, the main application, put this handler in the stack script of the launcher:

on openStack   
open stack "Main Application.livecode"
close stack "Launcher"
end openStack

The error message is:

stack "Untitled 1": execution error at line 5 (Chunk: can't find stack), char 4

Line 5 is blank. The last line is line 4.

It must be the path problem. Anyone done it?

robantonelli29GAgYtd
Posts: 90
Joined: Thu Dec 08, 2011 12:21 pm

Re: HOW DO YOU SAVE HIGH SCORES!

Post by robantonelli29GAgYtd » Thu Feb 02, 2012 6:34 am

hey all,

just wanted to throw in my 2 cents here because the topic interested me and I was looking to do the same thing. I tried Spencer's code and it did not work at first. Thank you for putting it up Spencer because had you not i wouldn't have been able to do the following. This code works. It not only sets the high score but will not deliver the message until the high score is beaten. My suggestion is, before you run the script to make sure it works, go into your gamecard (whatever it's called) and right-click (on the card itself) > card and stack > card property inspector. From the drop down menu click "Custom Properties". Click the "+" symbol to add a custom property called "cHighScore" (without quotes). Once it's added click in the window underneath labelled "property contents" and type "0" in just the first line (wouldn't recommend pressing "enter" as this adds another line to the contents of the property). Once that's done, save all work and run the script. Should work properly. I've include where you activate the handler as well as the handler itself below:

Code: Select all

on stopGame
   put false into sMoving
   set the layer of group "gameoverscreen" to top
   show group "gameoverscreen"
   saveHighScore
end stopGame

on saveHighScore

   put "gamecard" into tCard
   
   if the cHighScore of card tCard = 0 then
      put field "scorefield" into tHighScore
      set the cHighScore of card tCard to tHighScore
      answer "You got the highest score: " & tHighScore
   end if
   
   if the cHighScore of card tCard > 0 then
      put field "scorefield" into tCurrentScore
      if tCurrentScore > the cHighScore of card tCard then
         answer "You got the highest score: " & tCurrentScore
         set the cHighScore of card tCard to tCurrentScore
      end if
   end if
   
end saveHighScore
Hope this helps anyone who was looking to do this in a basic form. It took me 2 hours of tweaking the code to finally, and I mean FINALLY get the code to function properly. I hope others benefit from this, however much. Feedback welcome :-)

I would like to clarify that I am not currently using any skins in my game, therefore the cSkin section mentioned above did not apply to me. However, if you ARE using skins you would need to include what Spencer wrote above:

Code: Select all

if the cSkin of card "gamecard" is "spaceskin" then
   put "balloonskin" into tCard
else
   put "spaceskin" into tCard
end if
therefore, in total, if you have skins it would look like this:

Code: Select all

on saveHighScore

   if the cSkin of card "gamecard" is "spaceskin" then
      put "balloonskin" into tCard
   else
      put "spaceskin" into tCard
   end if   
   
   if the cHighScore of card tCard = 0 then
      put field "scorefield" into tHighScore
      set the cHighScore of card tCard to tHighScore
      answer "You got the highest score: " & tHighScore
   end if
   
   if the cHighScore of card tCard > 0 then
      put field "scorefield" into tCurrentScore
      if tCurrentScore > the cHighScore of card tCard then
         answer "You got the highest score: " & tCurrentScore
         set the cHighScore of card tCard to tCurrentScore
      end if
   end if
   
end saveHighScore
I am going to try and figure out how to code something that displays the top high scores, when I do i'll post it here :-D

ahmedinvent24BUSGdU9
Posts: 43
Joined: Mon Oct 15, 2012 6:44 pm

Re: HOW DO YOU SAVE HIGH SCORES!

Post by ahmedinvent24BUSGdU9 » Fri Dec 21, 2012 2:28 pm

this my sample for a puzzle game when i test it on android physical device the check sign hide on open card
please help me to fix that problem .

please download the file and fix the problem

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

How do you save high scores?

Post by Mark » Fri Dec 21, 2012 5:56 pm

Please, guys. Keep this forum neat and tidy. Don't use all caps in the title of your subject.

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

Post Reply

Return to “Games”