Local Leader Boards

Getting into LiveCode for iOS? Ask your questions here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
Danny
Posts: 106
Joined: Tue Nov 09, 2010 1:28 am

Local Leader Boards

Post by Danny » Tue Jan 04, 2011 5:33 am

Is there good code to make a local leader board where you don't need a server?
Oh and side question how do you make items in a graphic field randomize their location in the field? I have been tinkering around with some of my own code but it doesn't spread out enough; it just makes a pretty flat back slash.

Thanks,

Danny

splash21
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 369
Joined: Sun Dec 19, 2010 1:10 am
Contact:

Re: Local Leader Boards

Post by splash21 » Wed Jan 05, 2011 10:46 am

Hi, Danny. A new version of 'Snowballer' just went live this morning in the app store (an LC iOS game) - the main additions were local and online leader boards. I just read and write the leader board info to a text file and display it in a field.

The game's data file can contain multiple entries - one per line - and one of the entries is the high score information. To make sure that a large multi line text entry becomes one line in the data file, I use the following code;

Code: Select all

put base64Encode(tHiScores) into tSaveHiScores
replace LF with empty in tSaveHiScores
... and base64Decode it when you read it back from the text file.

JC
LiveCode Development & Training : http://splash21.com

Danny
Posts: 106
Joined: Tue Nov 09, 2010 1:28 am

Re: Local Leader Boards

Post by Danny » Fri Jan 14, 2011 5:39 am

Hey Splash sorry for the later reply. I've been trying out the leaderboard code, it's been a big help, thanks!
I have been trying to make a graphic appear, like a "game over," when these balls are finished up falling into the bucket. (Please reference some of my past post for a better explanation of my game idea).

I was playing around with some code

Code: Select all

on timerPlay
      if "fBallsDropped" > 9 then
        answer "hi"
            end if
end timerPlay
"fBallsDropped" is a field that changes depending on how many balls are dropping and right now the max is 10, also i'm just using the answer function to show that something is happening. My problem is that if I make it greater than (>) then it says "hi" every time no matter how high I make the number in the code. If I make it less than (<) then it won't say "Hi" no no matter how I change the code.

If you or any one else reading this could help it would be great.

Thanks,

Danny

splash21
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 369
Joined: Sun Dec 19, 2010 1:10 am
Contact:

Re: Local Leader Boards

Post by splash21 » Fri Jan 14, 2011 11:06 am

Hi, Danny. You just need to drop the word 'field' in to specify the object's value you're comparing - at the moment you're comparing the string "fBallsDropped" with the number 9;

Code: Select all

on timerPlay
      if field "fBallsDropped" > 9 then
        answer "hi"
      end if
end timerPlay
HTH :D
LiveCode Development & Training : http://splash21.com

Danny
Posts: 106
Joined: Tue Nov 09, 2010 1:28 am

Re: Local Leader Boards

Post by Danny » Fri Jan 21, 2011 4:30 am

Once again THANK YOU. I was thinking like algebra, so if one field in greater than or less than, then an event would happen.

I saw in your game "snowballer" (Congrats on getting an app to the App Store!) that you have constraint on how far back you can pull the snowball in the box. Would you be able to tell me how to do that with a field? Like keeping a bucket in a graphic field. I was testing the code that you had posted somewhere in the forums but I couldn't quite figure it out.

Any ideas?

Thanks,

Danny

splash21
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 369
Joined: Sun Dec 19, 2010 1:10 am
Contact:

Re: Local Leader Boards

Post by splash21 » Wed Jan 26, 2011 6:49 pm

Hi, Danny. From the 'Snowman Example' stack on rev online : check out the touchMove handler that gets called when a finger moves on the screen.
It receives the id of the touch event and x and y co-ordinates (pX and pY)

All I'm doing is checking pX and pY against the edges of the 'pull area' graphic (the dark rectangle - which is hidden in the final app) and resetting them if they fall outside.
This ensures that the point pX,pY lies inside the allowed area.

Code: Select all

# constrain pulling to the dark 'pullArea' rectangle on screen
if pX < the left of grc "pullArea" then put the left of grc "pullArea" into pX
if pX > the right of grc "pullArea" then put the right of grc "pullArea" into pX
if pY < the top of grc "pullArea" then put the top of grc "pullArea" into pY
if pY > the bottom of grc "pullArea" then put the bottom of grc "pullArea" into pY
LiveCode Development & Training : http://splash21.com

Danny
Posts: 106
Joined: Tue Nov 09, 2010 1:28 am

Re: Local Leader Boards

Post by Danny » Fri Feb 04, 2011 1:39 am

Hey Splash, I Got it to work. :D This might be an easy question. When the round is over the bucket moves off the screen and then I hit the "retry" button quickly to bring it back; the bucket quickly flashes on the screen and then goes away and the balls proceed to fall without a bucket on the screen. If I wait a second or two it usually appears but I can't assume that a player is going to wait that long to hit the retry button. I'm almost 99.9% positive that I wrote the right code but it just doesn't seem to work.

Code: Select all

 set the layer of img "bucket" to bottom 
just to get it out of the way.

Code: Select all

on moveBucket
   set the layer of img "Bucket" to top
end moveBucket
to bring it back to the front of the screen. I have that code on the "retry" button and the "start" button as back ups

Do you know why that would be happening?

Thanks,

Danny

BvG
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1239
Joined: Sat Apr 08, 2006 1:10 pm
Contact:

Re: Local Leader Boards

Post by BvG » Fri Feb 04, 2011 1:03 pm

Something else must be moving or hiding your bucket image.

Maybe your normal code just continues, and sets the location or layer of the bucket, as if the game would still be running?

Or some other code hides the bucket graphic by setting it's visibility?
Various teststacks and stuff:
http://bjoernke.com

Chat with other RunRev developers:
chat.freenode.net:6666 #livecode

Danny
Posts: 106
Joined: Tue Nov 09, 2010 1:28 am

Re: Local Leader Boards

Post by Danny » Sat Feb 05, 2011 1:10 am

Sweet! I think I had a couple of buttons moving the bucket around and after I deleted the code it started showing up and staying there.

Thanks,

Danny

cruddydan
Posts: 15
Joined: Tue Jan 18, 2011 10:57 pm

Re: Local Leader Boards

Post by cruddydan » Tue Feb 15, 2011 12:16 am

splash21 wrote:...A new version of 'Snowballer' just went live this morning in the app store (an LC iOS game) - the main additions were local and online leader boards. I just read and write the leader board info to a text file and display it in a field.

The game's data file can contain multiple entries - one per line - and one of the entries is the high score information. To make sure that a large multi line text entry becomes one line in the data file, I use the following code;

Code: Select all

put base64Encode(tHiScores) into tSaveHiScores
replace LF with empty in tSaveHiScores
... and base64Decode it when you read it back from the text file.

JC
Hi Splash,

Can you explain in more detail how one sets up an online leader board?

Thanks,

Dan

dburdan
Posts: 104
Joined: Fri Jan 28, 2011 5:39 am

Re: Local Leader Boards

Post by dburdan » Tue Feb 15, 2011 1:01 am


Hi Splash,

Can you explain in more detail how one sets up an online leader board?

Thanks,

Dan
I would also like to know how to set one up.

cruddydan
Posts: 15
Joined: Tue Jan 18, 2011 10:57 pm

Re: Online Leader Boards

Post by cruddydan » Tue Feb 15, 2011 5:56 pm

After some further investigation yesterday, I discovered that Apple provides a "Game Center" which provides (among other things) a centralized leader board service. There is a "Game Kit API" that developers can use to read/write to the "Game Center". I assume the Game Kit is a set of DLLs that the developer must use. I am not an advanced LiveCode developer, so I don't know how to "interop" with external DLLs.

I was hoping someone had already done this and would be willing to share...

witeowl
Posts: 45
Joined: Mon Feb 21, 2011 3:02 am

Re: Local Leader Boards

Post by witeowl » Sun Feb 27, 2011 1:39 am

dburdan wrote:
Can you explain in more detail how one sets up an online leader board?
I would also like to know how to set one up.
I hate to say, "Me, too!" but...

Me, too!

:wink:

dburdan
Posts: 104
Joined: Fri Jan 28, 2011 5:39 am

Re: Online Leader Boards

Post by dburdan » Mon Feb 28, 2011 6:17 pm

cruddydan wrote:After some further investigation yesterday, I discovered that Apple provides a "Game Center" which provides (among other things) a centralized leader board service. There is a "Game Kit API" that developers can use to read/write to the "Game Center". I assume the Game Kit is a set of DLLs that the developer must use. I am not an advanced LiveCode developer, so I don't know how to "interop" with external DLLs.

I was hoping someone had already done this and would be willing to share...
The GameKit Api is only for people developing with xcode. The LiveCode developers would need to add support for game center in order for us to use it. I have code for an online leaderboard that I use. I will post it when I'm done with my app.

cruddydan
Posts: 15
Joined: Tue Jan 18, 2011 10:57 pm

Re: Local Leader Boards

Post by cruddydan » Mon Mar 07, 2011 11:53 pm

That would be much appreciated... Thanks.

Dan

Post Reply