4

Cart #42640 | 2017-07-20 | Code ▽ | License: CC4-BY-NC-SA
4

Not a overly flashy game. but a personal challenge I set my self to better understand how to code.

I wanted to make a very basic calculator to better understand how to input and compare variables and output an answer. the two variables will increase in randomness based on your correct answer score. The operation are limited to addition subtraction and multiplication, No division as that would require a decimal place or to check the answer is a whole number which i have yet to finger-out.

--controls:--
use arrow key to navigate key pad.

If anyone know how to check for a whole number please put in comments below

having a issue with numbers over 9999? seems to generate is know random number if i try to input a number over this. Is this a limitation with the programming language or my programming skills?

P#42642 2017-07-20 07:07 ( Edited 2017-07-22 10:11)

As a retro console, Pico-8 has many charming quirks.

One of the ones most likely to blindside you is that the numbers can only go up to 32767.99

That's probably related to the problem you mention at the end of your post. If you need larger numbers, you'll have to do something clever.

Good work on the game. It's an accurate homage to all those tedious games that were installed on school computers back in the 80s!

P#42646 2017-07-20 10:06 ( Edited 2017-07-20 14:06)
:: enargy
1

EDIT: Here's an example cart

Cart #42653 | 2017-07-20 | Code ▽ | License: CC4-BY-NC-SA
1

If you need to go over the integer limit, you can store your number as multiple numbers, just have have each cover 4 or 5 places. For example.. (I used this in an old arcade game project I never released but maybe it will help?)

To calculate score:

 ```score += points while score >=10000 do //moves the points over 10,000 to a separate variable score2+=1 score-=10000 end ```

To get score for display:

 ```function get_score(s2,s1) //returns the combined values of //the 2 score variables, padded as necessary local txt = '' local txt1 = '' local txt2 = '' --10,000 txt1=''..s1 while #txt1 <4 do txt1 = '0'..txt1 end txt2=''..s2 while #txt2 <3 do txt2 = '0'..txt2 end txt=txt2..txt1 return txt end ```
P#42652 2017-07-20 11:26 ( Edited 2017-07-20 15:41)

Thanks apLundell and enargy

for the clarification of what is happening and for a awesome work around.

I will no doubt will use this in latter project or this one if I can figure how to solve my other problem of on diving into whole numbers.

Cheers