Well, that would be a problem - but rotating everything 90? at load
time, or doing it with some external tool, should be trivial. Check
out SGE, SDL_gfx and the like, or if you’re doing custom load time
processing anyway, just roll your own.
As for the game code, you don’t really have to do anything. Nothing
says origin must be in the top left corner - and in fact, several
graphics APIs and some image file formats put it in the bottom left
corner instead. (Having Y increase downwards is just a computer
thing, probably originating from the most common way of refreshing
CRTs.) Most of us are used to top left origo systems, but other than
that, any orientation works just fine.
Now, if you’re porting a working game that’s built for a different
orientation, or if you just can’t be arsed to think in a different
coordinate system, just throw in a thin layer over the SDL API or
something.
The “transform” for absolute coordinates:
display_x = y;
display_y = display_height - x;
Note that you’ll need to “flip” rects when dealing with SDL, as you
can’t use negative rect sizes; that is:
rect.x = y;
rect.w = h;
rect.y = (display_height - x) + w;
rect.h = w;
For blitting full surfaces (sprites) to the screen, only .x and .y are
considered, but you still need to deal with the sprite size, so:
rect.x = y;
rect.y = (display_height - x) + sprite.h;
…and of course, as I first pointed out, you’ll need to (pre-)rotate
all graphics one way or another for this to work.
(No formulae verified or anything, but they’re simple enough that I
might actually have managed to get them right.
//David Olofson - Programmer, Composer, Open Source Advocate
.------- http://olofson.net - Games, SDL examples -------.
| http://zeespace.net - 2.5D rendering engine |
| http://audiality.org - Music/audio engine |
| http://eel.olofson.net - Real time scripting |
’-- http://www.reologica.se - Rheology instrumentation --'On Saturday 05 January 2008, Edward Byard wrote:
Yes, especially when you have graphics created for a landscape
orientation!