Rotating collision with a rotating map
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Rotating collision with a rotating map
Hi, i'm using a tile map that rotates around its center, and i need consistent collision on each tile that will stay in the exact location and rotation as each tile. the issue is that all the tiles are rendered through love.graphics.draw, and when i rotate them with love.graphics.rotate and love.graphics.translated, the exact location of the tiles cannot be found, since their x or y value doesn't actually change. Is there some way to either get the position of the tiles after they are rotated and translated, or is there a way to also rotate all collision boxes in the same manner
-
- Party member
- Posts: 107
- Joined: Wed Oct 15, 2014 5:00 pm
- Location: Yorkshire, England
Re: Rotating collision with a rotating map
Hi, do you need to rotate your collisions? If the map is rotating on the screen their map position wont change, just the place you are drawing them. As far as your collisions are concerned the map wouldnt have moved at all. I may have misunderstood your question though.
Code: Select all
if not wearTheseGlasses() then
chewing_on_trashcan = true
end
Re: Rotating collision with a rotating map
hi, this is what my map is doing
this is one position where the map's rotation is 0. however, the game i'm making will have the map rotate in order to manipulate physics objects on the map, sort of like a pachinko puzzle, or one of these things
here is a case where the map is rotated
each tile is an 8x8 square, and i need a system where the collision boxes will maintain the same position and rotation as each tile. However, the tile's x and y coordinates remain unchanged, since rotation/translation doesn't leave behind any gettable x or y coordinates.
this is one position where the map's rotation is 0. however, the game i'm making will have the map rotate in order to manipulate physics objects on the map, sort of like a pachinko puzzle, or one of these things
here is a case where the map is rotated
each tile is an 8x8 square, and i need a system where the collision boxes will maintain the same position and rotation as each tile. However, the tile's x and y coordinates remain unchanged, since rotation/translation doesn't leave behind any gettable x or y coordinates.
Re: Rotating collision with a rotating map
The map rotation/tilting doesn't need to affect the collisions and tile positions at all. You could just visually rotate and tilt the map and apply forces to the objects (ie. the ball) based on the rotation and tilting values you got.
- yetneverdone
- Party member
- Posts: 446
- Joined: Sat Sep 24, 2016 11:20 am
- Contact:
Re: Rotating collision with a rotating map
You can use love.graphics.rotation() to rotate all of your visuals. And with love.graphics.translate(), you can easily get the points
My GameDev Website
Going Home:A Pixelated Horror Game
My Repositories!
Follow me lovingly!
Nga pala, pinoy ako.
Going Home:A Pixelated Horror Game
My Repositories!
Follow me lovingly!
Nga pala, pinoy ako.
Re: Rotating collision with a rotating map
the problem is that collision boxes aren't rotated by love.graphics.rotation, only the tiles are. the collision boxes are just coordinates that are being defined. and i already use love.graphics.rotation and that just rotates all the images, but it doesn't help since the collision doesn't move or rotate at allyetneverdone wrote: ↑Sun Jun 11, 2017 11:07 am You can use love.graphics.rotation() to rotate all of your visuals. And with love.graphics.translate(), you can easily get the points
So essentially use a camera and rotate it, but apply the forces to the movable objects instead? that sounds feasible so i might try it
- yetneverdone
- Party member
- Posts: 446
- Joined: Sat Sep 24, 2016 11:20 am
- Contact:
Re: Rotating collision with a rotating map
May i know what you use for your collision boxes?
My GameDev Website
Going Home:A Pixelated Horror Game
My Repositories!
Follow me lovingly!
Nga pala, pinoy ako.
Going Home:A Pixelated Horror Game
My Repositories!
Follow me lovingly!
Nga pala, pinoy ako.
Re: Rotating collision with a rotating map
im using boundingbox.lua which was on the love site
https://love2d.org/wiki/BoundingBox.lua
im trying to avoid using actual physics and rather revert to simple gravity and velocity for the project, but i do want some form of collision, working at least along 90 degree angles
Re: Rotating collision with a rotating map
Alright so i found a solution to what i'm saying. To get collision points to rotate and transform alongside the visual tilemap, i rotated all the points around the same origin the map was on, which produced good results
dx = xvertex - xaxis
dy = yvertex - yaxis
x = cos(θ) * dx - sin(θ) * dy + xaxis
y = sin(θ) * dx - cos(θ) * dy + yaxis
thank you to everyone that helped out
dx = xvertex - xaxis
dy = yvertex - yaxis
x = cos(θ) * dx - sin(θ) * dy + xaxis
y = sin(θ) * dx - cos(θ) * dy + yaxis
thank you to everyone that helped out
Who is online
Users browsing this forum: Bing [Bot], Google [Bot] and 190 guests