Page 1 of 1
help platformer game
Posted: Thu Dec 04, 2014 8:20 pm
by luislasonbra
hello
I am creating a game mario style, but I have problems with my game slope, noce how to implement this type of collision.
if someone could give me an example or some documentation on the subject, it would help me a lot.
hope your answers.
here I leave my example.
Re: help platformer game
Posted: Thu Dec 04, 2014 9:12 pm
by Kingdaro
There's a section on
this wonderful article that describes how to implement slopes.
Re: help platformer game
Posted: Fri Dec 05, 2014 1:17 am
by luislasonbra
sorry but I understand nothing.
I just need to know how to implement outstanding collisions.
Re: help platformer game
Posted: Fri Dec 05, 2014 6:09 am
by ivan
Take a look at the
Fizz library.
Representing slopes as "lines" is the approach used there.
The basic technique is projecting your shape onto the line and comparing the projected values (Separating axis theorem).
Re: help platformer game
Posted: Fri Dec 12, 2014 6:34 pm
by luislasonbra
ivan wrote:Take a look at the
Fizz library.
Representing slopes as "lines" is the approach used there.
The basic technique is projecting your shape onto the line and comparing the projected values (Separating axis theorem).
hello I need is to go up and down slope.
the code that I have so far is as follows
responsible for checking the slope is:
Code: Select all
function checkForSlopes(diry, dirx)
if tilemap.map[p.ytile + 1][p.xtile] == 2 then
p.ytile = p.ytile + 1;
p.y = p.y + tilemap.map.tileH;
end
if tilemap.map[p.ytile][p.xtile] == 2 and diry ~= -1 then
if diry == 1 then
-- p.y = (p.ytile + 1) * tilemap.map.tileH - (p.h + 32);
p.y = (p.ytile + 1) * tilemap.map.tileH - (p.h + 32);
end
local xpos = p.x - p.xtile * tilemap.map.tileW;
p.onSlope = tilemap.map[p.ytile][p.xtile] == 2;
if tilemap.map[p.ytile][p.xtile] == 2 then
-- up left 4
p.addy = xpos;
p._y = ((p.ytile + 1) * tilemap.map.tileH) - p.h - p.addy;
end
else
-- (p.onSlope == true and dirx == 1) or
if (p.onSlope == true and dirx == 1) or (p.onSlope == true and dirx == -1) then
p.ytile = p.ytile - 1;
p.y = p.y - tilemap.map.tileH;
p._y = p.y;
end
p.onSlope = false;
end
end
but I have several problems going up and down the slope.
please help.