<?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[GameMaker Studio: Player Attack in a 2D&nbsp;platformer]]></title><type><![CDATA[link]]></type><html><![CDATA[<p>&nbsp;</p>
<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=321&#038;h=181" alt="GameMaker-Studio-Logo" width="321" height="181" srcset="https://tyranthaxorus.files.wordpress.com/2016/05/gamemaker-studio-logo.jpg?w=321&amp;h=181 321w, https://tyranthaxorus.files.wordpress.com/2016/05/gamemaker-studio-logo.jpg?w=642&amp;h=362 642w, 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: 321px) 100vw, 321px" /></p>
<p>In 2D platformers, players should be able to take care of enemies with more than just jumping on them. Today I will show you a method for a player attack. It creates a projectile that flies in front and behind the player and damages foes it hits.</p>
<p>Sprites (This tutorial assumes your sprites are basic coloured squares and your game has functional platform collision and player/enemy movement )</p>
<p>spr_player 32&#215;32</p>
<p>spr_attack 32&#215;32</p>
<p>spr_enemy 32&#215;32</p>
<p>Objects</p>
<p><span style="color:#ff00ff;">obj_player</span></p>
<p><span style="color:#ff6600;">Create Event</span></p>
<p>canfire = true</p>
<p><span style="color:#ff6600;">Alarm 0 Event</span></p>
<p>canfire = true</p>
<p><span style="color:#ff6600;">Press A Key Event</span></p>
<p>if canfire = true</p>
<p>{<br />
if (keyboard_check (vk_left) = false) &amp;&amp; (keyboard_check (vk_right) = false)<br />
{<br />
action_create_object_motion (obj_attack, obj_player.x,obj_player.y,10,180)</p>
<p>action_create_object_motion (obj_attack, obj_player.x,obj_player.y,10,360)<br />
}<br />
if keyboard_check (vk_left)<br />
{<br />
action_create_object_motion (obj_attack, obj_player.x,obj_player.y,10,360)</p>
<p>action_create_object_motion (obj_attack, obj_player.x,obj_player.y,10,180)<br />
}<br />
if keyboard_check (vk_right)<br />
{<br />
action_create_object_motion (obj_attack, obj_player.x,obj_player.y,10,180)</p>
<p>action_create_object_motion (obj_attack, obj_player.x,obj_player.y,10,360)<br />
}<br />
canfire = false<br />
alarm[0] = 0.5 * room_speed<br />
}</p>
<p><span style="color:#ff00ff;">obj_attack</span></p>
<p><span style="color:#ff6600;">Collision Event with obj_wall</span></p>
<p>instance_destroy()</p>
<p><span style="color:#ff6600;">Collision Event with obj_enemy</span></p>
<p>instance_destroy()</p>
<p><span style="color:#ff00ff;">obj_enemy</span></p>
<p><span style="color:#ff6600;">Create Event</span></p>
<p>global.Ehp = 10<br />
Ehurt = false</p>
<p><span style="color:#ff6600;">Alarm 0</span></p>
<p>Ehurt = false</p>
<p><span style="color:#ff6600;">Step Event</span></p>
<p>if Ehurt = true<br />
{<br />
image_alpha = 0.5<br />
}<br />
else<br />
{<br />
image_alpha = 1<br />
}</p>
<p>if global.Ehp &lt;=0<br />
{<br />
instance_destroy()<br />
}</p>
<p><span style="color:#ff6600;">Collision Event with obj_attack</span></p>
<p>if !Ehurt<br />
{<br />
global.Ehp-=5<br />
Ehurt = true<br />
alarm[0] = 0.3 * room_speed<br />
}</p>
<p>When done, the player&#8217;s attack should produce moving projectiles. These projectiles disappear when hitting walls, are not produced every time the player mashes the A key, do damage to foes when they are hit by them, enemies flash invincibility frames when hit by the attack and disappear if they take enough damage.</p>
<p>I hope this tutorial has helped you in your project&#8217;s development.</p>
]]></html><thumbnail_url><![CDATA[https://tyranthaxorus.files.wordpress.com/2016/05/gamemaker-studio-logo.jpg?fit=440%2C330]]></thumbnail_url><thumbnail_width><![CDATA[440]]></thumbnail_width><thumbnail_height><![CDATA[248]]></thumbnail_height></oembed>