Help, tutorials and examples for Game Maker

Hexsweeper 2
click to visit
Minesweeper redefined!

Platformer Engine
click to visit
An Engine to help you start a 2D Platformer Game.
The Black Hole that Wants to Eat Me
click to visit
Stranded in space close to a black hole...

Spiral Lords
click to visit
Lead your empire to conquer the galaxy.
Home Search/Browse Comments Trollsplatterer You can help! Links
Terms&Conditions This website has been designed for Firefox Design by Trollsplatterer (©2017)

Single Script Game  download now
by Jack Oatley

This example shows how to make a game without using GM's internal step-system. The Instance Create event of the object obj_game contains a loop which is repeated until the game ends. Advanced knowledge of GML is required for this way of programming.


General Rating
Your Rating*


Menu This is the menu. It's no separate room, it's just drawn by code in the creation event of the game-object.
Game This is the in-game-layout. The controls and the drawing are still located in the creation event of the game-object.


By Comment
Great work!!
Yes, JackOatley released the EXE-version on his profile, this is the GM source file.
Toon Lighting
I seen this on YoyoGames Sandbox.
Woaahhh, a game made entirely by script, and no sprites or backgrounds were used! That is really amazing, it is just like the C++ and C# programming feel. Really awesome job, keep up the great work!
I found the solution. Move the code to the step event and the sleep function will reduce the processor requirements.
Apparently the Create, Room start or Game start events cause the sleep function to absorb the entire processor if they occur in the first room (not in the second one, though).
Sorry, maximum amount of characters reached :)

I'll take a look later (hopefully tonight), I don't know what the sleep-function does internally, but it might indeed absorb the processor too.
This is an interesting subject, I hadn't tested that and I don't know if Jack did either.
This is very interesting example. It's a really cool use of a loop. What I learned most is how to process keyboard events from within a loop by simply using io_handle()....right?

After looking at this example I started to wonder how much less processing power it uses since it only uses one script and really no other GM events. But it seems that even though it is only using the one script within a loop, the game uses around the max amount of cpu a GM game can use (about 50%).

I was kind of expecting this since loops usually try to compute and get their job done ASAP. So I tried to slow it down some by adding a sleep(33) after the screen is refreshed. I figured 33 milliseconds was the time each frame gets in 30fps. It didn't seem any slower and didnt use any less cpu so I used sleep(330) incase I miscaluated or something. There was a very noticable drop in fps, but the cpu still seemed to remain maxed out.

I just thought this was interesting and was wonde
It's at the bottom of the code:
screen_refresh(); // Flip everything drawn onto the screen.
There's a GM function to force the screen redraw, it should be in the example code somewhere (can't see it from where I'm now, I'll help you out later, if you haven't found it by then).
Cool pong-game

I have only one question: How do you get a text drawn in the create-event instead of the draw-event? When I try that The text is inviseble...
Very interesting, I never knew this was possible until now to be honest. I like it!

* : The rating makes use of your IP-address to remember your vote. IP addresses may change, but your vote will be kept, even though it may no longer be visible here.