Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Any ideas on 'cloning' cookie clicker upgrades?

Hi all again, I have been working on an exact clone of cookie clicker so people can properly play it on an iPad (the website is slow and out of proportion). Everything has been going well except now I'm stuck on how to incorporate the upgrades into the game. I've been thinking about tables but then I don't know how it will sort them by displaying the cheapest ones available at that point in time.

I would share the code but I haven't set up the images to download yet. I've included a screenshot of my current progress as I hope to post a link to it here on the forums when it's completed.

Any ideas are greatly appreciated :)

Thanks,
Jonathon

Tagged:

Comments

  • IgnatzIgnatz Mod
    Posts: 5,396

    A table is a good starting point for a list of items. It can easily be sorted any way you like.

    Please give us more detail on exactly what you want to do.

  • As you might know on the 'official' cookie clicker, you unlock upgrades when you either have a certain amount of buildings, cookie clicks, etc. The part I'm stuck on is having these upgrades appear in the top right of the screen with images. As on cookie clicker they are sorted by putting the cheapest on the left and more expensive on the right. I'm guessing I insert all of the values for each upgrade into a table separately, and then insert them into one that displays them when they have been unlocked.

    This is probably the harder part. I need to have it so that when you tap on the upgrade it knows which one you are tapping so it can display relevant info about it (and then buy it).

    Along with that I have no idea how I could save whether the upgrade has been bought (there are 150) but if I have to do that individually then I'll do that.

    I hope this has cleared up what I was trying to say.

  • IgnatzIgnatz Mod
    edited August 2015 Posts: 5,396

    You need to know how to do several things

    1. Have a master list of all upgrades which applies to all users

    2. Store a list of bought upgrades for each user (see http://codea.io/reference/Storage.html on how to store data for a user)

    3. sort a table (google "lua table sort", or if you give us the structure of your table we can help you sort it).

    What you may find most useful is to pre-sort your master list of (all) upgrades by price, and have a "bought" table field that is true if the item is bought, which starts off all false.

    Then when the user starts the game, the program reads the stored list of that user's bought items, from the iPad, and sets the bought field for those items to true in the master table.

    Then it's simple to display items at upper left, only if the bought field is true. They will be in the correct order, no need for sorting.

  • Ok, thanks so much @Ignatz! I understand what you mean but won't be able to check it out until later.

Sign In or Register to comment.