• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

GML Easy Dash With GML Code

BlueBot5000

Member
i'm working on a new game but it needs dashing i was thinking of dashing in 8 directions (with different sprites playing at the same time)

how i would i be able to do this as a novice?
 

Nidoking

Member
I think the best advice you're going to get is to practice until you're no longer a novice, and then your question becomes moot.

Dashing in 8 directions is very similar to dashing in one, two, or four directions, except you do it in eight directions.
 

rIKmAN

Member
Like Nidoking says - work on getting a dash working in one direction, then the other (ie. left and right).

Any problems you hit doing that, learn about them, ask questions here specific to what issues you are having with your attempts until they work like you want. After that, you'll have a pretty solid idea of how to adapt that now working code to work in the other directions.
 

BlueBot5000

Member
GML:
switch (state)
{
   case "Normal":
      #region Nomral State
//Get The PLayer Inputs
key_left = keyboard_check(vk_left);
key_right = keyboard_check(vk_right);
key_jump = keyboard_check(ord("S"));
key_jump_held = keyboard_check(ord("S"));
key_down = keyboard_check(vk_down);

//Calculate Movement
_move = key_right - key_left;
hspd = _move * walkspd;
vspd = vspd + grv;

//Jump
if (place_meeting(x,y+1,objCollision)) && (key_jump)
{
    vspd = -jumpspd;
}

//Small Jump
if (vspd < 0 and !key_jump_held)
{
    vspd = max(vspd, -jumpspd / jump_dampner);
}

//Horizontal Collisions
if (place_meeting(x+hspd,y,objCollision))
{
    while (!place_meeting(x+sign(hspd),y,objCollision))
    {
        x = x + sign(hspd);
    }
    hspd = 0;

}
x = x + hspd;

//Vertical Collisions
if (place_meeting(x,y+vspd,objCollision))
{
    while (!place_meeting(x,y+sign(vspd),objCollision))
    {
        y = y + sign(vspd);
    }
    vspd = 0;

}
y = y + vspd;

//Animations
if (!place_meeting(x,y+1,objCollision))
{
    sprite_index = sprBaraka_InAir;
    image_speed = 0;
    if (vspd > 0) image_index = 1; else image_index = 0;
}
else
{
    image_speed = 1.4;
    if(hspd == 0)
    {
       sprite_index = sprBaraka_Idle;
    }
    else
    {
       sprite_index = sprBaraka_Run;
    }
}

if (hspd != 0) image_xscale = sign(hspd);

if keyboard_check_pressed(ord("A")) {
state = "Dash";
}
#endregion
       break; [/CODE=gml]

[CODE=gml]   case "Dash":
      #region Dash State
      sprite_index = sprBaraka_Dash;
      image_speed = 0.6;
      
      if image_xscale == 1 and not place_meeting(x+6,y,objCollision)
      {
         x += 6;
      }
      
      if image_xscale == -1 and not place_meeting(x-6,y,objCollision)
      {
         x -= 6;
      }     
      #endregion
       break;
}[/CODE=gml]

could i at least have help with dashing LEFT & RIGHT
 
Top