cool demos and miscellania
- jojomickymack
- Prole
- Posts: 45
- Joined: Tue Dec 26, 2017 4:52 pm
cool demos and miscellania
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.
- Attachments
-
- parallax_test001.love
- (26.86 KiB) Downloaded 111 times
- jojomickymack
- Prole
- Posts: 45
- Joined: Tue Dec 26, 2017 4:52 pm
Re: cool demos and miscellania
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!
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!
- Attachments
-
- polygon001.love
- (149.05 KiB) Downloaded 96 times
- jojomickymack
- Prole
- Posts: 45
- Joined: Tue Dec 26, 2017 4:52 pm
Re: cool demos and miscellania
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)
- Attachments
-
- zoom_to_point.love
- (465.95 KiB) Downloaded 100 times
Who is online
Users browsing this forum: Bing [Bot] and 5 guests