• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Learning efficient programming.

Z

zchang

Guest
Hey everyone. So, I'm new to gamemaker, and also to programming.
I should get out of the way that programming isn't the issue here. I don't have any actual studies on programming other than my experience with softwares like GM and such. However, I don't find [gamemaker's] programming any difficult in general. I always try challenge myself with something I'm not sure I'll be able to program, yet so far I haven't had to retreat.
If this doesn't belong to the programming subforum, I apologize.

Anyways, when there is some mechanic that I can't fully imagine in my head, I of course look for some tutorials or examples. I never follow them exactly nor copy the code, just analyze the approach and use my own.
Is that a bad thing? I have probably close to a thousand hours of code experience, but I have yet to understand how to 'gain' more experience. Should I always try to do this fairly complex mechanic by myself or is looking for some direction okay?

In case I didn't myself very clear, which I believe I didn't: Why I'd like to know overall is, which is a better practice? Spending several minutes designing a good algorithm that will most likely fail (Trying by myself without any idea ), or try to start with some direction (Researching before starting) ?
 

jo-thijs

Member
I never follow them exactly nor copy the code, just analyze the approach and use my own.
Is that a bad thing?
I would say that is a good thing.

Why I'd like to know overall is, which is a better practice? Spending several minutes designing a good algorithm that will most likely fail (Trying by myself without any idea ), or try to start with some direction (Researching before starting) ?
I'd say several minutes isn't too long to design a good algorithm yourself.
If you're thinking about it for several days, it might be a good idea to look it up.
Even if you find a good algorithm yourself, it might still be a good idea to look up afterwards how other people approach it.
They might have better or easier solutions.

In short, I think it's good to think about it yourself first, but it's a good idea to look up how things are done afterwards anyway.
 
A

Aura

Guest
Researching a bit is as good of a practice as designing an algorithm yourself. You might find something that might be far more efficient than what you would've come up with.

But since neither of researching and self-dependency is a bad practice in general, you should choose for yourself as you see fit in the context. But I'd prioritize self-dependency though; you should design algorithms yourself and research to see if you could do it in a better and faster way that suits you.
 
T

The Shatner

Guest
Hey zchang!
Aura is right, self-dependency is a vital skill. However, especially when you are beginning, it's important to do a lot of research. Without researching, you won't even get to know some advanced functionalities and would have to write enormous algorithms to achieve what only a few lines of code can do. For example, you can make an algorithm that tells an object to avoid obstacles as it follows a certain other object, but if you research about Motion Planning you will see that GM already has tools that make that task a lot easier.
 

FrostyCat

Redemption Seeker
There comes a time in every programmer's development when further activity-specific training becomes futile without a grasp of basic computer science.

Computer science teaches you reusable, non-specific patterns. You will know how to organize a process, how to keep your data in line, what the ready-made general solutions are and how to gauge your correctness and performance. It can be self-taught, but my recommendation would still be a formal course like this one.

The more algorithms and data structures you can reduce your needs to, the more independent and informed you become. If you know your way around data structures, basic graph theory and first-year CS, you will be in the top 10% of this community as of today.

It's the main reason why skiddies keep asking for cover-all fairies all day in vain, while experts almost always gets things their way with little effort:

Skiddie: What's the code for an RPG inventory? *gets response* NO! Where's the stuff for dragging and dropping? *inane complaints ensues*
Expert: Looks like a map or 2D array with some sugar on top. I'll plan out the operations to support, implement them and then hook it up to the presentation later.

Skiddie: How do I generate good mazes? *told to look up maze algorithms on Wikipedia* I'm a visual learner! Where's the video tutorial? *reenactment of Goldilocks*
Expert: Heard about Prim's algorithm being used to generate mazes. From its description, maybe a priority queue plus a couple of 2D arrays or grids would do, then I'll build wall objects around the model if need be. I'll look up the specifics if I'm unsure.

Skiddie: How do I make my game playable online? *told to send messages and respond to them accordingly* What does that have to do with what I want? *foot stomping*
Expert: It's just passing messages around. I'll bootstrap myself with a chat project and then proceed when I'm comfortable. I'll also research techniques for dead reckoning and interpolation if needed.

Skiddie: What's the best textbox engine there is? *gets a few suggestions* But that doesn't have what I want! *more whining*
Expert: A textbox is just a bunch of drawn sprites and text, plus some basic keyboard I/O. I'll draw a diagram to plot out where elements will be drawn, then plan out its responses to keystrokes and behaviours while on screen. Then I'll add a script to make it easier to plop out.

Reduction to basic material is the most fundamental skill of anyone involved in mathematically oriented trades. Yet on the GMC, that is commonly replaced with whoring after tutorials and for tailor-made solutions. Not exactly what I'd call a proper learning environment.
 
S

Soco

Guest
I've been using gamemaker for about 6 months straight right now, so I'm not more more than a beginner myself. However, my approach has been to follow a couple different tutorial series from 2 or 3 different youtube folks. Normally, what I do is follow their code exactly. I comment the crap out of every line so I know exactly what everything does and how they tie together. Once I get to the end of the tutorial(I've completed 4 different ones now), I go back and change tons of stuff. I try to add new things to the game to expand on what I was showed. The goal being to make fully playable game of course. It sounds like copying I guess, but if I could give you a quick example.

I did a tutorial on a platformer, and the guy runs through a cave jumping on the enemies to kill them. I've changed it now so that you attack the enemies by throwing rocks, using a whip, and pickax. Giving the enemies knockbacks, healthbars, and different reactions to being hit by different weapons. I've also added various hazards like falling rocks and spears shooting out of the wall. Some other stuff as well, but the point is, that I learned how to do most of the additions by taking what I learned from the tutorial and modifying it. Otherwise, I wouldn't have the different between functions like place_meeting and position_meeting.

Eventually I'd like to be able to make a game from scratch, but right now, I'd burn myself out trying. This way is more like the difference between building a racecar from the ground up or buying a used Honda and putting in a souped up engine, and racing tires...and non-streakin windshield wipers...something something... I know nothing about cars actually, so this was probably a bad analogy. Sorry, got sidetracked.
 
Z

zchang

Guest
Hey, thanks everyone! I found every response very useful. Since I'm not really studying Computer Science I lack a community to discuss this kind of stuff that may sound trivial. I just want to do whatever is more effective for me as a programmer on the long run.

Without researching, you won't even get to know some advanced functionalities and would have to write enormous algorithms to achieve what only a few lines of code can do.
I hear you, I learnt this the 'hard' way, haha. Since then, the reference has become something that I find even fun to read, somehow.

However, my approach has been to follow a couple different tutorial series from 2 or 3 different youtube folks.
I've found this community extremely helpful. It's the first time I write here, as for any problem with some mechanic I usually go to reddit. Both here and on reddit, responses are quick and very resourceful. About you wanting to start from scratch: in MY experience, which I won't assume will be yours too, everytime I start a new 'project' I feel like i'm starting from a new, higher level, and that allows me to aim even higher and succeed (so far, at least). So even if it sounds scary, I'd tell you to try. Worst case-scenario, you can always resume your previous project.

It's the main reason why skiddies keep asking for cover-all fairies all day in vain, while experts almost always gets things their way with little effort:
I actually laughed while reading this. I've seen it so many times while looking for ideas to program this or that. There is too much people who want to make 'games' without any kind of effort. Sometimes I think that that sort of beginners make the rest of us look just like them. I feel like I'm somewhere in between the skiddies and the expertes in your examples. Once I understand how something works, I can basically deconstruct it and savage the things I didn't know.

Thanks everyone, all your responses were really helpful. I've felt kind of bad every time I looked up how to do some advanced stuff, some sort of shame, even if the aftermath was good. When I did I felt kind of a lesser programmer, but I guess that is a common thing since I am, after all, a beginner, haha.
 
K

Kris Hyre

Guest
Thanks everyone, all your responses were really helpful. I've felt kind of bad every time I looked up how to do some advanced stuff, some sort of shame, even if the aftermath was good. When I did I felt kind of a lesser programmer, but I guess that is a common thing since I am, after all, a beginner, haha.
No reason to feel bad about it. Using tutorials and demonstrations and such is not bad at all, as long as you area focusing on learning "why" something is being done that way. Once you understand the why, you can proceed on your own. Just copying code is not good, but that doesn't sound at all like your approach, just some others take that route.

Programming is full of algorithms, libraries and resources that other developers have worked on for years to come up with dependable, tested and proven code. It's ok to use that work and stand on the shoulders of giants, so to speak. You don't want to try to re-invent the wheel when its been done x1,000 before (unless you're an engineer working on racecar tires), but it is best to understand the underlying physics behind why the wheel functions the way it does while you build on that.
 
T

The Green Dev

Guest
YES you should follow tutorials and examples, not exactly cause it may not work for your game, but change it up a bit so that you learn what those values and equations do. That'll get you better at GML
 
ask lots and lots of questions and make sure to regularly apply face to wall when in doubt in the following order

:) this is zchang
:mad: this is zchang on gml
:bash: this is zchang learning gml
:confused: this is zchang coding gml
:eek: this is zchang when zchang figure out what to do
:bash: this is zchang after spending 2 months to solve something that took 2 hours after figuirng out what to do
:banana:this is zchang after finally making your first release
:bash: this is zchang where 13.25 seconds after the publish button is clicked realizing their is a glitch in the code
:duck: thit is zchang after 3-4 years on here

any questions?

welcome!!!
 

Hyomoto

Member
I think the best way to learn is to try and recreate things that already exist. Whether you want to build a ray-casting engine, or a tetris clone, define what it is you want to accomplish and do that. I honestly suggest pick an old game from the Atari, NES or even old DOS eras and try to recreate it wholesale. The nice part about old games is they are relatively simple and you can focus on learning how to code instead of, say, what deferred rendering is. The initial intention of what you want to build is incredibly important. Games have menus, status screens, levels, etc... and these are things people almost universally skip over when they first start learning. If you jump in head first to create your top-down shooter, you'll get lost in all the things you don't know you need to create. So even if you just try to recreate a single level from Smash TV, picking something that already exists means you have a clear example of what you are trying to accomplish and what it should do when it's done.

Personally, I suggest Tetris. It may be a simple game, but you'll learn quite a bit trying to recreate it so it makes an excellent starting point.
 
When I first started using Game Maker and GML, I used to look at almost every tutorial and example I could get my hands on. Luckily, I have a programming background, so it doesn't take me very long to pick things up. Nowadays, I can pretty much figure out anything I want to do on my own, unless it's something completely new that I've never dealt with before (I'm looking at you, shaders!). I used to take what the examples and tutorials did and completely change them. I don't like following along and recreating things 100%, cause it helps me to understand better to change things from the get go. After all, the example/tutorial already tells you what to expect from how they have it, so doing something verbatim is just a typing exercise in that case. The key is to understand what the code is doing and not just copypasting everything.

@FrostyCat, I enjoyed your post on here, but was sad when I got to the end of all the Skiddie vs Expert examples. They were very entertaining.
 
Top