[SOLVED] Help with rotation

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
User avatar
zikesha93
Prole
Posts: 11
Joined: Thu Sep 10, 2015 9:00 am
Location: your underwear

[SOLVED] Help with rotation

Post by zikesha93 »

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.
screenshot 2
screenshot 2
Screen Shot 2015-10-18 at 4.33.45 PM.png (26.53 KiB) Viewed 3014 times
screenshot 1
screenshot 1
Screen Shot 2015-10-18 at 4.28.51 PM.png (22.16 KiB) Viewed 3014 times
FPS_POLY.love
File Download
(2.03 KiB) Downloaded 204 times
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).
Last edited by zikesha93 on Fri Oct 30, 2015 2:30 pm, edited 1 time in total.
User avatar
zikesha93
Prole
Posts: 11
Joined: Thu Sep 10, 2015 9:00 am
Location: your underwear

Re: Help with rotation

Post by zikesha93 »

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.

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
WOW COMPUTERS ARE SOOO STUPID!!!
User avatar
zorg
Party member
Posts: 3465
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

Re: Help with rotation

Post by zorg »

zikesha93 wrote:

Code: Select all

    
       -- why
or...

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
or at least, that's how your snippet can be optimized... without other info about it, this may be wrong though.
Me and my stuff :3True 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.
User avatar
zikesha93
Prole
Posts: 11
Joined: Thu Sep 10, 2015 9:00 am
Location: your underwear

[SOLVED] Help with rotation

Post by zikesha93 »

zorg wrote:
zikesha93 wrote:

Code: Select all

    
       -- why
or...

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
or at least, that's how your snippet can be optimized... without other info about it, this may be wrong though.
Good idea

--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
--rotate left

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
Post Reply

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 1 guest