help platformer game

General discussion about LÖVE, Lua, game development, puns, and unicorns.
Post Reply
User avatar
luislasonbra
Citizen
Posts: 60
Joined: Sun Jun 24, 2012 1:57 pm

help platformer game

Post 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.

Image

here I leave my example.
Platformer Game.love
(3.92 KiB) Downloaded 149 times
User avatar
Kingdaro
Party member
Posts: 395
Joined: Sun Jul 18, 2010 3:08 am

Re: help platformer game

Post by Kingdaro »

There's a section on this wonderful article that describes how to implement slopes.
User avatar
luislasonbra
Citizen
Posts: 60
Joined: Sun Jun 24, 2012 1:57 pm

Re: help platformer game

Post by luislasonbra »

Kingdaro wrote:There's a section on this wonderful article that describes how to implement slopes.
sorry but I understand nothing.
I just need to know how to implement outstanding collisions.
User avatar
ivan
Party member
Posts: 1911
Joined: Fri Mar 07, 2008 1:39 pm
Contact:

Re: help platformer game

Post 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).
User avatar
luislasonbra
Citizen
Posts: 60
Joined: Sun Jun 24, 2012 1:57 pm

Re: help platformer game

Post 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.

Image

the code that I have so far is as follows
mySlopeGame.love
(3.43 KiB) Downloaded 154 times
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.
Post Reply

Who is online

Users browsing this forum: No registered users and 64 guests