Page 1 of 1
cool demos and miscellania
Posted: Fri Dec 29, 2017 11:58 am
by jojomickymack
I thought that parallaxing tilemaps with STI would be difficult - not so, just add some offsets and multiply the dx values for background layers by 0.9 or lower depending on the rate you want it to scroll. I'm certain there's a better way just using layers in a single map, but this appears to be working.
- parallax_follow.gif (466.53 KiB) Viewed 2754 times
Re: cool demos and miscellania
Posted: Sun Dec 31, 2017 6:49 am
by jojomickymack
Somebody was trying to attach a texture to a physics world polygon shape, it can be done using a mesh. Polygons have vertices in the physics world and when they're rendered by graphics.drawPolygon() and there's a limit of 8. That's standard for box2d, the reason being you can assemble multiple polygons together to make whatever shape you want.
A mesh has unlimited vertices - unfortunately the way the tables of points get returned from calls to Body:getWorldPoints(shape:getPoints()) doesn't match up with mesh:setVertices(), so you've got to pack the coordinates into the mesh tables before rendering it with graphics.draw().
Provided that is happening, textured meshes with physics world vertices works pretty well in love2d!
- texture.gif (376.14 KiB) Viewed 2699 times
Re: cool demos and miscellania
Posted: Sat Jan 06, 2018 12:03 pm
by jojomickymack
Instead of scaling and translating based on the position of the player, instead use the center of the window or the position of the mouse.
Code: Select all
dx = (love.graphics.getWidth() / 2) - (love.graphics.getWidth() / 2) / scale
dy = (love.graphics.getHeight() / 2) - (love.graphics.getHeight() / 2) / scale
--dx = (love.mouse.getX()) - (love.graphics.getWidth() / 2) / scale
--dy = (love.mouse.getY()) - (love.graphics.getHeight() / 2) / scale
love.graphics.scale(scale)
love.graphics.translate(-dx, -dy)
- zoom_to_center.gif (433.72 KiB) Viewed 2564 times