Game Maker Studio Game Project
Rogue like games are role-playing video games that are characterized by a dungeon crawl through randomly generated game levels, turn-based gameplay, tile-based graphics, and permanent death of the player-character.
Objective: Create an rogue like game using game maker
Game Scoring goo.gl/ttPhX5
Requirements:
Create Movement System
Create all graphics
Create 5 loot items
Create 5 sounds
Torch Light effect for player
Create 3 levels of game play
Enemy Path-finding / movement
Create 25 enemies
Create 3 bosses
Create point system
Create battle System
Create character improvement system
Create 3 NPC
Create Dialog System
Create Start Screen
Create High Score System
Create Save/Load Game system
Extra Credits Daily Videos
https://www.youtube.com/watch?v=z06QR-tz1_o&list=PLhyKYa0YJ_5BkTruCmaBBZ8z6cP9KzPiX
Step
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
Directions
Open Game Maker Studio
Click on New and name the project rogue like click create
Change skin to GM8 the default skin of the game is a bad looking green color that is hard to look at so I like to change the skin to the traditional GameMaker 8 look to do this click on file preferences and select GM8 for the skin
now exit out of the game and restart it
Sprites
We are now ready to start creating our game
First we will create three sprites. A character sprite and a block sprite and a monster sprite
Click on the create sprite icon
Picture
Rename the sprite to spr_block
You always want to name sprites with the spr_ prefix
Make your sprites 32 x 32
Block Sprite
Now click on Edit Sprite then file new
Make sure the width and height are both 32 px
Now double click on the checkerboard sprite to go into the image editor fill the sprite with black color and click the green check
the origin of the sprite should be 0 and 0 this will make it easier to place in your room
Draw Sprites
Open the green sprite Click Edit Sprite then double click on it
This will open game makers sprite editor
Lets Check out the tools of the sprite editor
Draw Tool
Spray Paint Tool
Eraser Tool
Color Picker Tool
Line Tool
Polygon Tool
Rectangle Tool
Ellipse Tool
Rounded Rectangle Tool
Selection Tool
Fill Tool
Change Pixel Color Tool
Text Tool
Magic Wand Tool
Select by Spraying Tool
Use the Zoom Tool at the top to zoom into your image and press the grid button to turn on grid
These setting will make it easier to draw our picture
Create player Sprite
Now we want to draw your players sprite so it looks better than a green block
First erase all the green with eraser tool this will leave a checkerboard pattern indicating that the image is transparent
Now add a head for your character I like to use the rounded rectangle tool
Choose black for left color and whatever color you want for character in right
You can use fill button to fill interior of the rectangle at anytime
Now Add eyes, mouth, hair etc
Take your time and do some Internet research to look at other 8 bit sprites
Mine is very simple you can make your more complex if you want.
Notice I left room above the head of my sprite I did this because I want to add the ability to add helmets to my character
The only requirements are to make it fit in a 32 x 32 sprite
Make sure you Modify the Mask of your player sprite and make it Full Image other wise you might be able to walk into walls
This happens when your sprite isn't exactly 32 x 32
Ideas and Resources
http://piq.codeus.net/gallery/
Player Sprite
Now we will make the sprite for you character we will change this later to a better looking sprite so do the same as we did with the block but call this sprite spr_player and change to color to green
You now have two sprites in your sprite resource folder
after you have created your player sprite and any other sprite make sure to modify the mask
The mask controls the collisions of your object and we want them all to be the full 32 x 32 image
Click Modify Mask and select Full Image Rectangle for the settings
Make a right and left version of your sprite
Edit your player sprite make a copy of first frame then edit it then select transform flip make the image face left in frame 0 and right in frame 1
Make sure to un-check apply to all images
Objects
Now create objects for your player and the block and your monster
Click on the Create Object icon
Name the object obj_player and select the player sprite
Click on the Create Object icon
again
Name this object obj_block and select the black block for its sprite
Make the obj_block object solid
You always want to name objects with the obj_ prefix
Make Room
Right Click on the room folder and create a room
Add your player to the room and a monster and add walls around the edges
Remember to make your room faster add a block to each corner and drag it larger to make the room border
Keep the size of the room 1024 x 768
Movement System
The character will be able to move left, right , up and down. And also in the vertical directions
Movement will be controlled by the keyboard keys either numpad and/or other keys
To do this we need to determine if the the key is pressed down
We will create a script called getInput() to do this
This script will be called every step of the game if it is your turn
Before we create the script we will add a few variables to your players object
Add a Create Event and add the following:
turn will keep track of whose turn it is in game player or monster
energy keeps track of speed of turn
keypress is what key you have pressed
dir will keep track of what direction you want you player sprite to face
getInput()
Right click on the script folder and create a script
Add a name comment at the top of the script by typing three backslashes ///
You normally use two // for a comment so add a second comment to describe what is happening in the code
Commenting your code is a best practice
We add a variables to keep track of button is pressed and give it a corresponding value
By using a variable that holds a value this eliminates us having to deal with movement if two keys are pressed at the same time
If you want to use other keys to move your characters you can substitute vk_numpad4, vk_numpad6 and so on with ord(“A”) and ord (“D”) \
In code for WASD it would look like this :
//Get the player's input if keyboard_check(ord('D')){
keypress = 6
}
if keyboard_check(ord('A')){
keypress = 4
}
ord means ordinary key vk stands for virtual key
Note: the dir variable can be used to change the sprite direction of your character to make it look a bit better
Reference
Add script to Player
Open your players object and add a step event
Click the execute code button found in the control tab this will open a code panel
In the code panel type getInput();
This will call or run the script each step
Make Character Move based on keyboard input
Now we will make the character move based on what key you press
Part 1
Add a script and name it playerMove
if you pressed the left key or numpad 4 your player will move left if a the position is empty
This is the logic behind the movement system
Check key pressed
Make sure no object is in the way if you move that direction
Move player that direction
Update monster energy with the turn speed of the monster
Set Turn to 0 which means players turn is over
Set alarm so that you cant spam movement key and get multiple turns with out monsters getting their turns
Note noticed that if you press a diagonal key we must check and move in both x and y directions
Challenge add the rest of the code for all keypress options using the same format to the right
Now update the players Step Event it should look like this now so that the movement script is called after we get the input
Notice the place_empty function it checks if ANY object is at the position you want to move.
Once we put loot and other items that can be picked up we will have to change this function to place_free which will only check objects marked as solid.
Part 2
Grid Movement x,y coordinates
Character Alarm and Draw Events
We have set an alarm in our character but we have not placed it in our player yet
Add a Alarm event 0 add turn = 1; this will allow your player to have a turn again after a short delay
Now add a Draw Event
Notice we use the dir variable to switch the players direction to face left or right
Monster object
Lets get your monster object set up this will be the parent of all other monsters so we will get its movement and turns set up
Add create event set up the turn speedy and energy variables
Add Step Event and set up turn based movement notice it has a new script called monMove we will set that up next
Monster Move Script monMove
Now add a script to make the monster move this will be very similar to the player move script
Monsters will move based on player is location
This script also contains what will become the attack state of the monsters
Monster movement can be done in lots of different ways including using paths
This is a fairly easy one that keeps monsters from running into each other and will chase player down
We can modify it later to give it more AI options
If you want a challenge look at this video series that talks about grid based movement
Video series of Grid based movement
https://www.youtube.com/playlist?list=PLFAuv8mcArkU5QeQv6qec5BKbZYdaWBjb
Turn controller object
We have to create a object to control the turns of the player and the monsters
Create a new object call it obj_turncontroller give it no sprite
Make your player and monster children of this object
Add Create Event to the controller object
Add turn energy and speedy variables
Add a Begin Step Event to the turn controller and keep track of energy of the player and the monsters
Notice we have a global variable we will add that in next step
place this object in your first room
Variables Object
We need an object to initialize all our global variables
create a new object name it obj_variables dont give it a sprite
For now a one variable
this object will be placed in our splash room which we make next
Splash Screen Room
We will now create a splash screen room.
A splash screen is a graphical control element consisting of window containing an image, a logo and the current version of the software. A splash screen usually appears while a game or program is launching.
We will also use it to initialize our global variables.
Global variables can be accessed by any object in the game and they always remain in memory even when you go from room to room.
First lets make a nice logo for our game you can use this online logo generator if you want
Make the logo 400px to 500px wide and add it as a sprite to your game call it spr_logo and center it
Make sure this room is first or on top in the resource list
Add your variable object to this room
Splash Screen Elements
The splash screen will have three visual elements,
Game Name
Sprite of you character and a monster
Text to start game
Create an object and call it obj_start Add a Draw Event and use the code below
Now add a key press event to obj_start you will add the code to move to next room in this event.
Test your game player should move and monster should chase
Create a Design Document for your Game
Now that we have basic movement done its time to think about your game
We do this by creating a Design Document
Use this as a template
Open the design document and make a copy
This will be your brainstorming and reference manual for your game
You can edit it as you go but will need to get everything filled out
This document makes you think about all aspects of your game before you create it
Lets get an idea of what a rogue like game is like click here to play jot down notes and add to your design document
http://munificent.github.io/hauberk/index.html
Original Rogue Like Moria
Design Document Example
https://shroomarts.blogspot.com/2013/01/dweller-roguelike.html
Create Item Sprites
We need items to add to our rooms like coins that drop make at least 5 items make them loot items gems
Make sure that the loot items start with the least expensive item to the most expensive in the sprite sheet
You can make your sprites look better by going to Global Game Settings then Windows then Graphics and unchecking the box Interpolate colors between pixels this blends colors between pixel we dont want that
Loot
Weapons
Helms
Armor
Boots
ideas can be found here you can also Draw your sprites here
You can get ideas here for more sprites
http://minecraft.wikia.com/wiki/List_of_Items#Tools.2FWeapons
Shields
Ranged
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
Create Wall, Floor and Terrain Sprites
When ever you have free time draw sprites to use in your game
The more variety you have the better you game will be
Here are some examples of some sprites you can create for your walls etc
These sprites will be set up in sprite sheets in the background resources so we can add them as tiles instead of as object
This will make your game more efficient
In part 4 we will automatically create rooms so these sprites will be used for boss rooms and NPC shops.
Create Monster Sprites
We need 25 different sprites for monsters use your list from your design document
Here is a site for ideas
https://nethackwiki.com/wiki/Tileset
http://pixeldungeon.wikia.com/wiki/Category:Standard_enemies
Just do a google search for 8 bit sprites or pixel spirtes to see lots of examples
Bosses
Monsters
GUI Panel Room Set Up
Now we will make our GUI this will contain all the game information at a glance
First lets set up our room dimensions go to settings tab and change the width to 3200 px keep the height 768 px
Now click on the views tab select enable the use of views and visible when room starts
Select your player as the object to follow and change the Hbor to 400 and the VBor to 400
GUI Panel Sprite
We are going to put our GUI at the bottom of the room view
The GUI needs to match to width of the room so we will make a sprite 1024 px wide and 128 px in height
I made my sprite black background with a blue border and named it spr_gui
We will use this sprite to draw all the game information on
GUI Object
Now create a GUI object dont give it a sprite but you will put in into your rooms
Add a Draw GUI Event the add a code action
First add comment ///Draw Stats
Then we will draw the spr_gui we use the draw_sprite function
Then we will set the font color to white and the alignment to left
And finally we draw the header text this function has 3 arguments the x,y coordinates and the string you want to draw
Since we are drawing this information on the GUI layer it will stay in place as our character moves to a new location of the room
Try it out
reference
https://docs.yoyogames.com/source/dadiospice/002_reference/drawing/drawing%20text/draw_text.html
Set Up Global Variables
We want to use some global variables that can be used by every object in the room
These will be used in the GUI object to keep track of player information
Create a new object called obj_variables
Add a Create Event and an execute code
Global variables are very useful because they can be used by every object in the game
They are always stored in memory so only make a variable global if you have to
We need to keep track of Hit Points, Max Hit Points, Level, Armor, attack, damage, weapon name, Gold and experience
This object will go in our splash screen room which we will make next
Add Global Variables to your GUI
Now that we have some variables that will change during game play lets have the GUI draw them
This info will be draw left aligned and to the right of the header information
It will look like this
Add States to Monsters
Using states is a very powerful way to control AI of monsters
We will add three states to our monsters
Wander when monster is far away from player
Chase when monster gets close to you
Attack when the monster hits you
We need two variables to do this perception which is the distance that the monster can be away from you before it chases
and state which keeps track of what state the monster is in
Open your monster object add these variables to the Create Event
Chase monMove script
Now we need to edit the monMove() script so we can account for the different states
First we check to see if the distance to the player is greater than perception if it is we set state to "wander"
Next we check if distance to the player is less than perception if it is we set state to "chase"
Third we chick if distance to the player is less than 33 px if it is we set state to "attack"
we add a second condition to the first turn check by adding "chase"
Add "wander" state to monMove() script
Under the chase movement in the script we add this
Wander means the monster will randomly move in one of the 8 direction
So first we choose a number to make it random choose(1,2,3,4,6,7,8,9);
will pick one of the numbers and assign it to a variable called d
d corresponds to the movement keys on the numpad
So we check if monster can move and if so move in that direction
This code looks very similar to player movement.
Test it out and see what happens
You can add debugging code to the draw event of the monster to make sure things are working correctly
This code will draw_self which draws the monster sprite
then draw a circle to show the perception
the draw text for what state the monster is in
If everything is working you can remove the debugging draw code
Items
Lets create our items now
In your design document you made some items that monsters will drop or items that are placed in your room for the player to pick up
We need to think about what category each item will be:
Weapon
Armor
Loot things like gold and gems
For each of these categories we will create one object that will handle all other types
Lets start with loot. Valuables are things like gold and gems. We will keep track of each since they can be used later with NPC's
Create an object and call it obj_loot
Create a sprite that contains all the loot items it will need 5-10 You created these earlier Add each sprite to a single sprite called spr_loot
Notice each subsprite is given a number starting with 0 and all the way up to 4 for 5 total sprites each one will represent an item visually
Now we need to name each in a variable so that it corresponds to the item sprite.
By doing this we only have to create one object instead of 10
Arrange sprites in order of their value keep gold as 0 and diamond as 4 we will use this later
Example:
image 0 is Gold
image 1 is Ruby
image 2 is Sapphire
etc
Create Event in Loot object and Global Variables
Add a create event to your item
Add type = global.type // This will set make the loot drop a certain kind of gem depending upon a chance
The higher the subimage the harder it is to drop so diamonds will only drop 5% of the time
obj_variables this will keep track of global variables in our game
Add a create event and add the following variables
Add an array variable and call it loot[0,0]
each variable is indexed by a number so
loot[0,0] = "Gold"
loot[0,1] = 50 //this is drop rate so 50% of the time gold will drop
loot[0,2] = 0 // How many you have collected
loot[1,0] = "Ruby"
loot[1,1] = 20
loot[1,2] = 0
loot[2,0] = "Sapphire"
loot[2,1] = 15
loot[2,2] = 0
etc
We also set up two other global variables maxloot and global.type
We want the type variable to have the global. in front of it since we are already using a instance variable called type
So each will hold the text name of each item and the % chance it will drop notice that the first item drops the most
We will create a script that will use the weighted drop rate to determine which type of loot is dropped when a monster is killed
type variable will be used to draw the correct subimage in the loot item
You can add this to the create event to make the loot random type=irandom(4)
reference
Draw Event of Loot Object
Add a Draw Event
draw the sprite of the item and use the loot variable to draw the correct sprite
Pick up Loot
We need your player to be able to pick up loot when the player collides with it and keep track of how many of each you have collected
We have already set up the variables to do this in the 2d Array in step 35
reference
https://docs.yoyogames.com/source/dadiospice/002_reference/data%20structures/ds%20grids/index.html
Collision Event in Loot object
Now if the player collides with loot the loot will be picked up and added to inventory
Open you loot object Add a Collision Event with you player
You need to destroy to loot object
Try your Game out see if you can collect loot
Draw Game Events
When something happens in the game we want a game text log to be displayed
This can be done with some clever coding
First we set up a global ds_list to keep track of our text log
A ds_list is a data-structure that stores information sequentially as it is added.
Go to your variables object and add this variable to the create event
global.text = ds_list_create();
Next we need to set up our obj_gui with some variables
Add a create Event to your obj_gui
offset = 0;
length = 7;
reference
https://docs.yoyogames.com/source/dadiospice/002_reference/data%20structures/ds%20lists/
Create
Step Event
Draw Event
Add to Events Log
Now when something happens we want to add this to the ds_list
Things like collecting loot or encountering a monster
Lets start with the loot pickup open the obj_loot and go to the Collision Event with player add this code to add the string which will contain the words:
"You collect a " + the item name you collided with
with the ds_list_add function we can add more text to a string
reference
https://www.reddit.com/r/gamemaker/comments/2o5apu/vertically_scrolling_text_log_wip/
Monster Variables
We want to be able to have lots of different monsters in our game so we will set up variables in a 2D array
We need to make a monster sprite, set up variables for each monster and create a system to randomly pick the monster.
Make the monster sprite go from weakest monster to strongest in the sprite we will set it up so we can add as many monsters as we want just be adding another sprite and the variables for the monster
Open the variables object and add the monster variables
Notice we use a variable i for each different monster so the Rat is indexed by 0 the Cat is indexed by 1 etc. This is a fast way to add more and more monsters.
MONSTER[0,4] = "1d1+0" this string holds the attack rolls, roll damage and bonus damage all in one variable. We will split this apart in the create event of the monster so we can get the value of each.
Monster Create Event
Open your monster object and we will add some variables
It will randomly choose a monster based on your level so you wont see strong monsters until you level up. Different variables will make each monster encounter different.
Remember to mark your monster as solid so it cant move on top of another monster
Test your Game
Place several monsters in your game make sure they spawning different kinds
You can increase your global.level variable to spawn more monsters.
Monster Create Event
Monster Draw Event
Reference
Video series of Grid based movement
https://www.youtube.com/playlist?list=PLFAuv8mcArkU5QeQv6qec5BKbZYdaWBjb
Spine Sprite Creator
https://craftpix.net/freebies/2d-fantasy-woman-warrior-free-sprite-sheets/
Information on rogue like
http://www.roguebasin.com/index.php?title=Articles
Article about Rogue Like game play
http://journal.stuffwithstuff.com/2014/07/15/a-turn-based-game-loop/
RogueLike Dev site not GML
https://www.reddit.com/r/roguelikedev/
Rogue Like made with Game Maker
http://www.naztail.com/game_runelock.html
Rogue Lock Game File
Constant file for Rogue Lock
https://drive.google.com/file/d/1UTxW3vb0jq-OxmqwunzLczDUtPpT8pRK/view?usp=sharing
Another nice Rogue Like