Different Devices with different Screen sizes but the same os.

Previous topic - Next topic

Crivens

That's pretty much what I do anyway. All my graphics are rescaled at app startup (only the once though unless you update the graphics version) and then I base all calculations on the target resolution (eg. Retina). When I want to put something on the screen I just multiply by the scale calcs, and for the mouse I divide. Seems to work.

Personally though even though I used 3D to simulate a 2D environment for the game I'm going to do the lot in 3D (even menu) next time (assuming Gernots new 3DES 2D code works now) so no mucking around and the only downside is memory (graphics won't be scaled).

Cheers
Current fave quote: Cause you like musicians and I like people with boobs.

Crivens

Well my game is 3D so it doesn't look any different just more of the play area is shown on an iPad. My menus which are scaled do look fatter but not to a level that I'm that bothered right now (just want to finish the damn thing). Wouldn't be too hard to take the aspect ratio into account though.

Cheers
Current fave quote: Cause you like musicians and I like people with boobs.

Slydog

I second the 'SETSCALE' command!
Imagine, no matter the physical resolution of the device, if you did a 'SETSCALE 1.0, 1.0' (or 'SETSCALE 480.0, 320.0'), then all other references would then be relative to this scale.

The top/left corner would be (0,0), the center of the screen would be (0.5, 0.5), and bottom/right would be (1.0,1.0)
(Or whatever scale you specified).

But, to make it perfect, you would need a 'scale' command for each sprite (it would mimic something like 'STRETCHSPRITE').
Why?  A 48x48 sprite would look different on different sized screens.
So in the above scale (1.0, 1.0), you would set the scale for that sprite using something like:
Code (glbasic) Select
SCALESPRITE sprite_id, 0.1, 0.1
That would mean whenever you draw that sprite, scale it to 1/10th of the screen for both the x and y.
This could be handled in the 'LOADSPRITE' command too with additional optional parameters.

Then, to draw that sprite at the bottom right of the screen, you would use:
Code (glbasic) Select
LOCAL screen_width# = 1.0, screen_height# = 1.0
LOCAL sprite_width# = 0.1, sprite_height# = 0.1
SETSCALE screen_width, screen_height
SCALESPRITE sprite_id, sprite_width, sprite_height
DRAWSPRITE sprite_id, screen_width - sprite_width, screen_height - sprite_height


I guess you could do the above fairly easily on your own, using your own ratios etc.  (And STRETCHSPRITE or POLYVECTORS for the sprite displaying)
But it may make it easier for beginners to implement a resolution independent game.


Now, regarding aspect ratios . . . this would stretch or compress your graphics if the device has a different aspect ratio than what you expected.  The easiest way, do nothing and accept it. 

Or have a new command 'GETASPECTRATIO' that returns a float (3/2, 16/9) etc, then multiply your screen scale 'y' value above to this ratio.  So your new screen ratio may be (1.0, 1.2).  But then relative positioning is more difficult as before you could just use '1.0' for the bottom edge, so  you can't hard code that value in your positioning code.  Or, also allow a percentage value when positioning such as: DRAWSPRITE id, 90%, 90%.

No clear obvious method I guess.
My current project (WIP) :: TwistedMaze <<  [Updated: 2015-11-25]

Kitty Hello

should that setscale also affect the viewport calls?

Crivens

Gernot, since we are on the subject, have you given any more thought to the idea of allowing project settings to have an exclude list? If you remember we talked about using the 9998x9999 trick to get the max resolution to allow universal apps, but the iPhone/iPod4 might not be quite upto the task for Retina gameplay while the 4S is fine (and non-retina is great for everything).

Essentially it would just be an option in the iOS project settings really. Essentially if using 9998x9999 (or 9999x99998 - although a max portrait/landscape option might be nicer) then have an exclude list you could add to that have different resolutions. So in my example I would set iPhone4 and iPod4 to have a set resolution of 320x480 and everything else would be maxed. So then the 4S would be 640x960 and the iPad would get it's max resolution (although can include them too if for example iPad1 hasn't got enough power so use lower resolution) but anything else would get 320x480. Can't see it being too hard to implement no?

I take it that the idea of changing resolution any time you want (so menus can be high res on iPhone4 but then the game itself switches to low res and we can work out ourselves if device can handle it (4S stays high res all the time)) is a complete no-no still? I know you completely rejected it before but now you are looking at all these scaling changes perhaps it would easier to implement.

Cheers
Current fave quote: Cause you like musicians and I like people with boobs.