More efficient platformer

Z

zuvizu

Guest
I was wondering if there is a better way to handle the "physics" for my project jumper.
See I just made the player jump and have it add to it twice until it starts falling.
I also have a ground pound and sprint ability.
Anyway, the main problems are the player jumps too high, doesn't always land directly on the platform and sometimes gets stuck on the edge.
The platform is solid, but if it isn't the player falls through.
Any suggestions?
 
N

Never Mind

Guest
You could take a break.. check out a tutorial, then come back with a fresh perspective.

Here's one!
 
Just an FYI for the future too, you'll get better responses and more quality answers if you show us the code in the areas you're concerned about. Without code, we can guess and theorize all day, but since there's an endless number of ways to do things, we won't get anywhere.
 
Z

zuvizu

Guest
Okay, I am back.
Sorry, I don't have access to the computer now.
I have a problem because my player only goes in one direction, ground pounds and jumps higher when the button is held.
For the most part, I think I could do the jump by adding to the jump speed variable, but the ground pound is a problem.
Is there a simple way to make the player move in one direction as smoothly?
Edit: I forgot to mention the player speeds up and doesn't have a constant speed.
 
Z

zuvizu

Guest
Okay, after a little fiddling around, I managed to get it too work for the most part, but there is one final problem.
See, when the player lands it stops moving, I can make him run again by press the run button again, but it really is a problem.
https://drive.google.com/file/d/0B4BzMTMaPr9-NkxEamY3RTkxX1E/view?usp=sharing
Information about object: obj_skipper
Sprite: spr_skipper
Solid: false
Visible: true
Depth: 0
Persistent: false
Parent:
Children:
Mask:
No Physics Object
Create Event:
execute code:

///Initialize Variables
grav = 0.2;
hsp = 0;
vsp = 0;
movespeed = 4;
image_speed = room_speed/4;
sprint = false;
dead = false;

Alarm Event for alarm 0:
execute code:

///falling platforms
if(global.call){
global.number++;
}
if(global.loop < 5){
alarm[0] = (room_speed/4);
}
else
{
alarm[0] = (room_speed/8);
}

Alarm Event for alarm 1:
execute code:

timer();
alarm[1] = room_speed;

Step Event:
execute code:

//Get the player's input
key_enter = keyboard_check_pressed(vk_enter);
key_shift = -keyboard_check(vk_shift);
key_jump = keyboard_check_pressed(vk_space);

//React to inputs
if(!dead){
if(key_enter){
if(movespeed < 10){
movespeed += grav;
}
if(!sprint){
hsp = movespeed;
}
else
{
hsp = movespeed*2;
}
}
if (vsp < 10) vsp += grav;

if ((place_meeting(x,y+1,obj_platform) && (key_jump)))
{
vsp = -hsp/2;
}
}

//Horizontal Collision
if (place_meeting(x+1,y,obj_platform))
{
while(!place_meeting(x+1,y,obj_platform))
{
x += sign(hsp);
}
hsp = 0;
}
x += hsp;
//Vertical Collision
if (place_meeting(x,y+vsp,obj_platform))
{
while(!place_meeting(x,y+sign(vsp),obj_platform))
{
y += sign(vsp);
}
vsp = 0;
}
y += vsp;
//diagnal collision
if(place_meeting(x+hsp, y+vsp, obj_platform))
{
while(!place_meeting(x+sign(hsp), y + sign(vsp), obj_platform))
{
x+= sign(hsp);
y+= sign(vsp);
}
hsp = 0;
vsp = 0;
}

Collision Event with object obj_add:
execute code:

with(other){
global.add = true;
x += 1200;
}

Collision Event with object obj_coin:
execute code:

global.sc++;
audio_play_sound(snd_coin,0,false);

Other Event: Outside Room:
execute code:

dead = true;
hsp = 0;
vsp = 0;
 
Z

zuvizu

Guest
Okay, I have a temporary solution and a permanent.
The temporary solution is too simply get rid of the diagonal collision and make the player die when colliding with an object.
The permanent solution is too not tile the sprites.
That is make them different lengths and sizes.
That was not the full game, but really the endless running mode.
I can't make higher platforms with the temp solution, but I think I can work around it until I get a pixel artist...
 
Top