Newbie Slot Machine Project

@dave1707 thank you for that, at first it looked like Ancient Greek but after a dozen or so readthroughs I ‘kind of’ understood a little of it.

@SkytheCoder thank you for going to the trouble of typing all that, it looks so very complex though, even reading through several times it almost seems like an alien language :slight_smile:

Thank you all, I think considering all things, I’d be better of not doing this, it seems incredibly hard and I am not sure my brain could cope, but I thank you for the advice and help.

Hello again,
I went to buy a £25 iTunes card today as I want to buy a couple of expensive games and the store had a buy 2 get 1 free on £15 cards so I got that and now I’m going to buy Codea. Why not, it’s like a freebie :slight_smile:

Now to my question, I want to learn codea as I work on a game so I would like to make that very simple slot machine game, don’t even need to use graphics at first, could use text for oxo, but what would be the best way to starting to code such a thing like moving reels?

Tyson, first learn a bit of Lua (the language itself), then you’ll be ready to try the graphic part of Codea. If you start programming a game before you even know what an if test is, you are doomed to fail.

While we are happy to help, we simply cannot provide you with one-on-one training, on this forum. You need to learn as much as possible yourself.

There are lots of tutorials and some ebooks on the wiki link above. Why not start there, and see how you go.

Uh okay. I never really asked for one-on-one training, just a pointer but I guess you guys really are sick of newbies asking pathetic questions so ok, I’ll take your advice.

Actually these guys are extremely helpful and patient with newbies. All that is being asked is that you look at the untold man days of helpful tutorials, etc. that they have compiled for new users to learn from. It is not fair to expect them to rehash that which they have already graciously provided. Once you have a foundation and can ask more specific implementation questions you will find the help overwhelming.

It’s kind of like saying “I want to build a house but I’ve never used hand tools. Not a mansion, mind you, just a simple cottage. Maybe just holes for windows. Any suggestions?”

Try the tutorials. Chances are you will get hooked and the lights will start to turn on.

@Tyson I wouldn’t be put off by @Ignatz remark, I don’t think he was intending to be rude. I think his main point is that, while you may want to dive in right away and start making a game (even if it’s a simple one), if you have no programming experience that is going to be quite difficult, and you are likely to get frustrated and give up altogether. Because let’s face it: making games is difficult even for experienced programmers.

Frequently we get questions like, “Hey guys, can I make Zelda or Battlefield: Canada with Codea?”. Frankly, if a person needs to ask that question, then the answer for them is almost certainly “no”.

It’s probably best to start much simpler, with programs that only do 1 single thing, and work up more complex stuff as you start to grasp the simpler things. For example, program #1: draw something (anything) on the screen; program #2: draw 2 things on screen; program #3: draw one thing on screen, make it change to a different thing when touched; etc, etc, etc. This way, you will feel a sense of achievement each time you accomplish a goal, which will in turn motivate you to continue trying and learning new things.

Okay thanks, I just thought I might learn faster or be more motivated to learn if I was working on something I was interested in.

I thought programming a text only fruit machine with no features or extras wouldn’t be too complex for a newbie (ie just 3 moving reels that start and stop) but to be honest being a beginner i can’t say if that’s very simple or very hard.

I’ll try to read some tutorials but most tutorials tend to be on boring, dull stuff. (Not commenting on codea ones, just usual ‘tutorials’ in general). Thanks for replying

@Tyson: It doesn’t have to be dull. It’s only dull if you see it that way. For most of us, the act of programming (and indeed learning how to program) is the interesting thing.

Also, it’s not helpful to ask others how difficult/simple something is. The answer will always be, “it depends”. It depends on the programmer. It depends on how simple/complex you want your fruit machine to be. Frankly, I have no idea how simple this will be for you.

As I said before, a good first program would be to: draw a sprite on the screen. If you can figure out how to do that, and you still find it dull, then you probably really aren’t going to enjoy programming that much. But, if you’re still interested, then figure out how to draw 2. Once you’ve figured that out, figure out how to draw 3. Bam! You are that much closer to a fruit machine game.

I get the message, ok thanks for your thoughts. :slight_smile:

@Tyson, of course I wasn’t intending to be rude.

And I understand that you thought your suggestion was a reasonable start. But what I was trying to say was that it is probably too complex, and that you shouldn’t really attempt anything at all until you know a bit about the language. Otherwise some of us would just end up having to write the whole thing for you.

The truth is that all programming involves hard work, like anything that is worth doing. I compare it to learning a foreign language. So saying you’ll learn Codea by programming a fruit machine is actually like saying you’ll write a short story in French without knowing any French first. Obviously you need to learn something about the language first.

So don’t be put off, it’s worth the effort, and we will help. But please do use the tutorials provided to learn as much as possible.

@Tyson I guess I will disagree with everyone when they say don’t try writing a game first. If you want to write a game, go ahead and do it. Just be warned that you will run into a lot of problems and it may not be what you intended. You won’t be doing it in a few days, weeks, or maybe even months. You’ll have to have different projects going at the same time. One project will be your main game, the other projects will be where you write little test routines that you will then integrate into you main game when you get them doing what you want. These little projects will be “I need to do this, so how do I write the code”. Depending on the way a person wants to learn will determine how they go about it. If you set a goal and continue to work at it knowing that you’re going to fail in the beginning, then you will probably succeed. If you have the attitude “I don’t know how do I do this, but I won’t give up until I know how” then you’ll be able to do it. But if you’ll say, " I’ve been working on this for 2 hours, this isn’t working, this is stupid ", then don’t bother trying. It’s the amount of work you put into it that will determine where you end up. Try writing some code. If it doesn’t work, look at the tutorials, or the build in documentation. Try to see what you’re doing wrong. Writing code that doesn’t work is an important way to learn how to write code that does work. So do it however you want, if that doesn’t work, try a different way. But do it in a way that’s fun and interesting to you.

@Tyson Exactly what Dave said but if after 2 hours you don’t find a solution don’t give up (I don’t think this is what Dave meant by the way) just put Codea down for an hour or a day and come back to the problem then try to rework it. The very attention you give to a problem is the energy that solves it but you won’t be attent to the problem anywhere near as much if you just roominate on it you should try and think of different approaches and similar ideas close to what your trying to accomplish then write it out, in my experience this helps many times more.
Another thing to do is to think of the steps involved in what you’re trying to get at and pay attention to each one individually, this also helps when learning new concepts.

@Luatee You’re correct. I meant that if you’re going to totally give up after 2 hours, don’t bother. It’s a good idea to stop working and come back to it later. I’ve done that many times.

@dave1707 - yes, but you have to know a minimum of code. Giving a total novice the task of building a fruit machine in Codea, however simple, without any knowledge of coding, makes no sense to me. It will just lead to enormous frustration. (Perhaps it is what you did, but you have a strong programming background).

Also, Codea is made up of several parts - Lua, the Codea drawing engine, etc. Trying to learn all of it simultaneously, especially for a beginner, is way too hard.

For many years, I have been helping new graduates learn Excel VBA. VBA also has a language and a visual part. I found with experience that it was best to learn the language first, and then apply it to the visual tools, because breaking it up like this reduced the learning curve dramatically. I believe the same applies to Codea.

@Dave1707 I thought that’s what you meant, was a bit unclear as I haven’t had much sleep due to raising a litter of puppies! If I’m creating effects for a game or mechanics for how something moves I tend to write additional features for an app in a new project first then put them in to the app when I’ve finished the base of it, this also seems to help a lot.

@Ignatz you’re right, he probably won’t need to know some of this for a while.

@Luatee - what I do is add a tab on the end and put a little setup and draw function there to test things out (because - for those who don’t know - Codea compiles from left to right, so if you have two setup functions, it will use the last one it finds). Then I comment it out until the next time I need it.

The nice thing about this approach is that it lets you call any function in your project, so it is great for testing new functions, or debugging functions, without having to leave your project.

@Ignatz I didn’t think of that, great idea! Saves me from those tedious minutes of missed time jumping in between projects, thanks.

Edit: changed my mind, too scared to post my code.

@Tyson Some people like to read and understand things before they try it. Others like to jump right in and try to do it. There isn’t a right or wrong way. If you don’t mind spending 8-9 hours then that’s fine. Those 8-9 hours will soon turn into 8-9 minutes. The whole point is to enjoy what you’re doing as you learn. I have one suggestion for your code, indent the code in functions and if statements. That makes it easier to see what’s grouped together. That will also help in the future when you have to debug code.

EDIT: There wasn’t anything wrong with your code. You’re learning and people can’t give you suggestions if they can’t see your code. Also, don’t be scared to post, we’re here to help.

@Tyson have no fear! You can do it! Believe it or not it would be easier to start with a graphical slot machine vice a text one. Step 1: go get three pictures or use three built in ones (it might look a little funny, but oh well). Step 2. Write a simple program to display them in a row. This is where codea excels, because it would only take three lines of code. Once that is done, the fun begins. Step 3. Setup a timer that changes the pictures and stops after a few seconds. Step 4, create an if then statement that says if all the pictures are the same, you win!

Honestly, your game would probably be less than 50 lines of code and would be a great way to learn how to code in codea.