I use the full physics engine or AABB collision for most of my tests / demos, but you probably want something in between. Take a look at Hardon Collider if you haven't already, it's pretty good.
If you aren't planning on having much else you could write some kind of simple slope handler thing that prevents the player from ever being below the slope, but that will be kind of a waste if you're going to eventually include platforms or something and have to do collision checks for those too.
Foreground/Background Scrolling Implementation
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
- The Burrito
- Party member
- Posts: 153
- Joined: Mon Sep 21, 2009 12:14 am
- Contact:
Re: Foreground/Background Scrolling Implementation
I see, let me expand on my "slope-collision" idea a bit to see if the results are good enough. I'll make sure to check out Hardon Collider, though, thanks for the heads up!
Re: Foreground/Background Scrolling Implementation
I don't know what your theory is, but most of the time for non-AABB collisions people use the separating axis theorem. Here is a VERY detailed explanation of it, though there is no code to see what is going on.
That said, both Box2D (and it looks like HardonCollider as well) use SAT if you don't want to melt your brain.
That said, both Box2D (and it looks like HardonCollider as well) use SAT if you don't want to melt your brain.
- AntonioModer
- Party member
- Posts: 202
- Joined: Fri Jun 15, 2012 5:31 pm
- Location: Belarus
- Contact:
Re: Foreground/Background Scrolling Implementation
LOVE 0.8.0 background scrolling
Code: Select all
camera = {}
camera.x = 0;
camera.y = 0;
--== BACKGROUND ==--
-- Setup --
backgr = {};
backgr.image = love.graphics.newImage("image.png");
backgr.imageSize = backgr.image:getWidth();
backgr.spriteBatch = love.graphics.newSpriteBatch(backgr.image, 9); -- =9 if screen=640x480, backgr.imageSize=512 !!!
function drawBackground()
love.graphics.setColor(255,255,255,255)
local floor, backgr, camera = math.floor, backgr, camera;
backgr.spriteBatch:clear()
backgr.spriteBatch:bind()
for x = floor((camera.x-(love.graphics.getWidth()/2)+0)/backgr.imageSize),
floor((camera.x+(love.graphics.getWidth()/2)-0)/backgr.imageSize) do
for y = floor((camera.y-(love.graphics.getHeight()/2)+0)/backgr.imageSize),
floor((camera.y+(love.graphics.getHeight()/2)-0)/backgr.imageSize) do
backgr.spriteBatch:add(x*backgr.imageSize, y*backgr.imageSize)
end
end
backgr.spriteBatch:unbind()
love.graphics.draw(backgr.spriteBatch,0,0);
end
Who is online
Users browsing this forum: Ahrefs [Bot], Bing [Bot], Google [Bot], Semrush [Bot] and 1 guest