Hi I was working on a simple dungeon crawler maze, I am basically drawing walls on the screen with love.draw.polygon().
I placed everything into neat tables so i don't have to retype the co-ordinates. The units go by width 100, height 100.
You can use the arrow keys to move around (navigate the table when key is released). I am sort of stuck with the rotation part. I am using the , and . keys to rotate (, is rotate counter clockwise . is rotate clockwise).
The problem is when I rotate the co-ords go off, Is there an easy way to do this?
I want to rotate into a new table and keep the orientation right with x and y.
Also Im really wasting a lot of space with empty polygons just to keep things square. This means the collision does not work and you can go straight through walls.
My aim is to make a simple FPS Dungeon Crawler like some of the first DOS games.
x = x array in table (left and right)
y = y array in table (forward and backwards)
t = table chunk with a bunch of walls for each step.
v[t][x][y][j] would get you a point. v[t][x][y] would get you a bunch of points in a tables (one polygon).
[SOLVED] Help with rotation
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
[SOLVED] Help with rotation
Last edited by zikesha93 on Fri Oct 30, 2015 2:30 pm, edited 1 time in total.
Re: Help with rotation
I figured it out. you just have to map each co-ordinate yourself manually each time the map table changes to keep the orientation in place.
So you would need to get the area of your x and y and just string in lots and lots of if statements for each possible co-ord.
WOW COMPUTERS ARE SOOO STUPID!!!
So you would need to get the area of your x and y and just string in lots and lots of if statements for each possible co-ord.
Code: Select all
if x == 1 and y == 1 then x = new_x;y = new_y end
if x == 2 and y == 1 then x = new_x;y = new_y end
if x == 3 and y == 1 then x = new_x;y = new_y end
if x == 4 and y == 1 then x = new_x;y = new_y end
if x == 5 and y == 1 then x = new_x;y = new_y end
if x == 1 and y == 2 then x = new_x;y = new_y end
if x == 2 and y == 2 then x = new_x;y = new_y end
if x == 3 and y == 2 then x = new_x;y = new_y end
if x == 4 and y == 2 then x = new_x;y = new_y end
if x == 5 and y == 2 then x = new_x;y = new_y end
if x == 1 and y == 3 then x = new_x;y = new_y end
if x == 2 and y == 3 then x = new_x;y = new_y end
if x == 3 and y == 3 then x = new_x;y = new_y end
if x == 4 and y == 3 then x = new_x;y = new_y end
if x == 5 and y == 3 then x = new_x;y = new_y end
if x == 1 and y == 4 then x = new_x;y = new_y end
if x == 2 and y == 4 then x = new_x;y = new_y end
if x == 3 and y == 4 then x = new_x;y = new_y end
if x == 4 and y == 4 then x = new_x;y = new_y end
if x == 5 and y == 4 then x = new_x;y = new_y end
if x == 1 and y == 5 then x = new_x;y = new_y end
if x == 2 and y == 5 then x = new_x;y = new_y end
if x == 3 and y == 5 then x = new_x;y = new_y end
if x == 4 and y == 5 then x = new_x;y = new_y end
if x == 5 and y == 5 then x = new_x;y = new_y end
- zorg
- Party member
- Posts: 3465
- Joined: Thu Dec 13, 2012 2:55 pm
- Location: Absurdistan, Hungary
- Contact:
Re: Help with rotation
or...zikesha93 wrote:Code: Select all
-- why
Code: Select all
for i= 0,all_possible_x_values do
for j= 0,all_possible_y_values do
x = new_x; y = new_y
end
end
Me and my stuff True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
[SOLVED] Help with rotation
Good ideazorg wrote:or...zikesha93 wrote:Code: Select all
-- why
or at least, that's how your snippet can be optimized... without other info about it, this may be wrong though.Code: Select all
for i= 0,all_possible_x_values do for j= 0,all_possible_y_values do x = new_x; y = new_y end end
--rotate right
Code: Select all
-- rotating right
for i= 0,all_possible_x_values do
for j= 0,all_possible_y_values do
x = i + change_in_x; y = j + change_in_y
end
end
Code: Select all
-- rotating left
for i= 0,all_possible_x_values do
for j= 0,all_possible_y_values do
x = i - change_in_x; y = j - change_in_y
end
end
Who is online
Users browsing this forum: Bing [Bot] and 3 guests