Monday, 25 May 2015

I Do Overcomplicate Things Sometimes...

I was watching some of Tom Francis's Make A Games With No Experience tutorials today, and I noticed something that made me facepalm.

Back in this post, I had a problem with randomly moving objects going offscreen. In order to try and solve this, I limited the distance that objects could choose to travel to and then, within that range, checked for problem locations such as screen edges. Once those problem locations were located, the object... actually, it's not worth going into - point is, it was a horribly convoluted method of doing things. Tom Francis used four lines of code that would have saved me a lot of time. Here's what he used:

/* Stay inside the room */

if x < 0 { x = 0 }
if y < 0 { y = 0 }
if x > room_width { x = room_width }
if y > room_height { y = room_height }

And that's it. God, I wish I'd known about room_width and room_height before -  I could have just used those four lines along with a random coordinate...

Which actually brings me to something else. Back when I started my game, I knew absolutely nothing about GameMaker. Having learnt a bit more, I can see just how shaky the foundations of my game are. I won't go into all my mistakes, but a lot of it is to do with how I've structured stuff - things like, which object I've attached code to, or how I could use scripts to simplify things.

Because of this, I'm thinking it's not really worth carrying on with my game. I think it really needs rewriting, which is not something I want to get into right now. There's all kinds of other stuff I want to try, other kinds of games. So, for now, this particular project is going to be put on the backburner. I do quite like the idea still, so I may well come back to it at a future date.

Instead, there's another game project which I hope to be starting soon. I'll continue to document it on here.

No comments:

Post a Comment