CodeWalrus

Development => Calculators => Calc Projects, Programming & Tutorials => Topic started by: semiprocoder on November 29, 2015, 09:23:42 PM

Title: Cookie Clicker for the Nspire!
Post by: semiprocoder on November 29, 2015, 09:23:42 PM
COOOOKIIEEEESSSS!!!!!!!!!!!


Yesterday I started working on cookie clicker for the nspire, and here is the first version of cookie clicker for the nspire. Right now it has 9 producers of cookies, including a walrus. It also supports upgrades for each tower and clicking(although I need to balance it a bit still).

Currently the help and settings menu don't do anything, and only game does anything. I may end up removing the settings menu, as I do not see any real use for it.

Controls: use arrow keys to scroll through menu and press enter to go into one of the parts. In the game click on the cookie or the producers to get buy or get extra cookies. Use left and right keys to scroll between the different producers of cookies.
Press 'u' to upgrade producers/mouse. Again click on what you want to upgrade and use arrow keys to scroll.

The images are taken from the actually cookie clicker images, and the background is just a random cool background I found online that I included in my files just to show that my code supports backgrounds. I hope to replace it with something else soon.

Edit:
First off, what do you think about me adding a potato(http://www.lulu.com/shop/rinardo/the-holy-scripture-of-rinardo/ebook/product-22008800.html). I am planning it to be right under walrus or even above it. Also I need to make everything more expensive, as it takes me about 30 mins to get even the walrus.

Here is the list of glitches I know about:

1. Font size:
Despite me setting the font size to 7, which is one of the values the ti nspire supposedly support, the font size stays default. This is really annoying because stuff has to be scrunched too far together and it often goes off screen.

2. Vars not saving properly:
This is probably my bad coding, but anyways, sometimes when you upgrade clicking it resets you clicking power to 0 and the cost to 3. I think I fixed this but I am not sure. Once I come up with larger changes I will update the downloads.
This is probably the most annoying glitch. This only has to do with the var "statsCookieSPC"(money, money per click, and upgrade cost for the money per click. It also only happens if you buy something ie. save something in the var "statsProducerSPC", which stores everything else

3. When you open the game again without closing it fully(like when you open another file), the game doesn't work at all. You have to open something else to make the game work again. Also think I have fixed this.
Title: Re: Cookie Clicker for the Nspire!
Post by: Dream of Omnimaga on November 29, 2015, 11:31:20 PM
This looks good. I saw an earlier screenshot on IRC and was gonna suggest adding that blue background from the PRIZM version to spice things up. I'm glad that it was already added. Also nice to see :walrii: in the game (you should probably call it Walrii, though :P)
Title: Re: Cookie Clicker for the Nspire!
Post by: semiprocoder on November 30, 2015, 01:10:06 AM
Can anyone who knows lua help me with a small(ish) issue?

I have an issue with saving the producer's stats right now. Here is my code(I have print statements there because I was checking what didnt work):

function game.cookieProducer:storeVars()
var.storeAt("statsProducersSPC", self.cost, self.id*4-3)--also needs to be improved
if var.recallAt("statsProducersSPC", self.id*4-3)==nil then
print("cost not working")
end
var.storeAt("statsProducersSPC", self.output, self.id*4-2)
if var.recallAt("statsProducersSPC", self.id*4-2)==nil then
print("output not working")
if self.output==nil then
print("wut")
end
end
var.storeAt("statsProducersSPC", self.amt, self.id*4-1)
if var.recallAt("statsProducersSPC", self.id*4-1)==nil then
print("amt not working")
end
var.storeAt("statsProducersSPC", self.upgradeCost, self.id*4)
end


The issue is that all the print statements are printing(showing that the vars aren't being saved), and my recall vars statement never set my variables because they are all nil.
Title: Re: Cookie Clicker for the Nspire!
Post by: Snektron on November 30, 2015, 02:12:12 PM
Looks pretty good :) what doe the :3= do?
Title: Re: Cookie Clicker for the Nspire!
Post by: Dream of Omnimaga on November 30, 2015, 08:24:36 PM
I think it's just there as the last item/thing, except instead of the usual Cookie Clicker final item, it's a walrus.
Title: Re: Cookie Clicker for the Nspire!
Post by: LD Studios on November 30, 2015, 09:01:07 PM
Quote from: semiprocoder on November 29, 2015, 09:23:42 PM
the first version of cookie clicker for the nspire
lies :P (https://www.omnimaga.org/ti-nspire-projects/cookie-clicker/msg373591/#msg373591)
Yours looks better though :P

Might I suggest adding some more spaces though before text? Like, add a bit of  margin between the left side of the screen and the Money, Output labels, and the same thing for your stats next to the different things you can buy.
Title: Re: Cookie Clicker for the Nspire!
Post by: Dream of Omnimaga on November 30, 2015, 09:05:53 PM
I seem to recall at least another with a white background, but I forgot who made it. I know that JWinslow23 made two versions, but neither were for the Nspire. Spenceboy98 made a PRIZM version and Kerm a CSE version.
Title: Re: Cookie Clicker for the Nspire!
Post by: LD Studios on November 30, 2015, 09:08:36 PM
Quote from: DJ Omnimaga on November 30, 2015, 09:05:53 PM
I seem to recall at least another with a white background, but I forgot who made it. I know that JWinslow23 made two versions, but neither were for the Nspire. Spenceboy98 made a PRIZM version and Kerm a CSE version.
That was probably me with the white background, but then I updated it- Not a very good update though because I added falling cookies in the background which create a lot of lag when you get to higher scores :P
Title: Re: Cookie Clicker for the Nspire!
Post by: Dream of Omnimaga on November 30, 2015, 09:12:49 PM
Oh right, I didn't realize that the cookies were animated. Is the lag still present on OS 3.6 or was it only on 3.1 and lower?

Also, I wonder if some PICO-8 games would be feasible in Nspire Lua (eg that racing game I posted in the PICO-8 thread)
Title: Re: Cookie Clicker for the Nspire!
Post by: LD Studios on November 30, 2015, 09:18:25 PM
Quote from: DJ Omnimaga on November 30, 2015, 09:12:49 PM
Oh right, I didn't realize that the cookies were animated. Is the lag still present on OS 3.6 or was it only on 3.1 and lower?

Also, I wonder if some PICO-8 games would be feasible in Nspire Lua (eg that racing game I posted in the PICO-8 thread)
No, the lag would be present on any OS considering how it outputs one cookie for every cookie created (so when you're outputting thousands per second...)- I could have sworn I blocked it from displaying more than about 30 at a time, but I just tested it and apparently not. *oh well*

There are a fair amount of commands in PICO-8 that don't exist in Nspire Lua such as the setPixel and getPixel (or whatever they're called), as well as tall the built in tilemapping stuff.

EDIT: ***This thread should probably get back on topic though*** :P
Title: Re: Cookie Clicker for the Nspire!
Post by: Dream of Omnimaga on November 30, 2015, 09:56:35 PM
Yeah the PICO-8 remark is because you seems a bit hard to reach on WalrusIRC sometimes :P. Maybe I should start a new topic about if some PICO 8 games could be feasible in Nspire Lua, though. And yeah I believe that blocking cookies at 30 would be better, or you could only animate 30 a second and loop through a longer list but then the cookies would fall slower  still.
Title: Re: Cookie Clicker for the Nspire!
Post by: semiprocoder on November 30, 2015, 11:20:35 PM
Quote from: LD Studios on November 30, 2015, 09:01:07 PM
Quote from: semiprocoder on November 29, 2015, 09:23:42 PM
the first version of cookie clicker for the nspire
lies :P (https://www.omnimaga.org/ti-nspire-projects/cookie-clicker/msg373591/#msg373591)
Yours looks better though :P

Might I suggest adding some more spaces though before text? Like, add a bit of  margin between the left side of the screen and the Money, Output labels, and the same thing for your stats next to the different things you can buy.

Well ldstudios I must apologize then. I only checked on ticalc as I don't participate on omninaga(only really joined calc community in september), and I don't check ti planet cause most of that is french. I'll change that I guess.

Anyways, ldstudios do you know vars well? Because right now I am having great difficulty in saving my money. It may somehow be a glitch of my code, idk, but I don't think so. I printed the values of self.money every timer tick, and they were all good. However, when I closed the game back again and restored the money it is a random value. I am not exactly sure why this happens, but I know it only happens if I buy something first, which saves those values in a different var. I have been trying to figure it out for like an hour, but I have no idea where the issue actually lies.

I will update my lua code for the more updated version and don't pay attention to my old question I fixed that but then this issue arose.

I fixed it after another hour of putting print statements everywhere. I finally figured out that I wasn't setting prevTime to anything when I open my game. Thus the difference between prevTime and millis() the first run of timer was huge and it added a huge amount of money to the game.
Title: Re: Cookie Clicker for the Nspire!
Post by: LD Studios on December 01, 2015, 01:26:38 AM
Just a few spots of advice
1) You should make your documents 3.1 compatible ;)
2) I usually use on.save and on.restore rather than saving math variables. I find it to be a little neater in the code, and it also prevents people from cheating by altering the variables from a calculator page, not to mention math variables will take up more space in your document! See here (https://inspired-lua.org/index.php/2011/08/save-a-high-score-without-cheating-possibility/) for more info on that.

EDIT:
Quote from: semiprocoder on November 29, 2015, 09:23:42 PM
3. When you open the game again without closing it fully(like when you open another file), the game doesn't work at all. You have to open something else to make the game work again.
There is some sort of bug where the timer glitches out upon minimizing lua documents. I recommend pausing the timer on on.deactivate() and resuming it with on.activate()
Title: Re: Cookie Clicker for the Nspire!
Post by: semiprocoder on December 01, 2015, 01:29:35 AM
Quote from: LD Studios on December 01, 2015, 01:26:38 AM
Just a few spots of advice
1) You should make your documents 3.1 compatible ;)
2) I usually use on.save and on.restore rather than saving math variables. I find it to be a little neater in the code, and it also prevents people from cheating by altering the variables from a calculator page, not to mention math variables will take up more space in your document! See here (https://inspired-lua.org/index.php/2011/08/save-a-high-score-without-cheating-possibility/) for more info on that.

1) no idea how to use string images still(and I think I had one other function that isn't compatible, but I am not sure)
2) I made my code badly and it would take a while to change it to work with on.save and on.restore, so I may do that, but not right now.
Title: Re: Cookie Clicker for the Nspire!
Post by: Dream of Omnimaga on December 01, 2015, 01:31:49 AM
I agree about 3.1. Some Ndless users still use 3.1 for larger memory and also the annoyances of 3.6 (perhaps they don't want to deal with nLaunchy). But I am ok if the game works on at least OS 3.6. Just don't make it 3.9-only.
Title: Re: Cookie Clicker for the Nspire!
Post by: semiprocoder on December 01, 2015, 01:37:49 AM
DJ I am not 100% sure that my game works with 3.6. Could you check if it does?
Title: Re: Cookie Clicker for the Nspire!
Post by: semiprocoder on December 03, 2015, 01:57:14 AM
Update!
Almost all of the glitches are fixed(excluding the timer and a few minor bugs I may not know of, despite putting timer.stop() in on.deactivate()).

First off, I balanced the producers better by making everything more expensive(although I may have made it too expensive).

I added many items, most of them troll items, to the game. I guess whichever ones you think I should keep I will keep. These include:
prism,
potato(look at first post for reason),
ti nspire calc,
ti 84,
super cookie,
and finally pfudor(pink fluffy unicorns dancing on rainbows)

Attached is an animated screeenshot of the game.
Title: Re: Cookie Clicker for the Nspire!
Post by: Dream of Omnimaga on December 03, 2015, 08:13:35 PM
Lol nice update. But does it still include the walrus? :P

Also make sure that late items aren't worthless, as in rewarding less than earlier items. I noticed that happening with one Cookie Clicker game in the past, where the factory was worth more than the next two items by far. That's unless of course an item is intended to be trollish and to make you waste money, though.

I'm not too sure about the political item, though, because it might be better in such case to include all major politicians :P
Title: Re: Cookie Clicker for the Nspire!
Post by: semiprocoder on December 03, 2015, 09:10:17 PM
Well, I'm not actually doing that. That was temporary, and I removed him from the game. Seeing as he is the richest of any candidate though, I think he was the best option to include for one day. He makes the most money, and that translates to more cookies.

Also right now all my items still follow cost order, but each subsequent item decreases performance/cost a little bit. And of course there is pfudor, which is almost impossible to get, but if you somehow do get it it still has about the same performance/cost as the previous producer.
Title: Re: Cookie Clicker for the Nspire!
Post by: Dream of Omnimaga on December 03, 2015, 10:21:24 PM
Ah ok good to hear. I think it was @JWinslow23 CSE game that had misordered cost ratios. I ended up using factories during most of the game as a result. But again I'm not one to talk with Illusiat series :P
Title: Re: Cookie Clicker for the Nspire!
Post by: JWinslow23 on December 04, 2015, 02:00:08 PM
Misordered cost ratios? I'd like an explanation.

/me checks code

Nm, couldn't have been me :P
Title: Re: Cookie Clicker for the Nspire!
Post by: Dream of Omnimaga on December 04, 2015, 04:41:50 PM
It might be another calc game then. I just remember factories being OP or the next two item imbalanced :P
Title: Re: Cookie Clicker for the Nspire!
Post by: JWinslow23 on December 05, 2015, 12:57:08 AM
There are only two other Cookie Clicker games for the +CSE that I know of, and the only one I think you'd know is Kerm's. Didn't notice anything off there :P
Title: Re: Cookie Clicker for the Nspire!
Post by: Dream of Omnimaga on December 05, 2015, 01:18:14 AM
I guess I'll need to investigate, then. I really recall one of the calculator game where the factory had a much higher reward:begin price ratio than the rest. Not that it matters much, though. Just make sure that the game isn't as imbalanced as Illusiat 3 :P (where the level 30-50 orb enemy can be killed in one hit, no matter your level, as long as you have enough MP to cast offensive magic spells, then you are almost 100% guaranteed to level up. And not to mention that level 10 brute in the 2nd dungeon that has 995 HP https://codewalr.us/index.php?topic=665.0 )
Quote from: semiprocoder on December 01, 2015, 01:37:49 AM
DJ I am not 100% sure that my game works with 3.6. Could you check if it does?
I'll try to check later @semiprocoder .
Title: Re: Cookie Clicker for the Nspire!
Post by: semiprocoder on December 05, 2015, 01:25:18 AM
Quote from: DJ Omnimaga on December 05, 2015, 01:18:14 AM
I'll try to check later @semiprocoder .

Thanks!

Also since I'm pretty much done with the game, I am putting up my download. Now there are two ti 84s, one basic and one asm. Also could you suggest any additions to the game, like more sprites or whatever :/.
Title: Re: Cookie Clicker for the Nspire!
Post by: Dream of Omnimaga on December 05, 2015, 01:40:30 AM
I am downloading it now. I just plugged in my Nspire to charge it and it appears that the game runs on 3.6 :D

Only some issues:

-In the main menu, the selection rectangle overlaps on the text above and below. Maybe make the rectangle smaller or increase the space between each line of text?
-The Walrus icon is blurry. Also I think all icons should have a background like the others, else it's not really consistent.

Otherwise, it looks very nice so far. Do you plan to add the background to the upgrade screen and a title?
Title: Re: Cookie Clicker for the Nspire!
Post by: semiprocoder on December 05, 2015, 08:44:19 PM
Ok so I've added the background to the upgrade screen, fixed the menu, and just got the 45 by 45 walrus instead of the 24 by 24 one.
But what do you mean by a title. Do you mean like a big cookie clicker on the top in the menu?
Edit: I found a really detremental glich that made moneyPerClick=0 when you upgraded anything. I fixed it now.
Title: Re: Cookie Clicker for the Nspire!
Post by: Dream of Omnimaga on December 08, 2015, 09:22:15 PM
Yeah I meant some title logo or screen with a cookie on the side or something. Also isn't the scaled up walrus 48*48 or do you mean the higher resolution sprite?
Title: Re: Cookie Clicker for the Nspire!
Post by: semiprocoder on December 22, 2015, 02:31:58 AM
So I have finally decided to finalize this. There is no cookie in the title, but I have added one(Cookie Clicker: NSpired, ik so original), and I have just uploaded my game to ticalc.
Attached is a game only(the gif is too large to post and I am too lazy to upload it somewhere else.
Also the walrus is the higher resolution sprite, not scaled up.

EDIT: Fixed a glitch that I didn't notice when testing, cause I just looked to see if the help screen worked, but turns out the menu stopped working before because I forgot to remove focus on the help text. The updated version is now attached.
Title: Re: Cookie Clicker for the Nspire!
Post by: alexgt on December 22, 2015, 05:08:56 AM
nice ;)
Title: Re: Cookie Clicker for the Nspire!
Post by: Dream of Omnimaga on December 22, 2015, 05:27:29 PM
Cool, I'll try it when I have some time.