U
Unofficial Horse Extract
Guest
In Game Maker Studio 1.4.1772, I'm following this tutorial on how to make a sonic game in game maker and by the end of the first video I am getting stuck in the floors when I jump on them and stuck into walls while walking into them. Part of the issue may be my confusion with collision and origin mapping for my sprites, since I'm using the adventure sprites instead of the classic sprites (The sprites are based off multiples of 5 instead of 2 and are supposed to go a bit into the ground with the front layer). There are only two used objects, Sonic and collidable, a script, a room, and 6 sprites total to inspect so the program hopefully wouldn't be too confusing for outside eyes.
before jump:
after jump:
Here is the code I am using right now:
script: drawUser()
Sonic (object): Create:
(MAXIMUM_JUMPS is a macro value I'm using to try to manage having a single, double, or triple jump.)
(it was 16 in the video, but I kept messing with it because sonic was in the ground.)
Download Here
before jump:
after jump:
Here is the code I am using right now:
script: drawUser()
Code:
draw_sprite_ext(sprite_index, image_index, round(x), round(y), image_xscale, image_yscale, image_angle, image_blend, image_alpha);
Code:
acceleration = 0.1;
velocity = 0;
MAXSPEED = 10;
ground = false;
availableJumps = MAXIMUM_JUMPS - 1;
Step:
Code:
///movement
if keyboard_check(vk_left) && !place_meeting(x+(abs(velocity)*-1)-1,y, collidable)
{
velocity -= acceleration*2;
image_xscale = abs(image_xscale);
}
if keyboard_check(vk_right) && !place_meeting(x+abs(velocity)+1,y, collidable)
{
velocity += acceleration*2;
image_xscale = -abs(image_xscale);
}
if ((velocity > 0 && place_meeting(x+abs(velocity)+1,y, collidable)) || (velocity < 0 && place_meeting(x+abs(velocity)+1,y, collidable))) || (velocity > -acceleration && velocity < acceleration)
velocity = 0;
if velocity > 0
velocity -= acceleration;
else if velocity < 0
velocity += acceleration;
//speed cap
if (abs(velocity) > MAXSPEED)
velocity = MAXSPEED*sign((velocity));
x += velocity;
//gravity
if place_meeting(x, y + vspeed + 1, collidable, )
{
ground = true;
gravity = 0;
}
else
{
ground = false;
gravity = 0.25;
if vspeed > 8
vspeed = 8;
}
//jumping
if(availableJumps > 0 && keyboard_check_pressed(ord('Z')))
{
vspeed = -7;
availableJumps -= 1;
}
//animation
if(ground)
{
if velocity == 0
sprite_index = Sonic_idle;
else if abs(velocity)>0
sprite_index = Sonic_walk;
else
{
}
image_speed = 0.2 + abs(velocity/20);
availableJumps = MAXIMUM_JUMPS;
}
else
{
sprite_index = Sonic_jump;
image_speed = 0.2 + abs(velocity/20);
}
Collision:
Code:
move_contact_all(direction, 40)
vspeed = 0;
Draw:
Code:
drawUser();
Last edited by a moderator: