Create a Math Game

I understand you want to limit the time you spend on it.

But if you plan to write any longer programs, you need to learn how to make your code tighter and smaller. That’s why so many beginners get into trouble.

Everyone has their own style. Mine is to get the program working, then optimize it.

I think I’m just going to complete it and submit it and then post the code onto here and later on I’ll go in and simplify it.

That’s fine, I think you’ve done well so far

In case anyone is still following this post, the program is still under development and in near completion! :slight_smile:

@codingislife. Please post your finished code using pastebin, Dropbox, or git. I thought about a change to your program using levels yesterday. An interesting skills drill might be to have the program iterate through addition, subtraction, multiplication, and division. You couldn’t proceed to the next level until you reached a certain level of proficiency on the current level. With the right U.I. Enhancements I bet you could get teachers to buy that on the App Store.

@nfgdayton That is an interesting idea. Although this is just a small assignment for my Computer Science class. Oddly enough I actually am doing a math game as well for my final app project (with a group) which will be put onto the App Store. But I’d love to work on this program after I submit it as well.

To get you thinking look at a post called " the power of openurl." I am going to look at sending myself emails … But this looks like it’s definitely possible. It is a small step to have a teacher send themselves reports from classroom activity using the iPad. Then your calc app moves from a practice app to a diagnostic app.

Of course you had better password protect access to the email functionality.

Okay! So I’ve completed what I wanted to accomplish. This is just a small assignment but I may come back to this code and make it much better. I’ve uploaded the code to Github and Pastebin. Open the links & copy/paste the code on your iOS device or else the code will not work (for the ones you must go to; it uses emojis as buttons)

Github: https://github.com/CodingIsLyfe/MathGame (This is my own code using my own iPad images)

https://github.com/CodingIsLyfe/Math-Game (GO TO THIS ONE)

Pastebin: http://pastebin.com/hbuX1pNf (This is mine)

http://pastebin.com/4FyXKe3j(GO TO THIS ONE)

Let me know if you run into any problems or have any suggestions. This was a fun project and it really helped me understand Codea. Big thanks to everyone who helped me. @dave1707 @Ignatz @nfgdayton and @quezadav

Don’t stop now.

There’s so much more you can do with Codea.

Oh I know. This is…hm…let’s say v1.0

I’m actually quite interesting in making the game look cleaner and more organized (etc). That’s just the code that works fine in my opinion and I’m happy with it. Also, that code will be what I’m submitting for my assignment but I’ll find time to make it better.

I’ll definitely come back and do more.

@codingislife Thanks for posting the version that uses CODEA native images. The “Go to this one” link in Pastebin is the same as your code, but I went to github and got the “native” version.

I am very jealous of your visual design skills. The cloud above the character boy is a great way to present the problem.

I am going to show this program to a teacher friend of mine and see what they think about using this program to evaluate student’s grasp of math facts. If I write that program I will post it on this thread.

This is very nice work. It is amazing what you can do in Codea in under 150 lines of code.

@nfgdayton Thank you for pointing that out. The new link is http://pastebin.com/4FyXKe3j

Also thanks for the compliment. I find my artistic skills play a major role in my other courses and it definitely helps.

Sounds good. Whenever I complete my course’s final app project I’ll make a post on here as well. The game will be similar to this but instead it gives you the solution and you must determine whether it is correct or incorrect.

Codea is so fun :smiley:

Yes. I’m exploring the tables to string/ string to tables threads right now. I’m surprised these don’t come up more often. Easy to convert a table to a string. [http://codea.io/talk/discussion/2850/table-to-string](String to table) is a little harder. I tried to go generic and got caught up in string handling problems. Problem is handling tables containing tables.

Formatting permanent data in terms other. Than key-value seems to be a sticking point for Codea ON THE IPAD.

You do whatever you want with my code @nfgdayton

@nfgdayton See the Codea functions json.encode and json.decode .

Hey, y’all. I’ve got a question about the touch function. I didn’t want to make a whole new discussion because that could get annoying.

So in my programming class, we’ve been creating an app in groups. I have a question about how I’d go about making a store. Well, I’ve got the code checking if the user has enough currency to actually buy the item and their amount of currency goes down. However, I want the user to be able to buy backgrounds for a scene where they are displayed with a math problem. Here http://imgur.com/a/lZQui you can see the pictures of some scenes. I have it when the user presses the small squares in the store, a preview of the background will show up. I’d like it if I could check if the user has held it for a certain amount of time and then maybe the square changes colour or something (checkmark) and then the user pressed the buy button. This is the code for the store scene http://pastebin.com/2M2T6txf. We have this chunk of code we use in class to make coding easier which is why the store scene code looks a bit different from normal LUA if you will. This is the said chunk of code http://pastebin.com/c004LDSi which is put in a ‘Blank File’.

HahaHa - I love the reference in the code to the scene manager being from Brainfox on the Codea forum. If Briarfox was still around, he would ROFL. :smiley:

You already have code for touches.

When a touch is made on one of the menu squares, and the touch state is BEGAN, set an indicator variable, eg startTime = ElapsedTime

When the touch ends (touch state is ENDED), check if startTime was set, and if it was, calculate the time it was held = ElapsedTime - startTime

@Ignatz Would the

if (touch.state == BEGAN

follow with

and backgroundPreviewRed.selected == true) then
startTime = ElapsedTime
end

or have I misinterpreted your comment?