Hello everyone, i searched through forums and couldn't find a solution
Maybe i searched not that good.
And yes, im not that experienced yet, thats why i took Love2d to get all basic understanding for the game coding.
Im not going to make a platformer, just top-side (isometric) quest-like game (detective actualy) with 8 possible directions of movement.
So i came to the point when i need to put some collision to what i have. But what i could find is that you draw boxes with position x, y and width height. Which doesn't work with isometric view that much. So i thought that, Either i would need to create 3-4 collision boxes for each tile (which is alot) or i could manage a mind-screwing task of creating collision map, which would work as a top-down map for the isometric view and would provide collision blocks in needed places (So when characters moves around, his movement is doubled at that collision map and collision counts there). Addtionally this would manage collision array, which would be x1.5 of tile map array.
Is there any way to create angled collision boxes ? Or solution for this type of thing?
Isometric game collision
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Re: Isometric game collision
Ok, so you don't need to have "tilted" collision boxes at all.
Just use axis-aligned rectangles then render them as an isometric tiles.
My point it, your collision code should NOT be dictated by the rendering projection you are using.
You want to keep your rendering and game logic independent of each other.
Now if you want to convert mouse coordinates to isometric grid coordinates that's a little more complicated.
Just use axis-aligned rectangles then render them as an isometric tiles.
My point it, your collision code should NOT be dictated by the rendering projection you are using.
You want to keep your rendering and game logic independent of each other.
Now if you want to convert mouse coordinates to isometric grid coordinates that's a little more complicated.
Re: Isometric game collision
so, thats exactly what i was thinking about second optionivan wrote:Ok, so you don't need to have "tilted" collision boxes at all.
Just use axis-aligned rectangles then render them as an isometric tiles.
My point it, your collision code should NOT be dictated by the rendering projection you are using.
You want to keep your rendering and game logic independent of each other.
Now if you want to convert mouse coordinates to isometric grid coordinates that's a little more complicated.
Well, thanks, i will try to manage it and see how this will all turn out
P.S. im from other country, so i might do mistakes in English words and i don't mind corrections of my mistakes
Re: Isometric game collision
I have the same problems so...
NECROPOST
You can use polygons for isometric projection like this. All you need is to draw the top diamond, left diamond and right diamond. Later on if you used polygons, you can work with polygon mesh and create textures like in Minecraft. Its just a drawing style so forget about isometric collision, such a thing is impossible because we are dealing with two things at one go. x and y. What this means is that there is a new variable called z, this z variable is either a sum or difference of x and y.
In programming when we want to remember something we store them in variables. In Lua variables are not type specific and global by default.
--later on you want these in two variables zx and zy not just z because collision is 2d
z= (+x,+y) --zx
z = (-x,+y) --zy
z = (-x,-y) --zx
z = (+x,-y) --zy
These are sort of like fake octants. Basically we have a new co-ordinate system that is based on x and y sums or differences.
zx = x+y
zy = y-x
zx = -x-y
zy = x+y
So zx and zy become some values just like x and y. Test this out with love.graphics.print() and move around.
Collision is always one of the two things. An Inequality (see Lua BoundingBox) wich works for moving objects such as bullets or other entities or a matrix such as map[z/units] == 0
Just to note, you might want to use math.floor to round down to an integer or math.ceil to round up. Never use floating points inside indexes. This is Lua suicide map[0.283838][0.3883833].
Matrix Isometric collision is very complex because rendering 3d into 2d is not easy, there surds involved like arctan 1/squareroot(2) which is like 35.264 degrees (3.s.f). You need a 3D engine to render this which is not necessary since you can plot something close enough without those calculations to determine the angles of each face.
Look at cube in the source code. its a table with points for the polygon, each side top, left and right.
If isometric rotation is mandatory then I would recommend a 3d engine altogether.
For basic 2d isometric matrix collision, use the fake octants zx and zy and divide them into units. I've never done this so its just a theory. I think it works the same.
Anyway back to the topic.
Then movement is something like
Try add in some Boolean logic in the if statements for collision. Here is an example of what it might look
Lua Bounding Box
Tell me if it works out, I'll try not to necropost but I had the same problem and I am working on this too. Lets learn this together (^_^).
NECROPOST
You can use polygons for isometric projection like this. All you need is to draw the top diamond, left diamond and right diamond. Later on if you used polygons, you can work with polygon mesh and create textures like in Minecraft. Its just a drawing style so forget about isometric collision, such a thing is impossible because we are dealing with two things at one go. x and y. What this means is that there is a new variable called z, this z variable is either a sum or difference of x and y.
In programming when we want to remember something we store them in variables. In Lua variables are not type specific and global by default.
--later on you want these in two variables zx and zy not just z because collision is 2d
z= (+x,+y) --zx
z = (-x,+y) --zy
z = (-x,-y) --zx
z = (+x,-y) --zy
These are sort of like fake octants. Basically we have a new co-ordinate system that is based on x and y sums or differences.
zx = x+y
zy = y-x
zx = -x-y
zy = x+y
So zx and zy become some values just like x and y. Test this out with love.graphics.print() and move around.
Collision is always one of the two things. An Inequality (see Lua BoundingBox) wich works for moving objects such as bullets or other entities or a matrix such as map[z/units] == 0
Just to note, you might want to use math.floor to round down to an integer or math.ceil to round up. Never use floating points inside indexes. This is Lua suicide map[0.283838][0.3883833].
Matrix Isometric collision is very complex because rendering 3d into 2d is not easy, there surds involved like arctan 1/squareroot(2) which is like 35.264 degrees (3.s.f). You need a 3D engine to render this which is not necessary since you can plot something close enough without those calculations to determine the angles of each face.
Look at cube in the source code. its a table with points for the polygon, each side top, left and right.
If isometric rotation is mandatory then I would recommend a 3d engine altogether.
For basic 2d isometric matrix collision, use the fake octants zx and zy and divide them into units. I've never done this so its just a theory. I think it works the same.
Anyway back to the topic.
Then movement is something like
Code: Select all
if love.keyboard.isDown('up') then
c.y = c.y - 1
c.x = c.x + 1
end
if love.keyboard.isDown('right') then
c.y = c.y + 1
c.x = c.x + 1
end
if love.keyboard.isDown('down') then
c.y = c.y + 1
c.x = c.x - 1
end
if love.keyboard.isDown('left') then
c.y = c.y - 1
c.x = c.x - 1
end
Code: Select all
if love.keyboard.isDown('up') and (c.zy < o.zy) then
c.y = c.y - 1
c.x = c.x + 1
end
if love.keyboard.isDown('right') and (c.zx > o.zx) then
c.y = c.y + 1
c.x = c.x + 1
end
if love.keyboard.isDown('down') and (c.zy < o.zy) then
c.y = c.y + 1
c.x = c.x - 1
end
if love.keyboard.isDown('left') and (c.zx > o.zx) then
c.y = c.y - 1
c.x = c.x - 1
end
Tell me if it works out, I'll try not to necropost but I had the same problem and I am working on this too. Lets learn this together (^_^).
-
- Citizen
- Posts: 54
- Joined: Thu Oct 24, 2013 1:29 am
Re: Isometric game collision
perfect explanation ... I do have some problems tho!
-
- Party member
- Posts: 234
- Joined: Mon Aug 29, 2016 8:51 am
Re: Isometric game collision
It's way easier to just create the game logic in top down and then convert to iso coordinates using some math tricks. That way you don't have to design a new A* pathfinding, collision, anything. Just make the game topdown and change the draw logic to use converted cartesian to iso coordinates.
Who is online
Users browsing this forum: Ahrefs [Bot], Bing [Bot], Google [Bot] and 4 guests