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.
help platformer game
Re: help platformer game
There's a section on this wonderful article that describes how to implement slopes.
- luislasonbra
- Citizen
- Posts: 60
- Joined: Sun Jun 24, 2012 1:57 pm
Re: help platformer game
sorry but I understand nothing.Kingdaro wrote:There's a section on this wonderful article that describes how to implement slopes.
I just need to know how to implement outstanding collisions.
Re: help platformer game
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).
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).
- luislasonbra
- Citizen
- Posts: 60
- Joined: Sun Jun 24, 2012 1:57 pm
Re: help platformer game
hello I need is to go up and down slope.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).
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
please help.
Who is online
Users browsing this forum: No registered users and 3 guests