GameMaker: Studio

GameMaker: Studio

View Stats:
Caster Oct 27, 2014 @ 12:34am
Draw Event Issues
So I've been fiddling with the draw event and I'm planning to use 'Final-Fantasy-like' sprites, and I'd like to use all my images in one sprite file, as in 'spr_hero', while only changing the image_index inside of a draw event. Here's the code:

if(hspeed = 0 && vspeed = 0)
current_frame +=0;
else
current_frame +=4/30;



if(keyboard_check(vk_up))
{
vspeed = -3;
if(current_frame > 3)
current_frame = 0;
}

if(keyboard_check_released(vk_up))
{
vspeed = 0;
current_frame = 1;
}

if(keyboard_check(vk_down))
{
vspeed = 3;
if(current_frame > 7 || current_frame < 4)
current_frame = 4;
}
if(keyboard_check_released(vk_down))
{
vspeed = 0;
current_frame = 5;
}

if(keyboard_check(vk_left))
{
hspeed = -3;
if(current_frame > 11 || current_frame < 8)
current_frame = 8;
}
if(keyboard_check_released(vk_left))
{
hspeed = 0;
current_frame = 9;
}

if(keyboard_check(vk_right))
{
hspeed = 3;
if(current_frame > 15 || current_frame < 12)
current_frame = 12;
}

if(keyboard_check_released(vk_right))
{
hspeed = 0;
current_frame = 13;
}

draw_sprite(spr_riou_global,current_frame,x,y);

Now here's the problem, all of the sprites(directions) are 4x4, but the last frame of each direction skips while in-game, it produces a visible skip at 2.5th/6.5th/10.5th and 14.5th frame. Any ideas?
< >
Showing 1-2 of 2 comments
Daynar Oct 27, 2014 @ 9:12am 
I tried your code and I didn't notice any skips. The only thing I changed was placing everything in the step event exept draw_sprite() it could have simply been that the sprite I tested with didnt highlight the skip in a noticable way. I also assume when you cycle through your sprites they transition from start to finish nicely (contain all the images needed to go from position 0-n and then transition back to 0)
Caster Oct 27, 2014 @ 11:06am 
I've found what caused the issue.. the fact that I've used current_frame +=4/30(which is approximately 0.13333). Game Maker interprets 0,0.1,0.2,0.3,0.4 as 0, and 0.5,0.6,0.7,0.8,0.9 as a 1, which means my frames would skip if I used a round number(as I did). So I've changed the code to this:

if(hspeed = 0 && vspeed = 0)
current_frame +=0;
else
current_frame +=4/30;



if(keyboard_check(vk_up))
{
vspeed = -3;
if(current_frame > 3.4)
current_frame = -0.6;
}

if(keyboard_check_released(vk_up))
{
vspeed = 0;
current_frame = 1;
}

if(keyboard_check(vk_down))
{
vspeed = 3;
if(current_frame > 7.4 || current_frame < 4)
current_frame = 4;
}
if(keyboard_check_released(vk_down))
{
vspeed = 0;
current_frame = 5;
}

if(keyboard_check(vk_left))
{
hspeed = -3;
if(current_frame > 11.4 || current_frame < 7.6)
current_frame = 7.6;
}
if(keyboard_check_released(vk_left))
{
hspeed = 0;
current_frame = 9;
}

if(keyboard_check(vk_right))
{
hspeed = 3;
if(current_frame > 15.4 || current_frame < 11.6)
current_frame = 11.6;
}

if(keyboard_check_released(vk_right))
{
hspeed = 0;
current_frame = 13;
}

Which made everything run smooth.
And yeah, having everything besides the draw in draw event could have caused the issues, which was not the case now tho.
< >
Showing 1-2 of 2 comments
Per page: 1530 50

Date Posted: Oct 27, 2014 @ 12:34am
Posts: 2