<?xml version="1.0" encoding="UTF-8" standalone="yes"?><oembed><version><![CDATA[1.0]]></version><provider_name><![CDATA[Tyrant Haxorus]]></provider_name><provider_url><![CDATA[https://tyranthaxorus.wordpress.com]]></provider_url><author_name><![CDATA[tyranthackrous]]></author_name><author_url><![CDATA[https://tyranthaxorus.wordpress.com/author/tyranthackrous/]]></author_url><title><![CDATA[How to Make a Platformer in Gamemaker&nbsp;Studio]]></title><type><![CDATA[link]]></type><html><![CDATA[<p><img loading="lazy" data-attachment-id="2425" data-permalink="https://tyranthaxorus.wordpress.com/2016/05/23/how-to-make-player-movement-for-a-platformer-in-gamemaker-studio/gamemaker-studio-logo/" data-orig-file="https://tyranthaxorus.files.wordpress.com/2016/05/gamemaker-studio-logo.jpg" data-orig-size="1600,900" data-comments-opened="1" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;1&quot;}" data-image-title="GameMaker-Studio-Logo" data-image-description="" data-medium-file="https://tyranthaxorus.files.wordpress.com/2016/05/gamemaker-studio-logo.jpg?w=300" data-large-file="https://tyranthaxorus.files.wordpress.com/2016/05/gamemaker-studio-logo.jpg?w=1024" class="  wp-image-2425 aligncenter" src="https://tyranthaxorus.files.wordpress.com/2016/05/gamemaker-studio-logo.jpg?w=297&#038;h=167" alt="GameMaker-Studio-Logo" width="297" height="167" srcset="https://tyranthaxorus.files.wordpress.com/2016/05/gamemaker-studio-logo.jpg?w=297&amp;h=167 297w, https://tyranthaxorus.files.wordpress.com/2016/05/gamemaker-studio-logo.jpg?w=594&amp;h=334 594w, https://tyranthaxorus.files.wordpress.com/2016/05/gamemaker-studio-logo.jpg?w=150&amp;h=84 150w, https://tyranthaxorus.files.wordpress.com/2016/05/gamemaker-studio-logo.jpg?w=300&amp;h=169 300w" sizes="(max-width: 297px) 100vw, 297px" /></p>
<p>Making 2D platformers in GameMaker Studio involves more than jumping a character up and down. It needs calculations of horizontal movement, Creation Code for a basic checkpoint system and novice developers often stumble because they underestimate what goes into a 2D platformer. While not overwhelming, 2D platformers are a reasonable step up from basic maze and space shooter projects.</p>
<p>After a month of development, I will show you how to make a 2D platformer foundation straight forward enough to develop, but simple enough so you can add your own ideas for a 2D platformer game.</p>
<p style="text-align:center;"><strong>Part 1: Sprites</strong></p>
<p>Make a new project</p>
<p>Create a sprite by pressing this icon</p>
<p><img loading="lazy" data-attachment-id="2286" data-permalink="https://tyranthaxorus.wordpress.com/2016/05/23/how-to-make-player-movement-for-a-platformer-in-gamemaker-studio/capture-3/" data-orig-file="https://tyranthaxorus.files.wordpress.com/2016/05/capture.png" data-orig-size="20,22" data-comments-opened="1" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}" data-image-title="Capture" data-image-description="" data-medium-file="https://tyranthaxorus.files.wordpress.com/2016/05/capture.png?w=20" data-large-file="https://tyranthaxorus.files.wordpress.com/2016/05/capture.png?w=20" class="alignnone size-full wp-image-2286" src="https://tyranthaxorus.files.wordpress.com/2016/05/capture.png?w=20&#038;h=22" alt="Capture" width="20" height="22" /></p>
<p>Make 10 sprites and name them: spr_wall, spr_player, spr_moving_wall, spr_movingwall2, spr_onewayplatform, spr_enemy, spr_emblem, spr_coin, spr_goal, spr_checkpoint</p>
<p>Double click on the sprites and give them the following properties:(The properties can be edited with these GUI interfaces. You can make the sprites anything you want, but its best to work with basic coloured squares)</p>
<div class="tiled-gallery type-rectangular tiled-gallery-unresized" data-original-width="500" data-carousel-extra='{&quot;blog_id&quot;:73647955,&quot;permalink&quot;:&quot;https:\/\/tyranthaxorus.wordpress.com\/2016\/11\/15\/how-to-make-a-platformer-in-gamemaker-studio\/&quot;,&quot;likes_blog_id&quot;:73647955}' itemscope itemtype="http://schema.org/ImageGallery" > <div class="gallery-row" style="width: 500px; height: 98px;" data-original-width="500" data-original-height="98" > <div class="gallery-group images-1" style="width: 500px; height: 98px;" data-original-width="500" data-original-height="98" > <div class="tiled-gallery-item tiled-gallery-item-large" itemprop="associatedMedia" itemscope itemtype="http://schema.org/ImageObject"> <a href="https://tyranthaxorus.wordpress.com/2016/11/15/how-to-make-a-platformer-in-gamemaker-studio/tut-pic-1/" border="0" itemprop="url"> <meta itemprop="width" content="496"> <meta itemprop="height" content="94"> <img data-attachment-id="2609" data-orig-file="https://tyranthaxorus.files.wordpress.com/2016/11/tut-pic-1.png" data-orig-size="148,28" data-comments-opened="1" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}" data-image-title="tut-pic-1" data-image-description="" data-medium-file="https://tyranthaxorus.files.wordpress.com/2016/11/tut-pic-1.png?w=148" data-large-file="https://tyranthaxorus.files.wordpress.com/2016/11/tut-pic-1.png?w=148" src="https://tyranthaxorus.files.wordpress.com/2016/11/tut-pic-1.png?w=496&#038;h=94" width="496" height="94" data-original-width="496" data-original-height="94" itemprop="http://schema.org/image" title="tut-pic-1" alt="tut-pic-1" style="width: 496px; height: 94px;" /> </a> </div> </div> <!-- close group --> </div> <!-- close row --> <div class="gallery-row" style="width: 500px; height: 180px;" data-original-width="500" data-original-height="180" > <div class="gallery-group images-1" style="width: 356px; height: 180px;" data-original-width="356" data-original-height="180" > <div class="tiled-gallery-item tiled-gallery-item-large" itemprop="associatedMedia" itemscope itemtype="http://schema.org/ImageObject"> <a href="https://tyranthaxorus.wordpress.com/2016/11/15/how-to-make-a-platformer-in-gamemaker-studio/tut-pic-2/" border="0" itemprop="url"> <meta itemprop="width" content="352"> <meta itemprop="height" content="176"> <img data-attachment-id="2610" data-orig-file="https://tyranthaxorus.files.wordpress.com/2016/11/tut-pic-2.png" data-orig-size="196,98" data-comments-opened="1" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}" data-image-title="tut-pic-2" data-image-description="" data-medium-file="https://tyranthaxorus.files.wordpress.com/2016/11/tut-pic-2.png?w=196" data-large-file="https://tyranthaxorus.files.wordpress.com/2016/11/tut-pic-2.png?w=196" src="https://tyranthaxorus.files.wordpress.com/2016/11/tut-pic-2.png?w=352&#038;h=176" width="352" height="176" data-original-width="352" data-original-height="176" itemprop="http://schema.org/image" title="tut-pic-2" alt="tut-pic-2" style="width: 352px; height: 176px;" /> </a> </div> </div> <!-- close group --> <div class="gallery-group images-1" style="width: 144px; height: 180px;" data-original-width="144" data-original-height="180" > <div class="tiled-gallery-item tiled-gallery-item-small" itemprop="associatedMedia" itemscope itemtype="http://schema.org/ImageObject"> <a href="https://tyranthaxorus.wordpress.com/2016/11/15/how-to-make-a-platformer-in-gamemaker-studio/tut-pic-3/" border="0" itemprop="url"> <meta itemprop="width" content="140"> <meta itemprop="height" content="176"> <img data-attachment-id="2617" data-orig-file="https://tyranthaxorus.files.wordpress.com/2016/11/tut-pic-3.png" data-orig-size="27,34" data-comments-opened="1" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}" data-image-title="tut-pic-3" data-image-description="" data-medium-file="https://tyranthaxorus.files.wordpress.com/2016/11/tut-pic-3.png?w=27" data-large-file="https://tyranthaxorus.files.wordpress.com/2016/11/tut-pic-3.png?w=27" src="https://tyranthaxorus.files.wordpress.com/2016/11/tut-pic-3.png?w=140&#038;h=176" width="140" height="176" data-original-width="140" data-original-height="176" itemprop="http://schema.org/image" title="tut-pic-3" alt="tut-pic-3" style="width: 140px; height: 176px;" /> </a> </div> </div> <!-- close group --> </div> <!-- close row --> </div>
<p>spr_wall 32&#215;32<br />
spr_player 32&#215;32, 16&#215;16 origin<br />
spr_moving_wall 64&#215;32, 32&#215;0 origin<br />
spr_moving_wall2 64&#215;64, 32&#215;0 origin<br />
spr_oneway_platform 64&#215;32, 32&#215;0 origin<br />
spr_enemy 32&#215;32, 16&#215;16 origin<br />
spr_emblem 32&#215;32<br />
spr_coin 32&#215;32<br />
spr_goal 32&#215;32<br />
spr_checkpoint 32&#215;32, 2 subimages</p>
<p style="text-align:center;"><strong>Part 2: Scripts</strong></p>
<p>Now make a script by pressing this icon</p>
<p><img loading="lazy" data-attachment-id="2620" data-permalink="https://tyranthaxorus.wordpress.com/2016/11/15/how-to-make-a-platformer-in-gamemaker-studio/tut-pic-4/" data-orig-file="https://tyranthaxorus.files.wordpress.com/2016/11/tut-pic-4.png" data-orig-size="22,28" data-comments-opened="1" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}" data-image-title="tut-pic-4" data-image-description="" data-medium-file="https://tyranthaxorus.files.wordpress.com/2016/11/tut-pic-4.png?w=22" data-large-file="https://tyranthaxorus.files.wordpress.com/2016/11/tut-pic-4.png?w=22" class="alignnone size-full wp-image-2620" src="https://tyranthaxorus.files.wordpress.com/2016/11/tut-pic-4.png?w=22&#038;h=28" alt="tut-pic-4" width="22" height="28" /></p>
<p>In the script, put in the following code:</p>
<p>///&#8212;&#8211;CHECKPOINT SYSTEM&#8212;&#8211;///<br />
//&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-//<br />
if (global.checkpointR != 0)<br />
{<br />
room_goto(global.checkpointR);<br />
}<br />
else<br />
{<br />
room_restart();<br />
}<br />
//&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-//</p>
<p>//This system needs Creation Code in order to operate<br />
//Make a room called rm_initialise and only put in Creation Code and room_goto_next<br />
//Global Variables are values that carry their functions across all aspects of a game<br />
//The player will never see this room, but is needed in order to make checkpoints work properly<br />
//In the first line, it checks if a checkpoint is activated (if checkpoints are not off)<br />
//The second line enclosed in a curly bracket will spawn the player in the checkpoints position<br />
//The third line checks if the conditions of the first two lines has not been met<br />
//Then the fourth line will spawn the player at the beginning of the level, but only when the conditions of the first two lines has not been met<br />
//In my example, the enemies have room_restart that makes the player start the room over whenever they touch the enemies and have not jumped on top of them<br />
//Because the Creation Code sets the checkpoint system, room_restart or scr_death will achieve the same thing, make the player spawn on an active checkpoint<br />
//But because it restarts the room, global variables for things such as collectables and coins will not be kept intact<br />
//You should use scr_death if you want certain aspects of progress to remain in memory<br />
//Keep in mind that this system is very basic</p>
<p><img loading="lazy" data-attachment-id="2834" data-permalink="https://tyranthaxorus.wordpress.com/2016/11/15/how-to-make-a-platformer-in-gamemaker-studio/checkpoint-illustration/" data-orig-file="https://tyranthaxorus.files.wordpress.com/2016/11/checkpoint-illustration.gif" data-orig-size="480,360" data-comments-opened="1" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}" data-image-title="checkpoint-illustration" data-image-description="" data-medium-file="https://tyranthaxorus.files.wordpress.com/2016/11/checkpoint-illustration.gif?w=300" data-large-file="https://tyranthaxorus.files.wordpress.com/2016/11/checkpoint-illustration.gif?w=480" class=" size-full wp-image-2834 aligncenter" src="https://tyranthaxorus.files.wordpress.com/2016/11/checkpoint-illustration.gif?w=480&#038;h=360" alt="checkpoint-illustration" width="480" height="360" /></p>
<p style="text-align:center;"><strong>Part 3: Objects</strong></p>
<p>After that, make 12 objects and name them: obj_jumprefine, obj_wall, obj_movingwall, obj_movingwall2, obj_onewayplatform, obj_enemy, obj_enemy2, obj_enemy3, obj_emblem, obj_coin, obj_goal, obj_checkpoint</p>
<p style="text-align:center;"><strong>Object 1/12</strong></p>
<p>In <span style="color:#ff6600;">obj_jumprefine</span>, edit these values: <span style="color:#ff6600;">Depth -1</span></p>
<p>Put the following code into these events:</p>
<p><span style="color:#ff00ff;">Create Event</span></p>
<p>///&#8212;&#8211;ESTABLISH PLAYER VARIABLES&#8212;&#8211;///<br />
//&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-//<br />
hsp = 0 //horizontal movement<br />
vsp = 0 //vertical movement<br />
grav = 0.5 //force of gravity that pulls the player down to the ground<br />
key_down = 0 //allows players to go down oneway platforms<br />
hsp_carry = 0 //horizontal movement on moving platforms<br />
vsp_carry = 0 //vertical movement on moving platforms (Legacy code, meaning this project ended up not using vertical platforms due to programming difficulties)<br />
acc = 0.50 //the amount a player&#8217;s speed revs up until they hit their max<br />
max_speed = 5 //default speed and can be changed by sprinting. Can be any letter key with (keyboard_check(ord(&#8220;&#8221;)))<br />
jump_number = 1 //how many times a player can jump in the air</p>
<p>//Checkpoint spawning<br />
if (global.checkpointR == room)<br />
{<br />
x = global.checkpointx;<br />
y = global.checkpointy;<br />
}<br />
//When an activated checkpoint exists in a room<br />
//The player spawns in the checkpoints X and Y position<br />
//When a checkpoint isn&#8217;t in existence, the player spawns back at the start of the room<br />
//The player&#8217;s spawn is affected by falling out of room borders and touching enemies<br />
//&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-//</p>
<p><span style="color:#ff00ff;">Step Event</span></p>
<p>///&#8212;&#8211;CONTROLS KEYBOARD INPUT AND GRAVITY&#8212;&#8211;///<br />
//&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-//<br />
if (keyboard_check(vk_right))<br />
{<br />
if (hsp &lt; max_speed) hsp += acc<br />
}</p>
<p>//When the right arrow key is pressed<br />
//The game checks if horizontal movement is less than the maximum movement<br />
//When less than max_speed, hsp adds acc(o.5) for every frame the arrow key is pressed<br />
//This rises until hsp is equal to max_speed(5 or 7)</p>
<p>if (keyboard_check(vk_left))<br />
{<br />
if(hsp &gt; -max_speed) hsp -= acc<br />
}</p>
<p>//When the left key is pressed<br />
//The game checks if horizontal movement is less than the maximum movement<br />
//When less than max_speed, hsp adds acc(o.5) for every frame the arrow key is pressed<br />
//This rises until hsp is equal to max_speed(5 or 7)</p>
<p>if (keyboard_check(ord(&#8220;Z&#8221;)))<br />
{<br />
max_speed = 7.5<br />
}<br />
else<br />
{<br />
max_speed = 5<br />
}</p>
<p>//When the Z key is pressed<br />
//max_speed is changed to 7.5, making the player move faster because acc now adds more multiples of 0.5 every frame<br />
//When the Z isn&#8217;t pressed<br />
//max_speed is set back to normal</p>
<p><img loading="lazy" data-attachment-id="2838" data-permalink="https://tyranthaxorus.wordpress.com/2016/11/15/how-to-make-a-platformer-in-gamemaker-studio/running-illustration/" data-orig-file="https://tyranthaxorus.files.wordpress.com/2016/11/running-illustration.gif" data-orig-size="480,360" data-comments-opened="1" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}" data-image-title="running-illustration" data-image-description="" data-medium-file="https://tyranthaxorus.files.wordpress.com/2016/11/running-illustration.gif?w=300" data-large-file="https://tyranthaxorus.files.wordpress.com/2016/11/running-illustration.gif?w=480" class=" size-full wp-image-2838 aligncenter" src="https://tyranthaxorus.files.wordpress.com/2016/11/running-illustration.gif?w=480&#038;h=360" alt="running-illustration" width="480" height="360" /></p>
<p>if(!keyboard_check(vk_left)&amp;&amp; !keyboard_check(vk_right) || keyboard_check(vk_left) &amp;&amp; keyboard_check(vk_right))<br />
{<br />
hsp = 0 + hsp_carry<br />
hsp_carry = 0<br />
}</p>
<p>//To allow the player to stop moving when letting go of a movement key<br />
//The game checks if movement is not pressed or if it is pressed<br />
//Horizontal movement is set to zero when let go or starts it at zero if being pressed<br />
//Previous movement code is responsible for increasing hsp&#8217;s value<br />
//! is NOT, &amp;&amp; is AND, || is OR<br />
//The hsp carry bracket allows the player to stand and move with a horizontal moving platform</p>
<p>if(place_meeting(x,y+1,obj_wall))<br />
{<br />
jump_number = 1<br />
}<br />
if (keyboard_check_pressed(vk_up)) &amp;&amp; (place_meeting(x,y+1,obj_wall))<br />
{<br />
vsp = -12<br />
jump_number -=1<br />
}<br />
if (keyboard_check_pressed(vk_up)) &amp;&amp; (!place_meeting(x,y+1,obj_wall)) &amp;&amp; jump_number &gt;=0<br />
{<br />
vsp = -12<br />
jump_number -=1<br />
}<br />
if(keyboard_check_released(vk_up) &amp;&amp; vsp &lt; 0)<br />
vsp *= 0.5<br />
else<br />
{<br />
vsp +=grav<br />
}</p>
<p>//The game checks if the player is touching or rather 1 pixel above a wall<br />
//If in contact jump_number is set to 1, allowing the jump again after the vsp has been set on input<br />
//When the jump button is pressed<br />
//The jump(vsp) moves the player upwards and subtracts 1 jump_number count<br />
//When jump_number is greater than or equal to 0<br />
//The player can make an additional jump<br />
//This jump can happen on ground or the air and resets after landing<br />
//When the jump key is pressed and released<br />
//It checks if vsp is less than 0<br />
//vsp then equals and multiply by 0.5 until the key is let go<br />
//After these functions have been met or don&#8217;t meet conditions<br />
//vsp will equal gravity, that pulls the player down to earth for every frame where a condition hasn&#8217;t been met<br />
//&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-//</p>
<p>///&#8212;&#8211;COLLISION AND MOVEMENT CHECKS&#8212;&#8211;///<br />
//Turn off Solid in your wall object because this paragraph gives superior control over collisions with the player//<br />
//&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-//<br />
if(place_meeting(x+hsp,y,obj_wall,))<br />
{<br />
while(!place_meeting(x+sign(hsp),y,obj_wall,))<br />
{<br />
x+=sign(hsp)<br />
}<br />
hsp = 0<br />
}<br />
x += hsp</p>
<p>//When the player&#8217;s position meets the wall horizontally<br />
//sign returns 1 or -1 values and checks if left or right meets the wall<br />
//Then if 1 pixel in a space is free, the player keeps moving left or right<br />
//Once the player touches the wall, they stop moving and don&#8217;t past through the wall horizontally<br />
//They will then carry on with their current X position</p>
<p>if(place_meeting(x,y+(vsp),obj_wall,))<br />
{<br />
while(!place_meeting(x,y+sign(vsp),obj_wall,))<br />
{<br />
y+=sign(vsp)<br />
}<br />
vsp = 0<br />
}<br />
y += vsp</p>
<p>//When the player&#8217;s position meets the wall vertically<br />
//sign returns 1 or -1 values and checks if up or down meets the wall<br />
//Then if 1 pixel in a space is free, the player keeps moving up or down<br />
//Once the player touches the wall, they stop moving and don&#8217;t past through the wall vertically<br />
//They will then carry on with their Y position<br />
//&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-//</p>
<p>&nbsp;</p>
<p>///&#8212;&#8211;GOING DOWN ONE WAY PLATFORMS WHEN STANDING ON THEM&#8212;&#8211;///<br />
//&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;//<br />
key_down = keyboard_check(vk_down)<br />
//When the down key is pressed on a one way platform, the player will fall through it<br />
//The player can also pass through Horizontal and Vertical moving platforms<br />
//&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;//</p>
<p><img loading="lazy" data-attachment-id="2842" data-permalink="https://tyranthaxorus.wordpress.com/2016/11/15/how-to-make-a-platformer-in-gamemaker-studio/onwayplatform-illustration/" data-orig-file="https://tyranthaxorus.files.wordpress.com/2016/11/onwayplatform-illustration.gif" data-orig-size="480,360" data-comments-opened="1" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}" data-image-title="onwayplatform-illustration" data-image-description="" data-medium-file="https://tyranthaxorus.files.wordpress.com/2016/11/onwayplatform-illustration.gif?w=300" data-large-file="https://tyranthaxorus.files.wordpress.com/2016/11/onwayplatform-illustration.gif?w=480" class=" size-full wp-image-2842 aligncenter" src="https://tyranthaxorus.files.wordpress.com/2016/11/onwayplatform-illustration.gif?w=480&#038;h=360" alt="onwayplatform-illustration" width="480" height="360" /></p>
<p><span style="color:#ff00ff;">Other, Outside Room</span></p>
<p>///&#8212;&#8211;FALLING OUTSIDE GAME BORDERS&#8212;&#8211;///<br />
//&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;//<br />
room_restart() //When the player goes outside the game borders, the room restarts<br />
//&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;//</p>
<p style="text-align:center;"><strong>Object 2/12</strong></p>
<p>In <span style="color:#ff6600;">obj_wall</span>, edit these values:<span style="color:#ff6600;"> Children:obj_movingwall, obj_movingwall2, obj_onewayplatform</span></p>
<p><img loading="lazy" data-attachment-id="2845" data-permalink="https://tyranthaxorus.wordpress.com/2016/11/15/how-to-make-a-platformer-in-gamemaker-studio/tut-pic-6/" data-orig-file="https://tyranthaxorus.files.wordpress.com/2016/11/tut-pic-6.png" data-orig-size="204,62" data-comments-opened="1" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}" data-image-title="tut-pic-6" data-image-description="" data-medium-file="https://tyranthaxorus.files.wordpress.com/2016/11/tut-pic-6.png?w=204" data-large-file="https://tyranthaxorus.files.wordpress.com/2016/11/tut-pic-6.png?w=204" class="alignnone size-full wp-image-2845" src="https://tyranthaxorus.files.wordpress.com/2016/11/tut-pic-6.png?w=204&#038;h=62" alt="tut-pic-6" width="204" height="62" srcset="https://tyranthaxorus.files.wordpress.com/2016/11/tut-pic-6.png 204w, https://tyranthaxorus.files.wordpress.com/2016/11/tut-pic-6.png?w=150&amp;h=46 150w" sizes="(max-width: 204px) 100vw, 204px" /></p>
<p style="text-align:center;"><strong>Object 3/12</strong></p>
<p>In <span style="color:#ff6600;">obj_movingwall</span>, put the following code into these events:</p>
<p><span style="color:#ff00ff;">Create Event</span></p>
<p>///&#8212;&#8211;ESTABLISH MOVEMENT PROPERTIES&#8212;///<br />
//&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;//<br />
dir = -1<br />
movespeed = 3<br />
hsp = 0<br />
sprite_index = -1;<br />
//dir is the direction the platform moves in<br />
//movespeed is how fast the platform moves<br />
//hsp is horizontal speed<br />
//Sprite_index allows the player to go through the bottom and sides of the platform<br />
//&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;//</p>
<p><span style="color:#ff00ff;">Step Event</span></p>
<p>///&#8212;&#8211;PLAYER COLLISION WITH THE MOVING PLATFORM&#8212;&#8211;///<br />
//obj_movingwall is a parent of obj_wall, meaning it shares many of obj_wall&#8217;s coding properties//<br />
//&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-//<br />
mask_index = spr_moving_wall<br />
hsp = dir * movespeed</p>
<p>//mask_index is the objects collision box<br />
//Horizontal movement is set by direction and movement speed</p>
<p>if (place_meeting(x+hsp,y,obj_wall))<br />
{<br />
while(!place_meeting(x+sign(hsp),y,obj_wall))<br />
{<br />
x += sign(hsp);<br />
}<br />
hsp = 0;<br />
dir *= -1;<br />
}<br />
x += hsp;<br />
if (instance_exists(obj_jumprefine))<br />
{<br />
if (round(obj_jumprefine.y + (obj_jumprefine.sprite_height/2)) &gt; y) || (obj_jumprefine.key_down) mask_index = -1;<br />
else<br />
{<br />
mask_index = spr_moving_wall;<br />
if place_meeting(x,y-1,obj_jumprefine)<br />
{<br />
obj_jumprefine.hsp_carry = hsp;<br />
}<br />
}<br />
}</p>
<p>//When the platform touches a wall<br />
//And they are currently not touching one<br />
//The X position is rounded by sign hsp<br />
//Then the hsp is set to 0<br />
//And the direction is flipped in the other direction<br />
//The platform carry&#8217;s on with its X position<br />
//This creates a loop where the platform goes left and right so long as it bounces off a wall<br />
//When a player exists on the platform<br />
//Their Y position is calculated to be above the horizontal platform<br />
//When above the platform, the mask below the platform is off, allowing the player to jump up, down or sideways onto the platform&#8217;s centre position<br />
//This is why the platform sprite&#8217;s X centre origin is placed in the top middle of the platform (You can change it in the Sprite properties)<br />
//When this condition isn&#8217;t met the mask_index is on, allowing the platform to collide with the wall<br />
//When the player is standing on the platform<br />
//Their hsp will equal the platform&#8217;s own hsp, allowing them to move with the platform<br />
//&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-//</p>
<p><span style="color:#ff00ff;">Draw Event</span></p>
<p>///&#8212;&#8211;SHOW SPRITE ON SCREEN&#8212;&#8211;///<br />
//&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;//<br />
draw_sprite(spr_moving_wall,0,x,y);<br />
//The objects sprite is shown on screen<br />
//&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;//</p>
<p style="text-align:center;"><strong>Object 4/12</strong></p>
<p>In <span style="color:#ff6600;">obj_movingwall2</span>, put the following code into these events:</p>
<p><span style="color:#ff00ff;">Create Event</span></p>
<p>///&#8212;&#8211;ESTABLISH MOVEMENT PROPERTIES&#8212;&#8211;///<br />
//&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;//<br />
dir = 1<br />
movespeed = 1<br />
vsp = 0<br />
sprite_index = -1<br />
//dir is the direction the platform goes in (up and down)<br />
//movespeed is how fast the platform goes<br />
//vsp is vertical movement<br />
//sprite_index sets the sprite subimage</p>
<p><span style="color:#ff00ff;">Step Event</span></p>
<p>///&#8212;&#8211;MOVEMENT AND COLLISION OPERATIONS&#8212;&#8211;///<br />
//Legacy code that does not work properly<br />
//&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;//<br />
vsp = dir * movespeed<br />
mask_index = spr_moving_wall2<br />
if (place_meeting(x,y+vsp,obj_wall))<br />
{<br />
while(!place_meeting(x,y+sign(vsp),obj_wall))<br />
{<br />
y += sign(vsp);<br />
}<br />
vsp = 0;<br />
dir *= -1;<br />
}<br />
y += vsp;<br />
if (instance_exists(obj_jumprefine))if (round(obj_jumprefine.y + (obj_jumprefine.sprite_height/2)) &gt; y) || (obj_jumprefine.key_down) mask_index = -1;<br />
else<br />
{<br />
{<br />
mask_index = spr_moving_wall2<br />
if place_meeting(x,y-1,obj_jumprefine)<br />
{<br />
obj_jumprefine.vsp_carry = vsp;<br />
}<br />
}<br />
}<br />
//&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;//</p>
<p><span style="color:#ff00ff;">Draw Event</span></p>
<p>///&#8212;&#8211;SHOW SPRITE ON SCREEN&#8212;&#8211;///<br />
//&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;//<br />
draw_sprite(spr_moving_wall2,0,x,y);<br />
//The objects sprite is shown on screen<br />
//&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;//</p>
<p style="text-align:center;"><strong>Object 5/12</strong></p>
<p>In <span style="color:#ff6600;">obj_onewayplatform</span>, put the following code into these events:</p>
<p><span style="color:#ff00ff;">Create Event</span></p>
<p>///&#8212;&#8211;ESTABLISH ONE WAY PLATFORM VARIABLES&#8212;&#8211;///<br />
//&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;//<br />
sprite_index = -1<br />
//sprite_index is responsible for affecting the collision box<br />
//By default, -1 turns off the collision box<br />
//the Draw Event, separate from this code script allows players to see the object sprite<br />
//The Step Event affects if the player can stand on top of the platform by turning the sprite_index on and off</p>
<p><span style="color:#ff00ff;">Step Event</span></p>
<p>///&#8212;&#8211;PLAYER COLLISION WITH ONEWAY PLATFORM&#8212;&#8211;///<br />
//&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;//<br />
//Check for player existing in the game to prevent death script conflict and crashes<br />
if(instance_exists(obj_jumprefine))<br />
{<br />
if (round (obj_jumprefine.y + (obj_jumprefine.sprite_height/2)) &gt; y) || (obj_jumprefine.key_down) mask_index = -1<br />
else mask_index = spr_oneway_platform<br />
}<br />
//When the player exists in the game<br />
//The sprite&#8217;s foot is checked<br />
// when its greater than the position of the one way platform<br />
//round turns numbers into integers to ensure whole numbers are caculated<br />
//mask_index is turned on, letting the player stand on top of the platform&#8217;s origin</p>
<p><span style="color:#ff00ff;">Draw Event</span></p>
<p>///&#8212;&#8211;SHOW ONEWAY PLATFORM SPRITES ON SCREEN&#8212;&#8211;///<br />
//&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-//<br />
draw_sprite(spr_oneway_platform,0,x,y)<br />
//Shows Oneway platfrom&#8217;s sprite<br />
//&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-//</p>
<p style="text-align:center;"><strong>Object 6/12</strong></p>
<p>In <span style="color:#ff6600;">obj_enemy</span>, put the following code into these events:</p>
<p><span style="color:#ff00ff;">Create Event</span></p>
<p>///&#8212;&#8211;ESTABLISH ENEMY VARIABLES&#8212;&#8211;///<br />
//&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;//<br />
state = e_state.idle//allows the enemy to move once the player is close enough<br />
dir = -1;//the direction the enemy moves<br />
movespeed = 2;//the speed the enemy moves at<br />
grav = 0.5;//the force of gravity dragging the enemy down to the ground<br />
hsp = 0;// horizontal movement<br />
vsp = 0;//vertical movement<br />
//&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;//</p>
<p><span style="color:#ff00ff;">Step Event</span></p>
<p>///&#8212;&#8211;ENEMY LOGIC AND COLLISION&#8212;&#8211;///<br />
//&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;//<br />
switch (state)<br />
{<br />
case e_state.idle:<br />
{<br />
hsp = 0;<br />
vsp = (min(7,vsp+0.5));<br />
if (distance_to_object(obj_jumprefine) &lt; 384) state = e_state.chase;<br />
}<br />
break;<br />
case e_state.chase:<br />
{<br />
dir = sign(obj_jumprefine.x &#8211; x);<br />
hsp = dir * 2;<br />
vsp = (min(7,vsp+0.5));<br />
if (distance_to_object(obj_jumprefine) &gt; 416) state = e_state.idle;<br />
}<br />
break;<br />
}<br />
if (place_meeting(round(x+hsp),round(y),obj_wall))<br />
{<br />
while(!place_meeting(round(x+sign(hsp)),round(y),obj_wall)) x += sign(hsp);<br />
hsp = 0;<br />
}<br />
x += hsp;<br />
if (place_meeting(round(x),round(y+vsp),obj_wall))<br />
{<br />
while(!place_meeting(round(x),round(y+sign(vsp)),obj_wall)) y += sign(vsp);<br />
vsp = 0;<br />
}<br />
y += vsp;</p>
<p>//The enemy has their state set to idle<br />
//State machines are isolated forms of code that can be called upon at any time<br />
//They are a useful advanced rescource for making A.I, complex mechanics and menus<br />
//In idle, the enemy is still and is affected by gravity<br />
//When the player comes into a close distance to the enemy, the state changes to chase<br />
//The previous state is replaced with the new activated state<br />
//The enemy moves to the player&#8217;s X posistion at a speed of 2<br />
//The enemy is still affected by gravity<br />
//Once the player has enough distance away from the enemy<br />
//The enemy&#8217;s state goes back to idle and the chase state is lost until activated again<br />
//The rest is collision code with the wall that rounds caulations to whole numbers<br />
//&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;//</p>
<p><img loading="lazy" data-attachment-id="2848" data-permalink="https://tyranthaxorus.wordpress.com/2016/11/15/how-to-make-a-platformer-in-gamemaker-studio/enemy-a-i-illustration/" data-orig-file="https://tyranthaxorus.files.wordpress.com/2016/11/enemy-a-i-illustration.gif" data-orig-size="480,360" data-comments-opened="1" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}" data-image-title="enemy-a-i-illustration" data-image-description="" data-medium-file="https://tyranthaxorus.files.wordpress.com/2016/11/enemy-a-i-illustration.gif?w=300" data-large-file="https://tyranthaxorus.files.wordpress.com/2016/11/enemy-a-i-illustration.gif?w=480" class=" size-full wp-image-2848 aligncenter" src="https://tyranthaxorus.files.wordpress.com/2016/11/enemy-a-i-illustration.gif?w=480&#038;h=360" alt="enemy-a-i-illustration" width="480" height="360" /></p>
<p>///&#8212;&#8211;PLAYER ABILITY TO JUMP ON AND DEFEAT ENEMIES&#8212;&#8211;///<br />
//&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-//<br />
if(place_meeting(x,y,obj_jumprefine))<br />
{<br />
if(obj_jumprefine.y &lt; y &#8211; 20)<br />
{<br />
with(obj_jumprefine) vsp = -vsp<br />
instance_destroy()<br />
}<br />
else<br />
{<br />
room_restart()<br />
}<br />
}</p>
<p>//When the player is touching an enemy<br />
//The player has their Y posistion checked to see if its a set number less than the enemies own Y posistion<br />
//When less than the enemies Y posistion, the player will bounce upwards off the enemy and kill it<br />
//The player&#8217;s bounce is equal to how much vsp was caculated during the check<br />
//If falling from a great height, the player will have a great bounce upwards and vice versa<br />
//If that check isn&#8217;t met, the player is beaten by the enemy and the room restarts<br />
//In my example, the enemies have room_restart that makes the player start the room over whenever they touch the enemies and have not jumped on top of them<br />
//Because the Creation Code sets the checkpoint system, room_restart or scr_death will achive the same thing, make the player spawn on an active checkpoint<br />
//But because it restarts the room, global variables for things such as collectibles and coins will not be kept intact<br />
//You should use scr_death if you want ceartin aspects of progress to remain in memory<br />
//&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-//</p>
<p><img loading="lazy" data-attachment-id="2851" data-permalink="https://tyranthaxorus.wordpress.com/2016/11/15/how-to-make-a-platformer-in-gamemaker-studio/enemy-stomp-illustration/" data-orig-file="https://tyranthaxorus.files.wordpress.com/2016/11/enemy-stomp-illustration.gif" data-orig-size="480,360" data-comments-opened="1" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}" data-image-title="enemy-stomp-illustration" data-image-description="" data-medium-file="https://tyranthaxorus.files.wordpress.com/2016/11/enemy-stomp-illustration.gif?w=300" data-large-file="https://tyranthaxorus.files.wordpress.com/2016/11/enemy-stomp-illustration.gif?w=480" class=" size-full wp-image-2851 aligncenter" src="https://tyranthaxorus.files.wordpress.com/2016/11/enemy-stomp-illustration.gif?w=480&#038;h=360" alt="enemy-stomp-illustration" width="480" height="360" /></p>
<p><span style="color:#ff00ff;">Outside Room</span></p>
<p>///&#8212;&#8211;FALLING OUTSIDE GAME BORDERS&#8212;&#8211;///<br />
//&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-//<br />
instance_destroy()//When outside the room&#8217;s borders, the enemy is destroyed<br />
//&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-//</p>
<p style="text-align:center;"><strong>Object 7/12</strong></p>
<p>In <span style="color:#ff6600;">obj_enemy2</span>, edit these values: <span style="color:#ff6600;">Children: obj_enemy3</span></p>
<p>Put the following code into these events:</p>
<p><span style="color:#ff00ff;">Create Event</span></p>
<p>///&#8212;&#8211;ESTABLISH ENEMY VARIABLES&#8212;&#8211;///<br />
//&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;//<br />
dir = -1//the direction the enemy moves<br />
movespeed = 2//the speed the enemy moves at<br />
grav = 0.5//the force of gravity dragging the enemy down to the ground<br />
hsp = 0// horizontal movement<br />
vsp = 0//vertical movement<br />
fearofheights = 0//allows obj_enemy3, a child of obj_enemy2 to move without falling off the ground<br />
//&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;//</p>
<p><span style="color:#ff00ff;">Step Event</span></p>
<p>///&#8212;&#8211;ENEMY LOGIC AND COLLISION&#8212;&#8211;///<br />
//&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;//<br />
hsp = dir * movespeed;<br />
vsp += grav;</p>
<p>//hsp is caculated by direction and movement speed<br />
//vsp is gravity, the force that pulls objects down to the ground</p>
<p>if (place_meeting(x+hsp,y,obj_wall))<br />
{<br />
while(!place_meeting(x+sign(hsp),y,obj_wall))<br />
{<br />
x += sign(hsp);<br />
}<br />
hsp = 0;<br />
dir *= -1;<br />
}<br />
x += hsp;</p>
<p>//When touching walls<br />
//The enemy goes in the opposite direction<br />
//They retain their X posistion</p>
<p>if (place_meeting(x,y+vsp,obj_wall))<br />
{<br />
while(!place_meeting(x,y+sign(vsp),obj_wall))<br />
{<br />
y += sign(vsp);<br />
}<br />
vsp = 0;<br />
if (fearofheights) &amp;&amp; !position_meeting(x+(sprite_width/2)*dir, y+(sprite_height/2)+8, obj_wall)<br />
{<br />
dir *= -1;<br />
}<br />
}<br />
y += vsp;</p>
<p>//When moving across walls and near an edge<br />
//The enemy&#8217;s sprite is checked to see if it&#8217;s 8 pixels away from changing its Y position<br />
//If the enemy is 8 pixels away from going off a edge, the enemy will have its direction changed before they fall off<br />
//They retain their Y position<br />
//This code only affects obj_enemy3 that inherits obj_enemy2&#8217;s properties<br />
//&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;//</p>
<p>///&#8212;&#8211;PLAYER ABILITY TO JUMP ON AND DEFEAT ENEMIES&#8212;&#8211;///<br />
//&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-//<br />
if (place_meeting(x,y,obj_jumprefine))<br />
{<br />
if (obj_jumprefine.y &lt; y-20)<br />
{<br />
with (obj_jumprefine) vsp = -vsp;<br />
instance_destroy();<br />
}<br />
else<br />
{<br />
room_restart();<br />
}<br />
}</p>
<p>//When the player is touching an enemy<br />
//The player has their Y posistion checked to see if its a set number less than the enemies own Y posistion<br />
//When less than the enemies Y posistion, the player will bounce upwards off the enemy and kill it<br />
//The player&#8217;s bounce is equal to how much vsp was caculated during the check<br />
//If falling from a great height, the player will have a great bounce upwards and vice versa<br />
//If that check isn&#8217;t met, the player is beaten by the enemy and the room restarts<br />
//In my game, the enemies have room_restart that makes the player start the room over whenever they touch the enemies and have not jumped on top of them<br />
//Because the Creation Code sets the checkpoint system, room_restart or scr_death will achieve the same thing, make the player spawn on an active checkpoint<br />
//But because it restarts the room, global variables for things such as collectables and coins will not be kept intact<br />
//You should use scr_death if you want ceartin aspects of progress to remain in memory<br />
//&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-//</p>
<p style="text-align:center;"><strong>Object 8/12</strong></p>
<p>In <span style="color:#ff6600;">obj_enemy3</span>, put the following code into these events:</p>
<p><span style="color:#ff00ff;">Create Event</span></p>
<p><img loading="lazy" data-attachment-id="2697" data-permalink="https://tyranthaxorus.wordpress.com/2016/11/15/how-to-make-a-platformer-in-gamemaker-studio/tut-pic-5/" data-orig-file="https://tyranthaxorus.files.wordpress.com/2016/11/tut-pic-5.png" data-orig-size="36,35" data-comments-opened="1" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}" data-image-title="tut-pic-5" data-image-description="" data-medium-file="https://tyranthaxorus.files.wordpress.com/2016/11/tut-pic-5.png?w=36" data-large-file="https://tyranthaxorus.files.wordpress.com/2016/11/tut-pic-5.png?w=36" class="alignnone size-full wp-image-2697" src="https://tyranthaxorus.files.wordpress.com/2016/11/tut-pic-5.png?w=36&#038;h=35" alt="tut-pic-5" width="36" height="35" />Drag and Drop in Control tab</p>
<p>///&#8212;&#8211;ABILITY TO NOT FALL OFF EDGES WHEN MOVING LEFT AND RIGHT&#8212;&#8211;///<br />
//&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;//<br />
fearofheights = 1//Allows the enemy to not fall off edges<br />
//Affects only obj_enemy3<br />
//&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;//</p>
<p style="text-align:center;"><strong>Object 9/12</strong></p>
<p>In <span style="color:#ff6600;">obj_emblem</span>, put the following code into these events:</p>
<p><span style="color:#ff00ff;">Collision Event with obj_jumprefine</span></p>
<p>///&#8212;&#8211;PLAYER INTERACTION WITH EMBLEM&#8212;&#8211;///<br />
//&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;//<br />
instance_destroy()<br />
//When the player touches the emblem, the emblem vanishes<br />
//It does nothing and is there to see the basic idea of collectables in action and how they affect player behaviour<br />
//&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;//</p>
<p style="text-align:center;"><strong>Object 10/12</strong></p>
<p>In <span style="color:#ff6600;">obj_coin</span>, put the following code into these events:</p>
<p><span style="color:#ff00ff;">Collision Event with obj_jumprefine</span></p>
<p>///&#8212;&#8211;PLAYER INTERACTION WITH COIN&#8212;&#8211;///<br />
//&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;//<br />
instance_destroy()<br />
//When the player touches the coin, the coin vanishes<br />
//It does nothing and is there to see the basic idea of collectibles in action and how they affect player behaviour<br />
//&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;//</p>
<p style="text-align:center;"><strong>Object 11/12</strong></p>
<p>In <span style="color:#ff6600;">obj_goal</span>, put the following code into these events:</p>
<p><span style="color:#ff00ff;">Collision Event with obj_jumprefine</span></p>
<p>///&#8212;&#8211;PLAYER INTERACTION WITH GOAL&#8212;&#8211;///<br />
//&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;//<br />
room_goto_next()<br />
//When touching the goal, the player is sent to the next room<br />
//This order can be arranged simply by having rooms ordered top to bottom in the room folder<br />
//e.g rm_initialize, rm_level1, rm_level2, rm_testing<br />
//&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;//</p>
<p style="text-align:center;"><strong>Object 12/12</strong></p>
<p>In <span style="color:#ff6600;">obj_checkpoint</span>, put the following code into these events:</p>
<p><span style="color:#ff00ff;">Create Event</span></p>
<p>///&#8212;&#8211;ESTABLISH VISUAL ELEMENTS&#8212;&#8211;///<br />
//&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;//<br />
image_index = 0<br />
image_speed = 0<br />
//image_index sets the sprite subimage drawn on the screen<br />
//image_speed sets how quickly the sprite shows its animation frames<br />
//In this suitation, the checkpoint will rapidly flash without its speed set to 0<br />
//&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;//</p>
<p><span style="color:#ff00ff;">Step Event</span></p>
<p>///&#8212;&#8211;CHECKPOINT REACTION TO PLAYER&#8212;&#8211;///<br />
//&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-//<br />
if (place_meeting(x,y,obj_jumprefine))<br />
{<br />
global.checkpoint = id;<br />
global.checkpointx = x;<br />
global.checkpointy = y;<br />
global.checkpointR = room;<br />
}<br />
if (global.checkpointR == room)<br />
{<br />
if (global.checkpoint == id) image_index = 1; else image_index = 0;<br />
}<br />
//When the player touches a checkpoint<br />
//The checkpoint sets its global variables<br />
//== room checks for the existence of a activated checkpoint inside a room to reduce repetition<br />
//When in existence, the specific checkpoint is identified<br />
//the checkpoints subimage is switched so the player sees that it is working<br />
//When not in existence or a new existence is found, the subimage for the previous existence goes back to normal<br />
//&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-//</p>
<p style="text-align:center;"><strong>Part 4: Rooms</strong></p>
<p>Finally, <span style="color:#ff6600;">make 3 rooms and name them the following: rm_initialise, rm_level1, rm_level2</span></p>
<p style="text-align:center;"><strong>Room 1/3</strong></p>
<p>In rm_initialise, enter <span style="color:#ff00ff;">Creation Code</span> in the Settings tab and put in the following:</p>
<p>///&#8212;&#8211;ESTABLISHING GLOBAL SYSTEM VARIABLES&#8212;&#8211;///<br />
//&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;//<br />
global.checkpoint = noone;<br />
global.checkpointR = 0;<br />
global.checkpointx = 0;<br />
global.checkpointy = 0;<br />
room_goto_next();<br />
//global variables are values that are always accessible to every aspect of a game, instead of normal values that only affect the object their made in<br />
//checkpoint is the ID of a currently active checkpoint. It&#8217;s set to noone so when a checkpoint is activated, GML does not get confused over the existence of multiple checkpoints<br />
//checkpointR is what room the player is currently in<br />
//checkpointX is the left and right position of the checkpoint<br />
//checkpointY is the up and down position of the checkpoint<br />
//When a checkpoint is activated, these global variables change to match its location values<br />
//After this system is set, the game goes straight to the first interactable room<br />
//&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;//</p>
<p style="text-align:center;"><strong>Room 2/3</strong></p>
<p>In rm_level1, go into the Views tab</p>
<p>Tick &#8220;Enable the use of Views&#8221;</p>
<p>Have View 0 selected</p>
<p>Tick &#8220;Visible when room starts&#8221;</p>
<p>Set W to 650, H to 600 in &#8220;View in room&#8221;</p>
<p>Set W to 1024, H to 768 in &#8220;Port on screen&#8221;</p>
<p>Set Hbor and Vbor to 999 and select obj_jumprefine in &#8220;Object following&#8221;</p>
<p>In the Settings tab, set &#8220;Speed&#8221; to 60. The size and length of the room can be changed with &#8220;Width&#8221; and &#8220;Height&#8221;</p>
<p>In the Objects tab, select obj_wall in &#8220;Object to add with left mouse&#8221; and place it in the room. Add and create the objects you want in the room to your heart&#8217;s content</p>
<p style="text-align:center;"><strong>Room 3/3</strong></p>
<p>Repeat for rm_level2</p>
<p>Upon finishing this example your game should have pixel perfect wall collisions, movement with weight that creates a feeling of greater control, a double jump for the ground and air that resets on landing, the ability to defeat enemies by jumping on top of them and die and respawn when touching them, checkpoints that start players at their position when activated, horizontally moving platforms that carry the player with them, the ability to freely run and walk by pressing down a run key, specific platforms the player can pass through downwards and jump back onto and collectable coins and emblems for leading players like breadcrumbs and expanding into bonus content.</p>
<p>My example isn&#8217;t perfect however. The way horizontal control is made means that a sliding effect can happen with a very specific use of the run button and move controls. Vertical platforms have also proven in the end to be out of my abilities. If you are seeking vertical platform solutions, you will likely have to use other resources such as <a href="https://marketplace.yoyogames.com/assets/1724/moving-platforms" target="_blank">ZGB&#8217;s Moving Platforms</a>.</p>
<p>I hope my example has helped you in your projects. Do not hesitate to point out what is wrong with my example and I hope this foundation will allow you to make the product the video game industry deserves.</p>
]]></html><thumbnail_url><![CDATA[https://tyranthaxorus.files.wordpress.com/2016/11/tut-pic-1.png?fit=440%2C330]]></thumbnail_url><thumbnail_width><![CDATA[148]]></thumbnail_width><thumbnail_height><![CDATA[28]]></thumbnail_height></oembed>