• 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!

Legacy GM [SOLVED] gml draws sprite without draw_self()

Soso

Member
I'm drawing equipment over the player sprite.

ex: helm, body, legs

the problem I'm having is on
keyboard_check(ord("W")))
{ vspeed = -(spd); }

it draws the spr_player_moving_up
even with no draw_self() in the draw event
causing the player sprite to be drawn on top of the helm. However tho the body draws correctly over the sprite for some reason just not the helm.

why is it drawing a sprite when there is no draw_self() in the draw event

Code:
///controls


if (keyboard_check(ord("W")))
 { vspeed = -(spd); } /// the problem comes from this check
 
if (keyboard_check(ord("A")))
 { hspeed = -(spd); }
 
if (keyboard_check(ord("S")))
 { vspeed = +(spd); }
 
if (keyboard_check(ord("D")))
 { hspeed = +(spd); }

//release
if (keyboard_check_released(ord("W")))
 { vspeed = 0;
   hspeed = 0; }
 
if (keyboard_check_released(ord("S")))
 { vspeed = 0;
   hspeed = 0; }
 
if (keyboard_check_released(ord("A")))
 { vspeed = 0;
   hspeed = 0; }
 
if (keyboard_check_released(ord("D")))
 { vspeed = 0;
   hspeed = 0; }
       
     
//sets moving sprites ==========================================================================
if (vspeed > 0)
 { sprite_index = spr_player_move_down;
   image_speed = 0.2;
   face_direction = "move_down";}

if (vspeed < 0)
 { sprite_index = spr_player_move_up;
   image_speed = 0.2;
   face_direction = "move_up"; }
 
if (hspeed > 0)
 { sprite_index = spr_player_move_right;
   image_speed = 0.2;
   face_direction = "move_right"; }

if (hspeed < 0)
 { sprite_index = spr_player_move_left;
   image_speed = 0.2;
   face_direction = "move_left"; }

 
 
//sets idle sprites    
if (hspeed == 0 && vspeed == 0) { //nest
  if (sprite_index == spr_player_move_down)
   {sprite_index = spr_player_idle_down;
    image_speed = 0.1;
    face_direction = "idle_down"; }
 
  if (sprite_index == spr_player_move_up)
   {sprite_index = spr_player_idle_up;
   image_speed = 0.1;
   face_direction = "idle_up"; }
 
  if (sprite_index == spr_player_move_right)
   {sprite_index = spr_player_idle_right;
    image_speed = 0.1;
    face_direction = "idle_right"; }
 
  if (sprite_index == spr_player_move_left)
   {sprite_index = spr_player_idle_left;
    image_speed = 0.1;
    face_direction = "idle_left"; }
        } //end nest


Code:
///draw equipment on player



//draw_self();

//helms

if (helm == "iron_helm"){ //wrap

   if (face_direction == "idle_up")
   {draw_sprite(spr_iron_helm_idle_up,image_index,x,y);}
  
   if (face_direction == "idle_down")
   {draw_sprite(spr_iron_helm_idle_down,image_index,x,y);}
  
   if (face_direction == "idle_right")
   {draw_sprite(spr_iron_helm_idle_right,image_index,x,y);}
  
   if (face_direction == "idle_left")
   {draw_sprite(spr_iron_helm_idle_left,image_index,x,y);}
  
   if (face_direction == "move_up")
   {draw_sprite(spr_iron_helm_move_up,image_index,x,y);}
  
   if (face_direction == "move_down")
   {draw_sprite(spr_iron_helm_move_down,image_index,x,y);}
  
   if (face_direction == "move_right")
   {draw_sprite(spr_iron_helm_move_right,image_index,x,y);}
  
   if (face_direction == "move_left")
   {draw_sprite(spr_iron_helm_move_left,image_index,x,y);}
  
   } //end wrap


All the other draw_sprites are the same setup
 
Last edited:

Morendral

Member
As said above, we need to the entirety of the code in the event to determine whats wrong. I can't find an error in the step event, or what you showed in the draw event.

Also, since it's not working as intended, i recommend commenting out everything in the draw event, then enabling smaller chunks of it at a time to see if you can first disable drawing all together, then enable only the parts that you want to work, like the special helm. The error might not be in the place you expect
 

Relic

Member
Waking left, right and down all work?Confident that the player is drawn above? Can you see the helm underneath or are you just assuming it is underneath?

If you can’t see the helm at all, it might be a sprite issue not your code. Check the origin in the helm sprite for the Up direction. Also check that sprite doesn’t have key layers hidden.
 
D

dannyjenn

Guest
So what you're saying is, it's drawing spr_player_move_up instead of spr_iron_helm_move_up?

My only guess is that somehow the game is mixing up spr_iron_helm_move_up with spr_player_move_up. (Try restarting GameMaker. Maybe it's some sort of bug with the way it's assigning IDs to the sprites in the resource tree...)

Also, if you haven't done so already, go into the sprite editor and make sure your spr_iron_helm_move_up sprite is what it's supposed to be. (Perhaps you inadvertently duplicated spr_player_move_up and renamed it spr_iron_helm_move_up without realizing it.)
 

Soso

Member
hey, thanks for the replies. After some sleep, I've realized I'm an idiot. Turns out the spr for the body had the player sprite drawn inside opps. Thanks again
 
Top