Game Maker Tutorial. Pong. Fall IAT Week 4 Lab. Sprites. Sprites are like little images. You can either import or create/edit these images. We'll create. Game Maker is widely used in UK secondary schools, yet under-researched in that context. .. sample games and following a structured set of video tutorials ( Jones and %20Closing%20the%20Gap%pdf [Accessed 14/06/16]. In this tutorial, you will learn how to create your first game in. Game Maker. The game you will create will be a simple maze game. The object of the game will be .
|Language:||English, Spanish, Dutch|
|Genre:||Business & Career|
|ePub File Size:||27.70 MB|
|PDF File Size:||20.35 MB|
|Distribution:||Free* [*Regsitration Required]|
PDF by Destron. Ver The Complete . This guide is distributed by Game Maker @ Destron Media with permission from the original author. Please do not. Game Maker now has a standard built-in tutorial for beginners. accommodate for the tutorial panel, Game Maker is now default started in full screen mode. related trade dress are trademarks or registered trademarks of John Wiley & Sons, Inc. and may not be used without written permission. GameMaker: Studio is a.
VwolfDog - OpenGameArt. RPGs generally have more than one method to display text, other methods and uses are covered in other elements in this book. A boss battle is generally composed of one or more of the following features: If this was your own game youd probably be loading this data from an INI file see element 40 Saving. There is one new object. The above sets initial values.
Allowing your players to access extra and new levels is one approach. It is possible to create text files that can be downloaded and processed with GameMaker. How you represent your bonus content in text form is up to you, this sections shows a very basic and easy to understand example.
For this example well use a simple grid system. The file that is downloaded from my website in this example looks something like this:. Each letter represents a different object. W is a wall, L is a lake, B is a bush, T is a tree, and P is the player. Blanks are just a space character and indicate there is no object present in that slot.
The file is downloaded asynchronously and saved locally as a text file. This text file is then opened, each line is saved as a string and this is then processed to place instance the required objects in the room. In the Create Event put the following block of code. This shows a message that it is getting the level and sets up an asynchronous event which is an event that takes place in the background and sets a variable change when complete.
A flag and an alarm are set. The alarm will trigger after 10 seconds. This can be done via: The code below will check on the status of the asynchronous event created previously. The status will change from -1 to 0 when it is completed successfully, which will set the flag done to true:.
It does not have a sprite assigned. This has a Create Event with two code blocks. The first will read each line of the file that was created previously, and put it into an array str:. The second block that will read the characters from each line and places instances of appropriate object accordingly:. Set as x in size. Showing level created from a downloaded file.
As well as having a main player character, you may want other controllable items, such as a car or other vehicle, a horse, a bird, a boat, etc.
You could set it up so certain areas can only be traversed by a vehicle, for example an island in the middle of the lake that can only be accessed by boat. Providing some variation in how the player interacts with the game is important, though you should always try make sure you dont veer off from it being an RPG, and step into arcade game-style.
This uses a mass based system, which also prevents the horse getting stuck over other objects. This script prevents objects from getting stuck:. There is a hoof track effect, this will be accomplished by creating instances of this object when the horse is moving. The Create Event, which will prevent any error if global. This needs to be loaded in.
They each have 7 sub images and the origin should be set as the center:. Showing the drivable vehicles element in action. AI is an import aspect of an RPG. Creating characters that have path finding is a basic form of AI. For the purpose of this example, well create a character that moves towards to the players location. The maths behind path finding is quite complex.
Fortunately, this is quite easy to do in GameMakers GML, as it has a number of functions that can be combined to achieve this task. First up a grid is created that covers the room in invisible cells where a path may be considered. Then cells in this grid are flagged where the path finding cannot go. A path start and end point are then set, with the path finding algorithm, creating a path between these two points, whilst avoiding cells that it cannot go through.
The Create Event for this object is shown below. First this creates a grid that will be used for path finding. The final part then creates a path between itself and the player, then starts this path.
The Step Event has two blocks. The first block checks if the end of the path is reached, if it is, it creates a new path between itself and the player object, and starts moving along this path:. Alternatively you could use the code, shown below in another event, such as an Alarm that triggers every so many seconds:.
Finally there is a Draw Event with the following code, which draws the path and the enemy. You could omit this whole event, but I have left it in for testing and visualization purposes:. Audio, both sound and music, can add a lot to a game. When used sparingly and for emphasis, the result can be an immersive experience for the player.
However, it is important not to overdo sound effects. Too much, too often can be overkill and detract from the overall experience. This example demonstrates how to use different sounds when walking on different things such as water, leaves, wood and solid floors.
Its a very simple method: Set an alarm. If the player is moving the alarm triggers, check what they are walking on and play the appropriate sound. Then reset the alarm. Using an alarm prevents constant playing of the walking sound.
Playing once every second is enough to give the player enough feedback to let them know the surface they are walking on has changed. This code deals with setting the correct sound effect and the playing of the audio if the player is moving:. The origin of the sprites for the above 4 objects is not important, either 0,0 or 32,32 will suffice.
The sound resources youll need to load in are: You may want to provide more than one sentence at a time, which could prove problematic. Each message is shown, deleted, then if there is another message in the queue it will show that. Some additional objects are added to show how to use this in practice. As messages are queued easily through a script you can add them at any time, it doesnt have to be through a collision event. Create this object. There is no code or sprite for this.
These messages are shown as examples, pressing the keys wont actually do anything. This has been omitted to keep it easy to understand.
Showing sprite and parent assigned. Next there is the object that will show the messages, if any. The Create Event which sets the required starting values is:.
The Step Event checks the ds list for any content: It does this by drawing an appropriately sized background and places the text over it:. The player needs access to a whole menagerie of information, for example:. A HUD is usually a non-interactive element of a game, though inventory and spells are often selectable and useable. The HUD is usually drawn separate from the view. In GameMaker: Studio this is relatively easy as you can draw a GUI above and independent from the main game view.
The example for this element draws the 7 elements listed above. In your own game you may choose to display more or less: In fact, this is never drawn in Draw Event, but present so you place in the room at the correct position.
This routine utilizes extra code for example purposes, which is indicated in the comments of the applicable code. Your actual game would omit these additions. This is the Draw Event code, in which we simply put a comment line to turn off default drawing:. You can use the keyboard to change the variable for testing, and show and hide the spells and inventory popups. An RPG must have some form of inventory system. Collecting items is one of the main focuses for a player. For example, in the RPG outlined in the introduction of this book, the player needs to collect items and use them appropriately to get cash so she can get off of the island she has been marooned on.
Acquired items are generally stored visually, so the player can see what items they have. The example shown is very basic, but simple enough to understand and expand upon. The inventory has a number of slots for placing items in, which the player can then drag around and place into other slots. This example allows the player to collide with an instances of an object and pick it up using a keypress, if there is a free slot available. Each slot holds a value of -1 if empty, otherwise a number that represents the object to be shown.
We use four items. Each item has a mini sprite as a sub image that is shown on the inventory. Adding additional items is pretty straight forward. As an example, in-game items that can be picked up will be generated randomly: Next is a sprite that will hold the images used in the inventory.
This is also 32x32 with the origin set as the center. It consists of 5 sub images, but well only be using sub images 1 through 4, so 0 is not used, but needs to be present. This is 64x64 in size and the origin is the center. The final sprite is used as a background when the inventory is visible. Its size is x The origin is 0,0. This code will increase the size of the inventory global.
In your own game, you may want to provide the bag as a reward for completing something in-game, or have it available for purchase in the shop. This value is used to show the items sub image and is also used when its being picked up. This code checks for a keypress and checks whether there is an empty slot.
There is a more thorough inventory example in the element Usable Items. There are five scripts. These scripts work together to allow you to add items to the inventory and to click and drag items. This script will check if a slot is available.
If it is it will add it and return true, otherwise false is returned:. It has a Step Event which toggles global. This variable is used to show or hide the inventory:. Providing info to the player using various messages, popup message, spoken sentences etc. However, too much can be overkill.
Another method worth considering is changing the colour of the player sprite. Dont worry you wont need to make a new set of sprites as GameMaker: Studio has a colour blend function.
You could use this method to convey information to the player. In this example it will show invincibility for the player by flashing red. It will also draw a bar above the player to show how much invincibility the player has remaining, which will replenish over time.
An Alarm Event has been added with the following code, which replenishes the timer once every 20 steps and keeps it at a maximum value of An additional block has been added to the Step Event. The last line turns off invincibility if there is no timer left:. And finally a Draw Event has been added, which draws the players sprite and coloured bars showing available invincibility:.
Mini Quests that the player must complete, either to progress the story, unlock something, or to get a reward provide variety within your game. This uses two sprites. If under a distance of it will draw inside the map:. This is the item that the player needs to collect in their mini quest. The Create Event sets everything up, such as the sprite index and image speed so the sub image 0 is shown.
This is used for showing a timer that displays how much time the player has to complete their quest. It will also be used as a control object to check whether the player has completed the quest in time or the timer has run out. An RPG generally has one large playfield, usually outside, and a number of smaller locations for example inside buildings. Youll need some system to transport from one room to another, and then back again. One method is to use separate objects to do this.
When the player collides with the object they are taken to the target location. At this point youre probably wondering how the rooms remember what has already happened in them, whats been collected and what not.
Fortunately GameMaker: Studio allows you to set rooms as persistent. You can therefore move back and forth between rooms without having to save and load hugh amounts of data. As the rooms remember the x and y positions of all objects, including the player, well use a little trick.
When the player collides with a door that will take them to another room, we will first move the player away from the door before going to the target room. This prevents infinite looping between target rooms. This is assigned to two objects: There is no code for either of this objects. You can set the origin as Center for this, and there is no code required. Changing the y position is very important it ensures that when you come back to this room the player object is not already touching the door.
Failure to make this position change would send you straight back the target room:. Load that in now as a background. Showing background assign and objects added. Showing how to set the room as persistent. Lastly well create a splash screen room to set some initial data. If this was your own game youd set up variables or load a save file instead.
This will set the initial value of global. In the resource tree move this room so that it is the first in the rooms section, so that it runs first. Studio has a number of audio effects.
One of these allows for positional audio. This plays audio at a volume depending on the distance and direction between an audio emitter and an audio listener.
This plays more through the left channel or right channel, depending on the position. If you have surround sound speakers youll also get front and back audio. This example is set up to play the audio louder the closer you get to an object, and fade off at a certain distance, leaving just a gentle ambient sound.
There is one change. This sprite has 50 sub images. Set the origin as the center. The Create Event code again plays audio on a loop:. There will be places that you may not want your player to go, for example a bottomless pit, or lava. What should you do when the player collides with these?
One answer is a respawn point. You would have a variable for both the x and y positions for a respawn point, and just move the player to that location. This system is pretty simple to put into place. You have a respawn point: Upon collision with this you store the location of the player as separate variables. Upon dying you move the player back to this position.
Where you place these respawn flags is somewhat important. Before and after a difficult point is a good place. This addition makes an initial starting point for respawning:. This element is almost a clone of the Inventory element, but with some distinct changes. As such the whole process is shown. So, your player spends plenty of time filling up their inventory with various items.
It would be nice to give them something to do with them. Before programming for something like this, you should already have noted down some of the items that the player will need to collect and how they will be used. Its OK to tweak things here and there if you come up with more ideas. This is used to identify whether objects can be picked and held in the inventory.
This example shows the use of three keys and three matching chests, each set as a different colour. You can pick up the keys with P and then left click and drag to use them: This element also includes the addition of being able to pick up a new item when the inventory is full. The new item will replace that which is in slot 0. This sprite is 64x64 in size, has a solid border and a transparent middle. In this example its 18x64 in size and consists of 4 sub images.
The first subimage, index 0 is not used. The origin is set as the center. This sprite is x This will draw the background of the inventory. The origin is set as 0,0. Next up are three key sprites, each of which is a different colour. These are the items that the player will pick up or put down.
The size of each is 23x64 with the origin as the center.
It is 64x43 in size and the origin is the center. These chests are the items that the player will interact with: This sprite will be applied to an object, so we have something to detect a collision between a key and a chest. If it is, it will add the item and return true, otherwise false is returned:. This will be used to allow items to be picked up and placed in the inventory, if there is room. This will add the picked up item to the next empty slot if available.
If not available it will place the item in slot 0 into the room and pick up the new item and put that in slot 0 instead:. This has the Create Event code:.
This is how were linking them up as useable items. This will allow the player to move an item from the inventory around the room. In your games, you could do something completely different: The Draw Event code is:. There may be quests or interactions that require the use of weapons. This element shows a basic example. It allows you to use a weapon - in this example it just reduces the weapon count, and collect crates to increase the weapon count. The current weapon in use can be selected by scrolling the middle mouse button up and down.
It doesnt have to be limited to just weapons, it could be used with element 31 Treasure hunting. The Create Event code is below. This will set up the starting values of the data used in this element. If this was your own game, youd probably load this from an ini file:. The Step Event code, which allows selecting the weapon by scrolling the middle mouse button, is:.
Effects such as this can add a lot to a game, though use them sparingly too many visual effects can be annoying for the player. This example allows for the destruction of solid blocks, it will also randomly 1 in 3 chance create a treasure chest. A great way of using this approach is to limit how many times the player can use a pick to destroy blocks.
You could award picks at other points in the game, so the player needs to come back to the destroy blocks section to destroy blocks. A nice twist would be a maze of some kind that uses solid and destroyable blocks, perhaps with the aim the player should find the loot hidden within that maze. Other ideas would be buildings that the player needs to enter but which are surrounded by blocks, which the player has to destroy to gain access.
However you decide to use this method, its bound to make an important contribution to the game play. Next is the Step Event code, which will test the damage, and -if destroyed- will create treasure chest with a 1 in 3 chance. It also sets the image index to match the damage:. The Step Event has an additional code block, which will damage the block in the direction the player is pointing if the player has any picks:.
There will be times when you want some variation in player movement. One thing you can add is dashing. This could be used by a player to escape tricky situations, such as avoiding a marauding enemy. One approach is to use a local variable that reduces when dashing is used, and slowly replenishes over time.
That is exactly what this element does: It goes down when used and up slowly over time. A simple graphical star effect is displayed when in use. It will also keep it at a maximum value of There is an additional code block in the Step Event, which takes care of the dashing movement:.
Using an array that stores the quest and whether it is completed or not is one approach. By using a global array this data can accessed, used and changed as needed. This also allows for easy saving and loading of this data as and when required. This example demonstrates as a basic method for four quests, though the priniciple would remain the same whether it would be ten or a hundred.
In this example keypresses are used to toggle between completeted true and not completed false. You could of course change this at any point within your game, for example when a puzzle game is completed.
This approach could also be used for other things in your game, for example whether a boss has been defeated or not. The Create Event code, which sets up the variables needed. If this was your own game youd probably be loading this data from an INI file see element 40 Saving. The Step Event code for testing is below. In your own game you would probably have other triggers instead of key presses:.
Finally there is the Draw Event code, which, like the above is for testing. In your own game you may wish to display the information in your HUD or as a pop up window:.
This could be used for example, to make a bridge over some water to an island that would otherwise be inaccessible to the player. This could be combined with a shop where the player has to purchase the road sections using their well earned loot. Systems such as this provide more variation for the player, and to some extent force the player to plan ahead as to what theyll do with their cash. This element is pretty simple.
It allows placing of road instances in empty places, which then link up to other road instances next to it using a bit of cool maths to generate the correct road instance shape, and updating those around it as needed.
If you are using the above example allowing the player to reach an otherwise inaccessible location, ensure that their reward is worth their time, effort and loot: The updated code is:. The Create Event code for this object is:. It is very important to get the correct order:. Next up for this object is a Room Start Event.
Showing where to find room start event. Next up, for the same object is a User Defined 0 Event. This event can also be found in the Other tab. Character progression is the development of player characteristics as the player progresses through the game. There can be positive traits, ie kindness and charisma, and negative ones such as evilness.
These traits can be updated depending on actions performed within the game. You could also base interactions depending on the current values of these traits.
This element draws the traits on screen, with buttons to change values. This provides a number of points the player can assign, you could of course change these values based on anything that the player does within the game. This uses a simple approach of using a 2D array to hold the data. There are other ways of doing this, but this serves as a great introduction.
It has two sub-images, the first is solid yellow and the second is solid red, the origin is center. Image 0 is green, image 1 is red, the origin for this is center. Finally for this object, a Draw Event which displays the values visually, and whether an upgrade is available or not:.
There are two rooms: This is usually because one character may be better than another at something more than another character, for example:. Well make this object able to destroy trees, so first well make the tree object.
Keeping track of how long a player plays your game, and providing this information is used in a number of games. Usually time within the game will progress faster than in the real world. This example overlays the room with a coloured rectangle with a set alpha depending on the time of day. This is a simple approach, if you want something visually more stunning you should look into the use of shaders. Add a Draw GUI Event with the code, which will draw the time as text and set the alpha value depending on the time of day:.
This example is a classic matching puzzle game, using pirate themed sprites. The aim is to find all matching pairs. If this was your own game, upon completion you would reward your player, possibly with gold or treasure chests. You may wish to allow the player to revisit this mini-game multiple times.
However, it would be a good idea to perhaps limit how often the player can do this. This is just one puzzle idea. You are of course free to add any number mini-games, but as mentioned keep within the main theme of your game.
This example does the coding within one object. This may be confusing as the coding is quite in-depth. There are comments throughout explaining what each part of the code does. This example allows the player to dig for treasure. When they dig they will be provided with information on the distance to the nearest buried treasure. In this example the player has a limited number of digs available. You could have this buried treasure scattered around the game world, that the player can hunt for if they have digs available.
Little in-game challenges such as this give life and meaning to your game. Your players will thank you if you have more than one such challenge in your game. The origin of all of these is center. It has an Alarm Event with the code, which is used to trigger showing info to nearest treasure:.
It has a Step Event with the code which will give the distance to the nearest treasure if it exists:. Finally there is a Draw Event with the following code, which draws itself and the distance to the nearest treasure until Alarm triggers:. This system uses cards that the player must choose a stat from and try to beat the opposing player computer. Diversity in battle styles can contribute a lot to the overall playability of your game. Variation is the key.
For this example the stats are generated randomly: This list is then shuffled and the player and compuer are each dealt 10 cards. The players current card and stats are displayed, the player should choose a value that they think will beat the computers card. Points are then awarded accordingly, depending on whether the player wins, the computer wins, or it is a draw.
This object sets up the data for this game. It has the Create Event code:. That is all for this object and room. This sprite has 20 subimages, the sub- image 0 is not used and is in solid red. The origin should be set as the center. The order is not important:. Graphical effects, as with audio effects, when not over-used, can make the game more fun to play and make it look more professional.
Little things such as foot-prints, animals that wander around, and weather effects can all contribute to the overall feel of your game. This element provides a basic effect, but feel free to experiment and diversify within your own game. It has the Create Event:.
The Create Event for this object is:. It has a Create Event with the code:. Here is an example of another mini-game, that kind of fits in with the stuck-on-the-island theme. This is not like any other mini-game in this project, so avoids the problem of repetition.
Having distinct mini-games is the way to go. The aim of this is game is simple enough: Fish of various size and types are created. The bigger the fish the bigger the score for catching it. You could add additional element like mines, or randomly place treasure chests on the sea bed.
For this game you need to navigate a ship around a course without hitting anything. The example is only a small one. Simple games like these that the player can participate in will extend the life of your game and allow the them to take a break from the usual RPG mechanics.
Next up well create the object the player must find: It makes use of different sprites for each of 8 directions, so load them in now. All of them need Precise collision checking and an orgin of center.
They are:. It has the Create Event code: One way to add variety and randomness is rollable dice. Most RPGs will have some kind of non-determined randomness: This example uses two 6 sided dice, you could increase the dice sides or number of dice to suit your need. This element combines a mini-game and dual zooming.
This dual zooming will keep both the player and enemy within view, zooming in and out depending on how close they are to each other. The enemy has some basic AI: This is achieved using paths. It will drop at the end of paths and randomly when moving.
Some clever maths is used to calculate a point between the player and enemy and to calculate the amount of zoom required to keep both in view. This zooming approach could be used in other ways, where you would like to keep two objects in view at one time.
For example for a maze with treasure in the middle, keeping the player and treasure both in view at once.
The origin needs be set as center. The Step Event code for this object is:. It is important to get the directions correct. The origin should be the center. The code for this is event is:. This has the Step Event code:. That is all for this room and object. Showing the room set up for this element. By now you should be aware that the aim of the game is to collect enough treasure so you can get off of the island. If this was within your own game, this would be a great time to have another cut-scene sequence.
Finishing the story off is important. You may want to end it that she wakes up in bed and it was all a bad dream, or something with more thought and imagination.
Your game will need to hold, save and load a lot of data. One easy to use method is with INI files. In this example well load and save the following: The INI file would look something like:. This will load any saved data, or set default values if no save file is present e.
This will set global. The second line will load the appropriate data held in the INI file. If the section and key are not present, it will set the default value in this case 4. The origin in center. It also has two sub-images and the origin as center. This object has two sub-images, as shown in Figure A different sub-image will be displayed depending on whether an upgrade is avaible or not. The Draw Event code will draw the appropriate text that was created in the splash room object.
It will also draw red or yellow rectangles depending on the stats:. There are two rooms. A step-by-step guide to making 40 commonly used RPG elements. Includes screenshots and coding. You're free to use the code in your own projects. Flag for inappropriate content. Related titles. GameMaker Studio Programming Challenges Game Maker Book 1 tutorial coding all items and one example also. Unity 5. Jump to Page. Search inside document. Main Artwork: KennyLand Girl Pirate: Background - Clipartkid.
VwolfDog - OpenGameArt. Retimer - OpensGameArt. Osmic - OpenGameArt. HebronTheatre- FreeSound. InspectorJ - FreeSound. Com Wooden Pirate Ship: Planning is good for the following reasons: It allows you to have: Some time away from coding on your computer A break from having to think about your game The option of reviewing your ideas At any point in the planning process, feel free to throw your notes into the nearest bin, whether one page or all your notes.
The rest of this introduction covers the main 20 points to consider when making an RPG. The code used in this book is designed so: Someone relatively new to GML can understand it Its clear and logical Otherwise complex code appears clear and easily read Its broken into understandable bite-size blocks You can easily re-use in your projects It doesnt take a PhD to understand It looks good in print Coding comments are used to explain what each section does, allowing a newbie to grasp the basics and understand what is going on.
This can be achieved through: Consider things such as: Appearance Voice if they speak, which they probably will in an RPG Quirks Special things that make your character unique e. Movement How the player is moved and whether 4 or 8 directions, or Animation Pre-rendered, made from separate parts, 3d rendered in real-time or just regular sprites.
Customizable Clothing e. Design and draw everything yourself 2. Commission an artist to do it 3. For this example the main character will be a blue bearded pirate. As for the main character, quirks are important. For the main character, it could be: A blue beard A wooden leg A hook Random voices and sounds The parrot could fly randomly around the level and on collision with the parrot the player has to play a mini game and win before proceeding.
As mentioned in a few place in this introduction, keep to the theme. Providing a variety different ways to collect gold coins is the key here, for example: Each enemy should have a different battle game with its own mechanics, to create variety. The following objects would be suited for such a pirate theme: Anchors Old wooden huts Wooden signs Barrels Palm trees Flying birds Sound effects will all help create an immersive environment for the player, such as: Birds Waves from the sea Footstep sounds on different surfaces Themed locations could include: Each has its own positives and negatives: Each has its own benefits and draw-backs.
Other major events could also warrant a cut-scene; or example: Killing a boss enemy Player finding their first gold coin When first visiting the in-game shop Conversations between player and other characters Way of explaining complex instructions or tasks A note of caution: That said, when done well and at the right times, cut-scenes can add a lot to your games.
I have a great idea! Lets make sound effects for everything: These days, not so much Overusing sound effects is an easy way to alienate your players. Generally speaking: Isometric games look pretty cool, but can be a pain to program Top-down looks OK, and is quite easy to program for Semi-top looks good, easy to program and allows you to provide more info than a top- down As you can see from the sketches, in the top-down view you can see the roof of a building, but are unable to tell what type of building it is.
For the purpose of this book, the project will be using semi-top, for the following reasons: Tonnes of artwork in this style are available, both free and paid Creating your own graphics in this style requires only a gentle learning curve Movement and object interaction is fairly simple when compared with isometric The maths level required for interactions and calculations is reasonably low Low CPU overhead hey GameMaker: Studio is great for 2D games Player can easily understand what they see on-screen No transparency effects needed e.
The main ones used are: Boss Battles - Which I wont discuss here as it is mentioned in a previous section Turn-Based Characters take turns attacking each other One-On-One Full-on fighting in real time, like old-school arcade games Random Player just clicks and hopes Avoidance Having to survive an amount of time or reaching a goal without hitting an enemy JPRG Japanese RPG Turn-based variation Card-Based Play a card and hope it beats the enemys choice Hybrid A combination of one or more of the above Some general guidance for battle systems: By dying, completing certain objectives or finishing the story Personally I think the main goal of an RPG should be clear from the onset.
Mainly the character will be walking, whether on solid ground, grass, or through puddles. You can also add variety by offering some alternatives. Parrot You catch a parrot that will fly you to isolated locations not accessible by foot.
Swimming The ability to cross a vast river to, again, otherwise inaccessible locations. For the purpose of the game made with this book well be using the following: Text On Scroll Used during cut-scenes to convey information.
Pop Up Text Box When conversing with other characters in game. For example: Why is there no medicine in the jungle?
Because the parrots eat them all. Mental Well-being Strength, which maybe reduced during physical exertion and replenished with rest Designing the layout for an HUD able to display all this information is a skill unto itself. Other things that you may want to keep track of, perhaps as a pop-up so as not to over- crowd the HUD: For the game designed in this book the main objects are: Keys Can unlock areas and help advance the story. Battle Skills Certain objects add battle skills. Sword Allows player to participate in battles Satchel A bag that, when collected, allows player to carry more items Bird Seed Allows a player to trap a parrot for hidden areas An RPG is likely to have tens, if not hundreds of separate items.
Its how you relate the game back to the player. Destroy Buildings - Use a trebuchet to throw rocks at a building. Swimming Swim in the sea collecting seaweed, but avoiding fish. Maze Find your way out of a maze in a set time limit. Lock-Picking Pick a lock using the mathematical clues provided. Matching Game Match the cards. Rowing Race Race against a pirate over a water based course.
TapTo Music A variation on the tap-the-button-to-the-music style game. Match 3 Swap over objects to get three in a row As you can see, mini games are really only limited by your imagination: You may want to limit how often a player can play each mini-game. Other quirks could include: Uses mundane objects as toys would make good cutscenes. Dances to music if not moved for a time. Make it so this can only be done when not a mini-game or quest I prefer the use an INI system to save data.
There is a whole chapter dedicated to saving data in the main body of the book. Basically for an RPG, youll need to store: The first block detects key press and updates the values accordingly: It checks whether the player is moving or not and sets appropriate sprite: Selecting four sub-images Repeat the process for the other image sets: Text will be displayed a letter at a time when the audio plays - known as typewriter-effect.
Upon collision a random sentence will be chosen and displayed relative to the object. For this example Ive done 9 sentences, you can of course use more or less. Keeping the control in the colliding object will allow for more variation, for example you may want to: This is shown in Figure below: The code is: I've never seen a mushroom before!
It will also play the accompanying audio file: This battle system is loosely based on Rock, Paper, Scissor except four options are used: Feel free to expand upon this basic battle system. You could add: This will allow the player to choose which play to make by pressing keys 1 through 4: This value is then used to set the string for the computers play: It will draw the player and computer sprites, the move each made and the results: This code is in the Create Event: This is used in a game over room to show that the player has won: Like the above code, this will show that the computer won: Next load in the following sprites: Delete any rooms present.
A boss battle is generally composed of one or more of the following features: It is usually a one on one battle, sometimes with minions The boss moves in some kind of path, sequence, or pattern Has one or more system of attack Needs to be beaten for the game to progress Has a vulnerability that the player must use Are more difficult to defeat than other enemies More formidable than other characters: Try to keep the elements used in any battle the same as the main game theme.
The Step Event destroys the instance as it leaves the room: It has a Step Event with the code: The Create Event, which sets it moving and sets up a sine wave is: This event also destroys the instance as it leaves the room: The Create Event is: The Create Event code is: When done. Have a look online for free RPG games. Although this book only deals with a couple of battle systems. Scissor — except four options are used: This would mean over many games.
This book covers a couple of battle systems. A battle system is where the player takes on another main character and has a fight with them.
How you reward your player is up to you. You could add: First to 5 successful plays wins. Ground beats Ice. The player can select their choice of play using the appropriate key. The aim of the game in this book is to acquire 1.
Feel free to expand upon this basic battle system. This battle system is loosely based on Rock. This could be achieved in a number of ways. Either the player wins.
Fire beats Ground. Players of your game will thank you if you have lots of variations they can play. The computer then makes a random move. Now create an object. This will allow the player to choose which play to make by pressing keys 1 through 4: First create an object. And finally in a Step Event put the following.
This code sets up the initial variables needed. This is all for this object. The code above detects a keypress. There is no sprite for this object. It will draw the player and computer sprites. Next create another object. That is all for this object. In the Create Event the following code that will choose a random play between 1 and 4 inclusive. Next create an object. It checks each combination. Not the most compact or the best coding. This code is in the Create Event: The final few lines checks whether either has reached the target and goes to the appropriate room.
That is all for this object: Next create a font. Next create 3 sounds and set as the following. Next load in the following sprites: Like the above code. Create a room. That is all for this room. Delete any rooms present. There are literally hundreds of Boss V player battle methods that can be used: I managed to acquire some pirate voices.
A boss battle is generally composed of one or more of the following features: I have added a few too many. The controls will be simple: The dropped bombs of both sizes will damage the player. Occasionally actually every 10 seconds. Try to keep the elements used in any battle the same as the main game theme. The origin should be set as center. The Step Event destroys the instance as it leaves the room: This object has a sprite.
The Step Event applies and updates the sin wave. The Create Event. It has a Step Event with the code: This event also destroys the instance as it leaves the room: Both of these sprites need Precise collision checking checked in Sprite Properties and have the origin set as center.
This makes use of 2 sprite sheets. Collisions with instances have different outcomes. The Create Event code is: This character can move left and right keeping inside room and fire swords towards the enemy. Step Event: The Create Event is: The first block in the Step Event is the following. The code for the Alarm which resets being able to shoot a sword is: It will allow the player to move left or right to the next slot.
This sets the starting values. If the player collides with it they will lose 1 health point. There are four collision events. This object is the boss enemy that the player must beat.
On collision the player will lose 5 hp points. The Create Event code. It moves left and right. This enemy will get faster over time. The Alarm Event for the enemy consists of three blocks. The first. And the third and final block for the Alarm Event which deals with movement is: Next is a Alarm Event.
It has a Step Event with two code blocks. The final alarm event is Alarm Event. The first makes the pirate move to the next slot location: The code for this is: This displays the player and enemy health as bars and checks if either win.
Avoid Bombs". Shoot Enemy when jumping Collect Fruit. The Create Event which sets an alarm is: And the Draw Event code: A number of sounds are used. These are the resources folder. Each room has a height of and a width of This game uses two fonts: The Alarm Event code: The approach shown in this section is basic. As well as providing dialogue.
The flow of conversation therefore can be very dynamic and engaging. This branching is pretty logical. I strongly suggest using a chart or other notes when making your own dialogue system. When interacting with other characters in-game you want to be able to hold up a decent conversation. For each level you add. For example if the character asks: The example provides for two options for each question. The text is dialohgue is simply drawn inside boxes: I have left it out for clarity.
An interactive dialogue system is an essential part of an RPG. Basing the dialogue on the responses that the player makes is the way to go. Showing flowchart of conversation As you can see. For clarity a positive choice first option divides to left and a negative choice second option divides to right.
I Love Cheese. Sing Me A Shanty Song. Would You Like Some Cheese? I'm In Great Mood. This sets up an array for the data.
I'm Sad. I'd Rather You Didn't. It only has a Create Event: It has one instance in it. I'll Pass. Hmm Rum. Sounds Good! I Have Enough Already. Want Some Rum? I'm After Gold. I Don't Drink. I Prefer Brie.
Fishing Is Boring. Want To Go Fishing? I'll Get My Rod. Your Choice. The first element. The third element. The second element. It has a Step Event with the following code: The fourth element. That is all for this object and room. You can also offer no options. You can offer one option. This is then repeated for the other elements. By setting the text to "". The fifth element. The Draw Event code. The click part will update global.
There are two button objects. There are a few changes. Also the Draw Event has changed so that it draws the text for the second option: There are also two fonts. The images are in downloadable resources. Having a shop for perishable items. This is displayed using a parent object that gets all the info from a global array.
A shop is one ideal solution. The programming technique and GML code used in this element is not the most compact. In addition there is a buy button.. The sketch shows the data as it is used in the array.
Your player is going to spend a lot of time acquiring loot. This example gives the player four items to buy: You can keep the origin as 0. This sets up the array needed for the shop. As noted below. The next object. This item is made from two sprites. The Step Event code. Its origin is 0. Create a new room.
Create an object for this. This object has a depth of 10 and will be used as a background for the shop keeper object. Load in and assign the appropriate sprites from the resources.
The Draw Event code is: This is a parent object that draws the data from the array. Its origin set as center. This example uses just 4 items. This parent object is a button that is clickable when an item is available to buy. It has two sub images, image 0 in green and image 1 in red. Green will show when available and red when not available. The Step Event code, sets which sub image to show. The first conditional checks whether the player has enough cash the second whether the player has a full allocation of items:.
And the Left Mouse Button Pressed Event, will first check whether the player is maxed out on that item, then check if the player has enough cash, and update the item count and available cash, playing the appropriate audio as required:.
The depth of each is A cut scene is generally a non-interactive animation providing information that progresses the story. These are normally shown at the start and end of a game, with additional cut scenes in- game as needed.
For example, this could include:. Cut scenes vary from game to game: For the purposes of this book, the example will use 2D animation. This will consist of a collection of 11 separate scenes, each having its own room.
The method used is pretty basic, but demonstrates the rudimentary elements needed to make a cut scene. It should be noted that over-use of cut scenes is a big no-no. Cut scenes stop the player from playing the game, albeit for a short time. Always consider that the player wants to play, not spend time watching poorly made cut scenes.
However, when used sparingly and at the right times, a cut scene can contribute a lot to your game. And the Step Event code: Additional objects used are: A bubble effect object. The fish Create Event code is: The code above allows the cloud to wrap the room. The Step Event is: The above sets initial values. There is a fish object. The Draw Event is: This is added as other elements may have a lower alpha value.
This fish swims from right to left. To add a bit of movement. A sine wave is used to make it wobble. There is no code for this object. Obviously the code will change the sprite every alarm event and play a sound. Its Alarm Event: The Step Event code for this object is: The Create Event code for this object is: It has the Create Event code: The Step Event code is: This origin should be set at And its Step Event: This is the point the windmill sails will rotate on.
There is no code for this. The origin should be the middle of the roof at The default origin 0. This string is shown after a short pause. It sets destroy to false.
The above block will set the text and add a letter at a time. Basically the object is created and a string sent to it. Alarm Event: The Create Event: As you can see above. Base code The cut scenes display text on the screen. The variable fading will used to change the alpha value i. Draw GUI Event. Alarm Event: This will make it fade out gradually. Most of the control objects for the scene follow the example above.
The full code for each is shown for each scene for clarity purposes. When fading is less than 0. This sets destroy to true. This room has a background. Alarm Event code is: This object has an Alarm Event.
This sets up the view and the initial alarm. An Alarm Event sets the other alarms and plays the audio music for the scene. Up High On A Hill. The Step Event code: This alarm is then used to spawn alarms 0 and 1. This increases the view size.
The view is set in the room properties to foloow the windmill object. The Alarm Event code is: The view is set to follow this sun object. This is basically the same as scene 1. The Alarm Event is: The Alarm Event: There are no additional objects in this scene. This view pans across the screen. This is a static view with a moving fish and boat. And the Step Event code is: The code for the Alarm Event is: Finally for this object is the Step Event code: In this scene a boat moves across the screen bobs about.
It consists of a moving ocean. There are no additional objects. As you can see. The Create Event for this control object. And the Step Event: Alarm Event is: A Big Strong Storm Came. There is no Step Event on this object. The Alarm Event is: An Alarm Event is also used. This scene consists of lightning sprite images and loud audio. This scene is an underwater scene with a fish and submarine. The Alarm Event is: And finally the Step Event code is: Except For The Moon.
Objects in this room are just static objects. This scene zooms out from the moon to show a dark night scene with the ocean below. Its Create Event code is: It is just a basic pan. Finally the Step Event code is: Scene 11 The final scene is a static image. This element employs a trick to make sure that the player and in-game objects are drawn in the correct place. Making sure things behave like they would in the real world is another matter. Keeping things looking good visually is important in any game.
This technique also creates an additional object that is used to prevent the player moving through the base of an object. It makes use of the gamebase GMZ file. This is done by changing the depth of the player and in-game objects relative to the y-position on screen. The origin should be set as Instances of this object will be placed at certain points in the room and the main player object will be programmed to prevent it walking through instances of this object. First up create a sprite.
This text file is then opened. W is a wall. L is a lake. It is possible to create text files that can be downloaded and processed with GameMaker.
The file that is downloaded from my website in this example looks something like this: The file is downloaded asynchronously and saved locally as a text file. B is a bush. You could allow access and use bonus content when: Adding longevity to your games is important. How you represent your bonus content in text form is up to you. T is a tree. Blanks are just a space character and indicate there is no object present in that slot.
Allowing your players to access extra and new levels is one approach. In an Alarm Event put the following. The alarm will trigger after 10 seconds.
A flag and an alarm are set. Open the GameBase and create four objects. In the Create Event put the following block of code. This shows a message that it is getting the level and sets up an asynchronous event which is an event that takes place in the background and sets a variable change when complete.
The status will change from -1 to 0 when it is completed successfully. In a Step Event put the following. The code below will check on the status of the asynchronous event created previously. It does not have a sprite assigned. This can be done via: The first will read each line of the file that was created previously. This has a Create Event with two code blocks. When run and download is completed. That is all for this element. Set as x in size. Providing some variation in how the player interacts with the game is important.
The example makes use of two objects. You could set it up so certain areas can only be traversed by a vehicle. Collisions are calculated using a script. This uses a mass based system. As well as having a main player character. For this example a horse is used. This script prevents objects from getting stuck: This example uses a script.
There is a hoof track effect. They each have 7 sub images and the origin should be set as the center: There is a sound effect that is played when the horse is moving. This needs to be loaded in. The horse object. There is also an object. The Step Event has 5 blocks.
The second block is. The third block which creates hoof marks every 20 frames that the player moves: The room. Finally assign a sprite. You could have a character: Then cells in this grid are flagged where the path finding cannot go. A path start and end point are then set. AI is an import aspect of an RPG. The maths behind path finding is quite complex. Creating characters that have path finding is a basic form of AI. This is achieved in only a few lines of code.
First up a grid is created that covers the room in invisible cells where a path may be considered. First this creates a grid that will be used for path finding.
This element has one additional object. The first block checks if the end of the path is reached. The Create Event for this object is shown below. The sprite origin is The Step Event has two blocks. The final part then creates a path between itself and the player. You could omit this whole event.
Then reset the alarm. Using sounds at important points. Too much. This code deals with setting the correct sound effect and the playing of the audio if the player is moving: If the player is moving the alarm triggers.
Using an alarm prevents constant playing of the walking sound. When used sparingly and for emphasis. Set an alarm. The origin of the sprites for the above 4 objects is not important. Additional objects are: Some additional objects are added to show how to use this in practice.
That is achieved through use of one script and one object.
As messages are queued easily through a script you can add them at any time. Each message is shown. This has been omitted to keep it easy to understand. Create this object. First up there is a parent object. These messages are shown as examples. There is no code or sprite for this.
The Create Event has been changed to: The Step Event checks the ds list for any content: The Alarm Event is shown below. The Create Event which sets the required starting values is: This clears any current message: The Alarm Event sets the flag so a message can be shown: It does this by drawing an appropriately sized background and places the text over it: Place a few of the items in the room.
Finally there is the font. The example for this element draws the 7 elements listed above. A HUD is usually a non-interactive element of a game. In GameMaker: Studio this is relatively easy as you can draw a GUI above and independent from the main game view.
The HUD is usually drawn separate from the view. The player needs access to a whole menagerie of information. In your own game you may choose to display more or less: HUDs are important in lots of game genres. Firstly sprite. All the other HUD graphics is done within the following object. This routine utilizes extra code for example purposes. In fact. There are some fonts: Your actual game would omit these additions. The first block draws the sprite for the object.
The second block formats the text: This has 8 code blocks. The sixth block draws the appropriate chosen weapon: You can use the keyboard to change the variable for testing. Collecting items is one of the main focuses for a player.
Adding additional items is pretty straight forward. This example allows the player to collide with an instances of an object and pick it up using a keypress. Each slot holds a value of -1 if empty. In this example. The inventory has a number of slots for placing items in. The example shown is very basic. Acquired items are generally stored visually. As an example. Each item has a mini sprite as a sub image that is shown on the inventory. An RPG must have some form of inventory system.
We use four items. It consists of 5 sub images. Its size is x It also consists of 5 sub images. This is 64x64 in size and the origin is the center. First up there is a sprite. Next is a sprite that will hold the images used in the inventory. The origin is 0. This is also 32x32 with the origin set as the center.
This code will increase the size of the inventory global. In your own game. In your own games. There is a more thorough inventory example in the element Usable Items.
This code checks for a keypress and checks whether there is an empty slot.
There are a few objects. These scripts work together to allow you to add items to the inventory and to click and drag items. If it is it will add it and return true. This script will check if a slot is available. It has the following Create Event: It has a Step Event which toggles global. This variable is used to show or hide the inventory: Providing info to the player using various messages. Studio has a colour blend function.
It will also draw a bar above the player to show how much invincibility the player has remaining. In this example it will show invincibility for the player by flashing red. This element has the GMZ Invincibility. You could use this method to convey information to the player. Another method worth considering is changing the colour of the player sprite. An additional block has been added to the Step Event. And finally a Draw Event has been added.
The last line turns off invincibility if there is no timer left: When done the player object. This example challenges the player to collect all treasure chests before the time runs out.
Mini Quests that the player must complete. Quests should ideally be themed so that they match the over-all game theme. The room size needs to be changed to x This uses two sprites. There is an object. Next there is an object that draws a mini map of certain object instances in the room. If under a distance of it will draw inside the map: This will draw a background. The sections for drawing the chest blips.
These two sprites are not assigned to any object. This element makes use of a few additional objects and sprites. Those are the only changes. The Create Event sets everything up. This checks if the chest is not already opened. This is the item that the player needs to collect in their mini quest. An Alarm Event will destroy the instance: An Alarm Event reduces the time available and resets the alarm: The Step Event checks whether time has run out or the player has completed the quest: This makes use of two sprites.
It will also be used as a control object to check whether the player has completed the quest in time or the timer has run out. This is used for showing a timer that displays how much time the player has to complete their quest. When the player collides with the object they are taken to the target location.
When the player collides with a door that will take them to another room. One method is to use separate objects to do this. As the rooms remember the x and y positions of all objects. You can therefore move back and forth between rooms without having to save and load hugh amounts of data.
Fortunately GameMaker: Studio allows you to set rooms as persistent. This prevents infinite looping between target rooms. You can set the origin as Center for this. Delete the room that is already present. Failure to make this position change would send you straight back the target room: There is no code for either of this objects. Changing the y position is very important — it ensures that when you come back to this room the player object is not already touching the door.
They are: This is assigned to two objects: Load that in now as a background. Now set both of these rooms to persistent. This will set the initial value of global. In the resource tree move this room so that it is the first in the rooms section. This example plays audio for a fire and some water. This example is set up to play the audio louder the closer you get to an object.
Studio has a number of audio effects. This plays audio at a volume depending on the distance and direction between an audio emitter and an audio listener.
One of these allows for positional audio. As mentioned before. This plays more through the left channel or right channel. This object. This sprite has 50 sub images. You then need to load in the audio files. There is one change. Set the origin as the center.
The Create Event code again plays audio on a loop: What should you do when the player collides with these? One answer is a respawn point.
You have a respawn point: There will be places that you may not want your player to go. This system is pretty simple to put into place. Where you place these respawn flags is somewhat important.