• 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 Issue with Moving up slope in 32x32 2D platformer project

D

Derikwhatever

Guest
Okay so this project is a 2D platformer using 32x32 sprites for everything so far.
My player sprite has a constant collision mask of an ellipse and i handle all my sprite drawing in the draw event that allows for animated sprites and sprite rotation that bypasses changing the mask by using a different variable than image_angle so I can rotate my sprite while on a slope but not the collision mask as this allows for the smoothest effect i've been able to acheive. This is my draw event:
Code:
//Setting sprite variables
if sprite_state = 0
{
sprite_index = spr_subject_idle;
}
if sprite_state = 1
{
sprite_index = spr_subject_walking;
}
if sprite_state = 2
{
sprite_index = spr_subject_jumping;
}

//Sprite rotation

var maxcheck = 16;
if place_meeting(x,y+1,obj_ground){
//Find p1
for (i=0;i<=maxcheck;i+=1){
if position_meeting(bbox_left,bbox_bottom+i,obj_ground){
p1=i;
break;
}
}
//Find p2
for (i=0;i<=maxcheck;i+=1){
if position_meeting(bbox_right,bbox_bottom+i,obj_ground){
p2=i;
break;
}
}
//Now, rotate the sprite!
render_angle = round((point_direction(bbox_left,bbox_bottom+round(p1),bbox_right,bbox_bottom+round(p2))));
draw_sprite_ext(sprite_index, image_index,x,y, image_xscale, image_yscale, render_angle, image_blend, image_alpha);
}
else
{
draw_sprite_ext(sprite_index, image_index,x,y, image_xscale, image_yscale, render_angle, image_blend, image_alpha);
}
and my step:
Code:
///Input, Collision, and Sprites
//Get our inputs
Key_Left = keyboard_check_direct(ord("A"));
Key_Right = keyboard_check_direct(ord("D"));
Key_Jump = keyboard_check_direct(vk_space);
//Move left and right
if (Key_Left)
{
hsp = -2;
image_xscale = -1;
//sprite_index = spr_subject_walking;
sprite_state = 1;
}

if (Key_Right)
{
hsp = 2;
image_xscale = 1;
//sprite_index = spr_subject_walking;
sprite_state = 1;
}

//Neutral Input = 0 movement
if ((Key_Right && Key_Left) or (!Key_Right && !Key_Left))
{
hsp = 0;
//sprite_index = spr_subject_idle;
sprite_state = 0;
}

//Jumping
if (Key_Jump)
{
if (grounded) vsp =-8;
//sprite_index = spr_subject_jumping;
sprite_state = 2;
}
vsp+= grav;

//Vertical Collison
if place_meeting(x,y+vsp,obj_ground)
{
while (!place_meeting(x,y+sign(vsp),obj_ground)) y+=sign(vsp);
if (sign(vsp) ==1) grounded = 1;
vsp = 0;
}
else
{
grounded = 0;
}

//Horizontal Collision
if place_meeting(x+hsp,y,obj_ground)
{
yplus = 0;
while (place_meeting(x+hsp,y-yplus,obj_ground) && yplus <= abs(1*hsp)) yplus += 1;
if place_meeting(x+hsp,y-yplus,obj_ground)
{
while (!place_meeting(x+sign(hsp),y,obj_ground)) x+=sign(hsp);
hsp = 0;
}
else
{
y -= yplus;
}
}

//Commit to movement
x += hsp;
y += vsp;
and my create event:
Code:
vsp = 0;
hsp = 0;
grav = 0.5;
image_speed = 0.1;
mask_index = spr_player_collision_mask
// Creates a new variable with the "angle" at 0 (aka. pointing right)
render_angle = 0;
sprite_state = 0;
My issue is that though sprite movement is smooth when going down a slope or any regular movement when walking going up the slope the sprite doesn't move smoothly. I've tried handling this issue in many ways with no luck maybe i'm missing something obvious but as i stated i handle all of the sprite changes in the draw event and the collision mask is constantly an ellipse shape regardless of sprite change. I use an ellipse for the collision mask because it produces the best effect when walking down the slope and the sprite moves smoothly except for when walking up a slope. Any questions I will try to answer as quickly as possible and I sincerely appreciate any help i can get.
 
Top