[Tutorial] How to pause your game in GameMaker

Adding the ability to pause is an easy way to polish your game. It make your game feel more like a “real” game. Luckily GameMaker makes pausing games very easy.

There are two major ways to pause your game. One is to create a globalvar called “paused” or something similar, and wrap all of your step code (except the step code on your pause controller) in a check that looks like this:

if(!paused)
{
    //Step code goes here
}

Your pause button object would then take a click and set paused to true, stopping all the step code.

Personally, I feel that that is ugly, and hard to maintain. I do not like solutions which involve adding the same boilerplate code to everything. My preference is to use the instance_deactivate_all function to handle pausing for me.

To do this, you need to set a global which we’ll call gamePaused to true:

globalvar gamePaused
gamePaused = false;

Create a pause button object with a pause button sprite set to it’s default sprite. Add the following code to the step event:

if (global.gamePaused == false && mouse_check_button_pressed(mb_left) && position_meeting(mouse_x,mouse_y,pauseButtonObject))
{
    instance_deactivate_all(true);
    global.gamePaused = true;
    sprite_index = playButtonSprite;
}
else if (global.gamePaused == true && mouse_check_button_pressed(mb_left) && position_meeting(mouse_x,mouse_y,pauseButtonObject))
{
    instance_activate_all();
    global.gamePaused = false;
    sprite_index = pauseButtonSprite;
}

This checks to see if the game is paused. If it isn’t, and the left mouse button is pressed, and it is pressed over the pause button, deactivate everything but the pause button, set the gamePaused variable to true and change the sprite to a play button. If the game is paused, and the left mouse button is pressed, and it is pressed over the play button, reactivate everything, set paused to false and change the sprite back to the pause button sprite.

If you want to make a pause menu, create the instance in the first conditional.

Share Button

[Meta] I’m moving my games to GameJolt

What is GameJolt?

GameJolt is a kind of social network for game developers. They host tons of games and game jams. All around it seems to be a large, active, positive community. The site is quite old. I honestly have no idea how I went so long without hearing of them. You can see my profile here.

Why are you moving your games?

To get them more exposure and to monetize them. The $1.87 I’ve made from my blog so far isn’t exactly going to pay my mortgage. I’m also going to only make a few more direct Atari clones, before I move into more elaborate retro style games. To make money, I need players. To get players, I need to be better than games from 40 years ago. Pong is old enough to be my dad. It’s been cloned a million times and adding one more clone into that ocean of clones isn’t how I’ll get noticed.

GameJolt also has a nice API for achievements/high score/other goodies which I would like to integrate into my games. I’ll also add some direct social integration, rather than just post links to my game and hope for the best.

How will this effect readers?

It probably won’t. All the links will be changed in the near future. If you happened to bookmark any of my games directly, you’ll have to update the bookmark to point to GameJolt. The source code will remain in my github repository.

Overall I think this will be a positive move which increases exposure to my work. If I can stick it out and make a name for myself I can live the dream I had at 5 years old. To make a living making video games!

Share Button
Asteroids Icon

[Tutorial] Asteroids

Goal

I cloned Asteroids in GameMaker Studio, to complete the Hexagons monthly challenge on OneGameAMonth. Graphics were made in Aseprite, sounds were pulled from OpenGameArt.

I heavily commented the source, so anyone who wants to learn some GML can follow along.

History

Asteroids was released by Atari in 1979. It was a massive hit for them. Game play is pretty simple. You pilot a small ship, which you fly around on a screen filled with asteroids. Shooting an asteroid causes it to break apart into a couple of smaller asteroids. That process happens twice. The final, tiny asteroids are destroyed when shot. Occasionally an alien saucer flies by and shoots at you.

Asteroids has a unique game fell. The style of movement is based on a lot of vector math. Coding it in ASM, like the original developers did was probably pretty difficult. Luckily, modern tools make that kind of thing trivial, so I leaned on GameMaker Studio to figure out the calculations for me, and just played with the numbers.

Details

Asteroids Gameplay

Asteroids Gameplay

I drew the sprites by hand with Aseprite. None of them (with the exception of the invincible ship sprite) are animated. I let GameMaker handle sprite rotation for me, rather than trying to animate it myself. Most of the code involved is stored as a GML script. There are a few places I used drag and drop, but mostly because I had a couple of one-offs that would’ve resulted several scripts which were one line long, and not reused anywhere else. In those cases I opted to just use DnD. I think that’s the only real, legitimate cast to use the DnD interface. I try to use it sparingly, because it is nowhere near as powerful as GML.

You can get the source here, and play a live demo here.

Share Button
Brick Breaker 1GAM Icon

[Tutorial] Game Boy Style Breakout

Goal

I’m cloning Breakout, at a Game Boy resolution, with a Game Boy color palette for two reasons.

  1. To have something to submit to GBJam 3
  2. To fulfill the “Resolution” monthly challenge at 1GAM.

Graphics will be made in Aseprite, coding will be done in GameMaker Studio. Sounds will be pulled from OpenGameArt, because I don’t have time to make them.

History

Breakout was created by Atari in 1976 by Nolan Bushnell, Steve Wozniak, and Steve Bristow. Breakout was created around the concept of trying to make Pong into a single player game. Breakout has been ported to just about every language and system you can imagine, including an actual Game Boy port called Alleyway.

Details

Alleyway Title

Alleyway Title

Brick Breaker Title

Brick Breaker Title

I duplicated the layout of the Alleyway for my GBJam entry. I titled it Brick Breaker. Like my last project, it’s written in GML. No drag and drop methods are used. Some of the code is a little ugly, because I wrote it in great haste. I made a mistake with the timing of GBJam and though it began a week later than it actually did. Because of that, I did not have time to polish the game, or track any sounds in Famitracker.

Alleyway

Alleyway

Brick Breaker Game Play

Brick Breaker Game Play

All the graphics were made by me, in Aseprite, using the Game Boy palette that ships with the software. I obeyed the original Game Boy restrictions on sprite sizes and sprites per line. My graphics are based on, but not a clone of, the graphics from Alleyway.

You can grab the source here, and see a live demo here.

The source is messy, but pretty well commented. Following the comments, it should be pretty obvious how everything works. I may clean this example up one day, but for now, if you have questions, contact me and I’ll answer them ASAP.

 

Share Button

[Open Thread] Trance Music

Every Sunday, I will post an open thread. I’ll only moderate to remove illegal or wildly inappropriate behavior. You’re free to talk about anything in the comments, but I’ll suggest a topic in the title.

Today’s topic is trance music. I’m a fan of trance. Does anyone have any suggestions for a good trance or EDM album I can pick up on Amazon Music?

Share Button
Puzzlebeams Title

[Review] Puzzlebeams by Blue Candle Games

General Info

Puzzlebeams is an Android puzzle game by Blue Candle Games. You use laser beams to push colored balls into holes of the same color. There are 40 levels. The game is ad supported, but ads can be removed for a small fee. You can get the game here.

Gameplay

You are presented with a game board which features colored balls, colored holes and laser emitters. By swiping, you activate the lasers pointing the direction you swiped. The lasers push the balls in the direction they fire. The balls retain a little bit of momentum after you shut off the beams, but the collision detection on the beams is pretty generous, so you never get into a position where you hose yourself by having momentum carry your ball slightly too far.

There are 40 levels in the game. So far I’ve been through 20 of them. The core mechanics do not change much. Some removable walls are introduced and a couple of levels have moving walls. Other than that, it’s just slightly more complicated arrangements of the same pieces over and over. A game this simple doesn’t really need more mechanics. I think it was a good design call.

Puzzlebeams has a casual feel. The levels are very short, progress is automatically recorded. I like that the game can be picked up for a minute or two, played and put away. The game play is simple and engaging enough to become addictive. I found myself pulling my phone out of my pocket and playing it every time I was waiting in line for something. I have absolutely no doubt that I will finish all 40 levels.

Visuals

Screenshot_2015-08-07-11-34-54

 

The graphics are very simple, which I like. This game doesn’t try to dress up it’s gameplay with a bunch of overdone graphics, or unnecessary particle effects. 2D sprites over a simple background gives Puzzlebeams a board game-esque feel, which I really enjoyed.

Suggestions

Sell level packs to up the level count. I would pay to extend this game to 80 levels, without question.

Share Button
pong

[Tutorial] 30 Minute Pong

Pong is one of the oldest arcade games there is. Pong was released in 1972 by Atari Games. It’s almost old enough to be my dad. I first played Pong when I was about 8 years old. At that point I was very familiar with NES and SNES games, so I was not very impressed with Pong. I had no historical context and didn’t realize that had it not been for Pong, more or less launching the videogame industry, that my precious NES and SNES might not even exist!

Pong was written by one man named Allan Alcorn, as a training exercise to learn how to make games. I’ve recreated it in GameMaker Studio as a lesson in simple GML programming. I use no drag and drop techniques at all in the recreation. Pong is so simple, that this tutorial can easily be followed in 30 minutes.

You can get the source here, and play a live demo here.

All of the scripting is well commented and should be pretty easy to follow. You’ll notice that each room only has one object. I make an invisible master object and have it initialize everything else where I want it. I do that, because it’s more precise than trying to drag objects around in the room GUI (though that GUI is pretty great if you’re trying to make a platform game).

This is the most complicated piece of code in the entire project. It’s located in the ballControlScript script.

//if the ball hits a paddle, have it bounce off.
//Determine the angle by where the ball hit the paddle.

if(place_meeting(x,y,playerPaddleObject))
{
direction = radtodeg(arctan2(playerPaddleObject.y – playerPaddleObject.y, playerPaddleObject.x – (playerPaddleObject.x – 50)) – arctan2(y – playerPaddleObject.y, x – (playerPaddleObject.x – 50)));
speed++;
audio_play_sound(beep, 10, false);

} else if(place_meeting(x,y,enemyPaddleObject))
{
direction = radtodeg(arctan2(enemyPaddleObject.y – enemyPaddleObject.y, enemyPaddleObject.x – (enemyPaddleObject.x + 50)) – arctan2(y – enemyPaddleObject.y, x – (enemyPaddleObject.x + 50))) + 180;
speed++;
audio_play_sound(beep, 10, false);
}

In the original Pong, the paddle was broken up into 8 sections. Which section the ball hit on the paddle determined what angle it would bounce off at. I was capable of a smoother system. The script above uses some trigonometry tricks to make a triangle between three points. The ball. the center of the paddle and a point 50 units horizontally behind the paddle. I calculated the angle based on that. You can adjust how sharply you can return the ball by making that 50 a smaller number.

Share Button
Grapple title screen

[Review] Grapple – Free Platform Game for Android

General Info

Grapple is a free and ad free platform game by Oakmead apps. You play as a king who has been dethroned. Naked and alone, you’re tossed into sort of an evil forest where you try to get key pieces (and clothing) so that you can reclaim your rightful place on the throne.

Gameplay

Grapple features a variety of puzzle elements and is very reminiscent of Escape Goat. Players control the king with on screen controls. You’ve got three buttons. Left, right and up. The buttons appear at each bottom corner of the screen. I suspect this was to accomodate both people used to having a D-pad on their left and buttons on the right (like an NES controller) and people who are used to using arrow keys with their right hand, and other keys with their left.

Actual gameplay starts out pretty slow, with a series of tutorial levels. Some people dislike tutorial levels, but I’d rather play through them than read a manual (or worse, not get any instruction at all). After you get out of the tutorial heavy levels, the game gets pretty challenging. You work to dodge saw blades, position boxes on buttons and catch platforms to reach a single treasure chest which contains a portion of a key, or an outfit. If you die, there is no real penalty. You just fail the level and have to try again. Levels are timed, both as a fail condition, and as a means of replayability by challenging yourself to beat your previous best time.

Grapple has Google play achievements.

Visuals

grapple gameplay

Grapple game play, not the controls in the bottom corners.

Grapple is a pretty game. It features SNES-like sprites. It seems pretty retro, with the exception of a few gradient backgrounds which are too smooth to be retro, and some particle effects which are beyond most retro systems.

Suggestions

The only thing I’d change about this game, would be to move the controls around a little. It’s way to easy too accidentally jump. This could be solved by moving the jump buttons to the upper corners so it’s impossible to hit a jump button and direction at the same time, on the same side.

Share Button

[Code] Laying the Foundation of the Crypt

Now that I’ve got some placeholder art assets to work with, I can begin working in GameMaker! The first draft of the project is like the first draft of the art. Largely a placeholder/proof of concept. The first draft is completely unpolished and should never be distributed. You shouldn’t even show it to people, unless you have a compelling reason, as it may give them a bad first impression of your game.

First, create a new project in GMS. Then begin importing the art assets. Sprites should be imported as sprites. Tiles should be imported as a background. When you’re done, it should look like this:

Loaded Assets

Loaded Assets

Next, create a room. Name it “testRoom” and leave all the room settings as the default. Then, create the objects. Each sprite we currently have will need it’s own object. Be sure to copy the hierarchy of groups we used with the sprites. Though it isn’t required to actually compile and play the game, it will make the code much more manageable. When you create the object, assign it it’s corresponding sprite.

Assigning a sprite to an object

Assigning a sprite to an object

When you’re done, your workspace will look like this:

Workspace with objects

Workspace with objects

We are now ready to write some of the base code, and set up some simple interactions between objects!

A brief word about naming conventions:

You can name your assets whatever you want. If you’ve ever read a GameMaker book (or enough tutorials online) you probably noticed that my variable naming doesn’t match the naming conventions usually used. For example, my player sprite, would be named “spr_player” had I followed the typical GML convention.

I personally, hate the established naming conventions. The naming seems backwards to me. Why should I care something is a sprite before I know what it’s going to be a sprite of? Plus typing underscores takes more effort than it’s worth. I am a professional Java developer, so I use naming conventions closer to what you’d see in Java. I use camel case and add the type (if I add it) as the last word of the name. You can use whatever convention you want, this is just how I choose to code.

 

Share Button
poster_portrait rev

[Review] Cartesian by Betashark

Cartesian is a laser based puzzle game by Betashark. You play as a mining robot who is trying to rescue three miners from an alien planet. You are armed with a laser that you use to destroy enemies and to unlock doors by lighting up orbs which are the same color as your laser. Hostile enemies appear and try to shoot you with their own lasers. Switching the color of your laser and using mirrors to reflect your beam are core mechanics of Cartesian.

Cartesian gameplay

Cartesian gameplay

Cartesian has a very portal-esque vibe and a casual, light-hearted vibe. Lives are infinite and dying only sends you back to the beginning of the current level. Levels are pretty short so it doesn’t feel like you’ve been set back too badly. Cartesian is well suited to casual or busy players. Cartesian is very friendly to short, interrupted play sessions. Saves are frequent and automatic.

Levels in Cartesian are incredibly well designed. I was amazed with how hard some of them were to solve and at how many different angles and movements were needed to get through. The game is engaging from start to finish, and with a run time of about three hours, it doesn’t overstay it’s welcome.

 

Spaceship

Spaceship

Cartesian feels like it has a very solid core, but it could use a little bit more polish. In particular, I think the game needs a hint button, for when players get badly stuck (I was able to ask the developer when I got stuck, but most users probably will not have that privilege). I’d also like to see a control reference added to the menu you get when you pause.

I would love to see this game Greenlit through Steam. Its better than many of the other platform/puzzle games I’ve seen there.

Share Button