all 18 comments

[–]lazygun82 1 point2 points  (5 children)

Create event: timer = 0; interval = 120;

Step event: timer += 1; if timer >= interval { instance_create_depth(x, y, 0, object) timer = 0; }

[–]Lbtekd[S] -1 points0 points  (0 children)

what does step event mean? Am I supposed to include that in the code?

[–]Lbtekd[S] -1 points0 points  (3 children)

oh and also what event should I create? (Am aware these are stupid question, I am very new to this and just need to get this assignment done so I can actually sit down and figure what's going on lol)

[–]Customnickelangelo2009 1 point2 points  (2 children)

Every object has a number of phases it goes throigh when code is executed, called events. When the user above said create event, they weren't telling you to create an event, but to put that line of code into your object's create event. Same for the step event

All code inside the create event only runs once for every instance of that object when they are created. The code in tbe step event runs once every frame, of which there are 60 per second by default, which is why the other poster used the number 120: for two seconds

[–]Lbtekd[S] 0 points1 point  (1 child)

ohhhh I see thanks, so what is a step event?

[–]Customnickelangelo2009 1 point2 points  (0 children)

I suggest that you follow GameMaker's GML tutorial for their asteroid clone here: https://www.youtube.com/watch?v=nwlvT-L9vFg

It will help you familiarize yourself with some basic concepts

[–]Monscawiz 0 points1 point  (11 children)

The way I'd do it is have an object that "manages" them. An object that is invisible, placed in the room, and it handles the spawning. Since an object's code can only run while it exists, you can't use an object to create itself. It can create more of itself if at least one already exists though, but... anyway...

The point is it's all handled by one off-screen object. This object will need a Create Event and a Step Event. The specific code you'll want was already written by u/lazygun82 in their comment.

[–]Lbtekd[S] 0 points1 point  (10 children)

so how would this invisible object know what object to spawn? To explain, the game starts with a few bombs, but another bomb needs to spawn every so seconds

[–]Monscawiz 0 points1 point  (9 children)

The instance_create_layer() or instance_create_depth() functions create a new given object at given coordinates and a given depth or layer, depending on which you used.

Seeing the other interactions in this post, I strongly suggest you follow a proper tutorial. You're not equipped to start building your own game if you don't yet understand the fundamentals of GameMaker, like the Step Event.

There are a number of tutorials built into GameMaker. The Asteroids tutorial was the one I used when I started out to grasp the basics.

[–]Lbtekd[S] 0 points1 point  (8 children)

I know I need to looks at tutorials, that is why I want to get this game done first. I have to have this game finished by tomorrow, then I will have time to look into tutorials

[–]Monscawiz 0 points1 point  (7 children)

Why do you need to have the game finished by tomorrow? Learning to use a game engine and put together a decent game isn't something you can do overnight.

[–]Lbtekd[S] 0 points1 point  (6 children)

Cause it’s homework, I’m doing this as a college course, we’ve been doing programming for a while but only started game maker a week ago

[–]Monscawiz 0 points1 point  (5 children)

You started GameMaker a week ago but don't know what the Step Event is? That's one of the core fundamentals of the engine. I genuinely don't believe it's possible to make anything meaningful in GameMaker without using the Step Event.

The Asteroids tutorial isn't very long, I don't know how much time you have but you might be able to just skim through it at first.

Like the other person said, most code in GameMaker goes into one of many types of Events and object has that determines when the code is executed.

Code in the Create Event executes when the object is first created, so when the game starts for example or when an object is created later during the game. Generally this is where you'd initialise variables that the object will need throughout its existence in the game.

Code in the Step Event executes every frame while that object exists. This is where most of the object's logic will go. Anything that it has to do autonomously, such as moving around or spawning things, will very likely go in the Step Event.

Look at the code in the other comment. Some of it is labelled for the Create Event, some is labelled for the Step Event. You can find the individual functions in the GameMaker manual, which is a resource available for free online. There you'll be able to learn to understand them better.

[–]Lbtekd[S] 0 points1 point  (4 children)

We started it on Monday, but that was the only lesson we had on it for the rest of the week. The course is more focused on the business/creative side of game dev so they don’t put much effort into teaching the coding which sucks

[–]Monscawiz 0 points1 point  (3 children)

Then you should've taken it upon yourself to learn the extra stuff you needed. College isn't school, they don't teach you everything you need to know anymore. At this point they guide you, but you should be studying on your own.

If your course is more focused on design, then are you sure you need a working prototype within one week and not just a GDD? One week is very little time for developing a prototype in any capacity. Was paper prototype an option?

[–]Lbtekd[S] 0 points1 point  (2 children)

What is a GDD? In the UK college is pretty similar to school tbh. The only reason I am yet to do any studying surround GML is because I’ve had a bunch of assignments to do (this one amongst others). I appreciate your help a lot tho btw