Christmas gist : KraizyCircles

Hello i’ve made this little game for Christmas, that i call KraizyCircles
http://www.youtube.com/watch?v=FbVBL8YiS7k
It is the rework of Dave1707 ‘cicles of confusion’ that i tried to make more ‘spicy’. At least it works for my kids. There is a big battle for making the highest score possible. Enjoy!
https://gist.github.com/4375513
[edit] i’ve updated the gist so the unfinished paths have a blinking end.
[edit] v4 posted: 27 levels.
[edit] v5 : corrected for the save score problem.
[edit] v6 : corrected again for save score. Now it work.

Gist updated: new levels from 7 to 12: numbers of circles limited, and i started introducing ‘special regions’ that interract with the balls during run phase. Also: the touch interface is slightly modified to improve the user experience. Read the instructions again.

@Jmv38 Looks like a fun game, a lot more colorful than my original. Good to see it’s not going to waste. I tried running your game, but the next and prev buttons aren’t showing up. So far I’m only able to connect the 2 dots at level 1. I looked thru the code and see 7 buttons defined, but only 5 are showing on the screen. I dont know if the other 2 show up later, or should show all the time.

Hi @dave1707. The next should show up. It must be a problem of initialization: i check if the saved score is higher than 0, and if yes i show the next button. Does the top line say ’ level 1 - best score x by ?’ with x >0? If not it can be.
1- you hve not really linked the 2 targets.Or not pressed ‘run’.
2- there is a problem with globalstorage on your device.
3- i have a problem of ‘firat time usage’ that does not show up on my ipad because the score has already been saved.
4- i am on beta 1.5(8). I thought i had not used any new function, but maybe i used one?
I correct that and i ll be back. Thanks for the feedback.
[edit] i checked removing the max score of level 1 from the storage: then the ‘next’ button does not show up, as for you. Then i link the 2 dots. then the ‘run’ button turns green. Then i press ‘run’. Then the ball rides the path. Then the ‘next’ button appear in green. Do all this steps happen for you?
Anyone having the same problem? If yes i will post a verion with ‘next’ always enabled.

@Jmv38 I loaded a new version of your code so I can start fresh. Here are my steps. Level1 max score by ?. Keyed in qwerty for a name. Player, run, swap are purple. 200 and draw are green. I touch the left circle and a line is drawn from the right circle to the left one. Draw turns purple, run turns green. I tap run and the ball is drawn from the righ circle to the left circle. Run turns purple and 100 is on a green button. All the other buttons are purple and next or prev don’t show. The score is max 0 by qwerty. When I get time, I’ll look thru your code and see what’s happening unless you find it first.

Thank you dave that detailed description is very useful. The highest score should have been saved and re-read so 100 and your name should be on the top, this unlocks next level. They don’t so it means the storage did not work. I am using GlobalStorage i have to check it it existed in previous version. I didn’t use localstorage because it is broken in my codea version. I will soon put online a new version with 30 levels and AllLevelsUnlocked = true so you can test the whole game. Just pretend you can’t go to next step if it is not completed :wink: .

Hello @Dave1707. You can download the code again:

  • check the instructions i have modified again the touch interface.
  • i check for localstorage and globalstorage: if one of them is ok, it should work.
  • in case the levels still dont update, then there is a contant ALL_LEVELS_ENABLED, which is at true for the moment, you can comment this line and see if it stll works.

@Jmv38 I downloaded your new code and I can play the different levels, but the max score isn’t updating. To fix it, change line 296 from “if txt == tostring(i) then self.maxScore = i end” to “if txt == i then self.maxScore = i end” . Remove the tostring. Also, should line 266 be “self.score = 100” or should it be 0. I noticed that the name in the max score line isn’t there on some levels.

This is strange… It works on my codea version with the tostring(). It could be linled to the version. I’ll wait for the 1.5 release to see what is the status. @Simeon do you understand this?
@Dave if you can play now, is the score saved between game restart? The main interest of the game is to try beating the best score, so…

@Jmv38 the level 1 max score always comes up as 100 by ?. The other levels show max score by “qwerty” (the name I used) with a correct value. Look at the 3 print statements I added to the function readMaxScore below. “Local” prints that txt is a number. I think that “global” will also print that txt is a number. But “other” will probably print that txt is a string because of tostring. Maybe that’s why the if statement with the tostring works for you. Add the print statements and see what you get. Comment out DisplayMode at the beginning.


function OneLevel:readMaxScore()
    local txt 
    if LOCAL_STORAGE then
        txt = readLocalData(self.maxScoreKey)
        print("local ",type(txt))
        self.winner = readLocalData(self.winnerKey) or "?"
    elseif GLOBAL_STORAGE then
        txt = readGlobalData(self.maxScoreKey)
        print("global ",type(txt))
        self.winner = readGlobalData(self.winnerKey) or "?"
    else
        txt = tostring(SCORE)
        print("other ",type(txt))
        self.winner = playerName
    end
    self.maxScore = 0
    for i =0,100 do 
        if txt == tostring(i) then self.maxScore = i end
    end
    nextButton.enabled = ((self.maxScore > 0) and (self.lev<NMAX)) or ALL_LEVELS_ENABLED
end

Thanks @Dave1707. On my version

  • ‘local’ doesnt work so it prints nothing.
  • ‘global’ prints ‘string’.
    So we can see there is a change between your and my version.
    I think your version works correctly now. The max score being 100, for level the winner will always be ‘?’ because it changes only if you beat the score => its ok.
    I think i’ll rewrote the read and save to works with both version, and also correct the winner name. Thanks!

The v5 is online: i’ve corrected for the save score problem by forcing the conversion to string, so it should work the same whatever the version. Oh, and i’am going to disable the all enabled too.

@Jmv38 I’m actually having the same problem that was mentioned earlier with the next button not showing up. The series of steps that I’m following is the same as described by @dave1707. I’ve downloaded the most recent version of the code from github.

Ok . Uncomment line 21 in the main : all levels will be enabled.
I’ve corrected the gst so that all levels are enabled now.

I think i know why it didnt work in v05. I’ve corrected and updated to v06. I cannot verify because the problem don’t show up on my ipad. Try it. If is still doesn’t work, you can stlii un comment line 20 in the main to allow all levels.

@Jmv38 the changes you’ve made for v06 have made the difference. Now the score is updated on the main instruction page and the ‘Next’ button activates appropriately on the subsequent challenges. Great work!

Those who are interested in this game can download the last version from:
http://jmv38.comze.com/CODEA/server.php
I have added a few interesting new things in it. There are now 30 levels. The last level has the ‘‘black hole’’ obstacle still to be debugged. I’d like to add ‘‘best score management’’ via the web, and ‘‘best result save and upload’’. Maybe some day…

V1-4 update: very small change: i had forgotten to update the first page with new command instructions. It is done in this version.
http://jmv38.comze.com/CODEA/server.php
If you have problems put a comment here, i have not recently checked if everything is ok.