Page 1 of 1
Efficient tile-based scrolling with rotation?
Posted: Sun Aug 19, 2012 11:03 pm
by thecontrarian42
Hi, i'm new to love and i'm making a game similar to Realm of the Mad God. my maps are huge 2d arrays corresponding to arrays of quads and a tile atlas. ive covered the existing tutorials on the various methods of tile based scrolling, but they all lack any rotation. i've figured out how to create a "viewport" (rectangle) and move it out the screen, and only rendering the little square of the map that the viewport sees, and thats easy to do when you have a rectangle referencing to a matrix (basically flooring the xy of the top left corner and ceiling the bottom right and you have your ranges), but i cant figure out how to evaluate what is inside of a rotated rectangle.
PLEASE ASSIST <3,
Daniel
Re: Efficient tile-based scrolling with rotation?
Posted: Mon Aug 20, 2012 2:59 am
by Lafolie
Just do all your update stuff as if it was not rotated and then in the draw step rotate the entire draw operation with
love.graphics.rotate.
Re: Efficient tile-based scrolling with rotation?
Posted: Tue Aug 21, 2012 1:32 am
by thecontrarian42
thanks Lafolie, but that isnt what i need. when i do that it just rotates the rectangle of the screen arround the top left corner, or the x0y0 point. i need a way to rotate my viewport rectangle, not the actual screen. my viewport doesnt actually have anything to do with the drawing to the screen, its merely conceptual. it exists solely to tell the functions that determines what part of the map actually does get drawn to the screen. its like instead of moving the window (what the love.graphics transform functions do) i'm moving the world outside the window, except that whatever the window doesnt see doesnt actually exist as viewable data. i really need help more with matrices than graphics. once i can get the program to tell me what squares are inside its rotated rectangle, the rest is easy.
Re: Efficient tile-based scrolling with rotation?
Posted: Tue Aug 21, 2012 3:43 am
by Lafolie
Re: Efficient tile-based scrolling with rotation?
Posted: Tue Aug 21, 2012 11:39 am
by kexisse
It sounds like you're trying to rotate the camera itself. There are a number of camera implementations out there, for example in
vrld's hump library.