Universal Screen Size support.

Previous topic - Next topic

AMateus

Hello,

I'm newbie regarding coding for the mobile platform and I have a few doubts, so I hope someone can help me. I post here because resolutions and orientation between different hardware is my main doubt.

The scenario is a game coded for desktop with a resolution normal resolution. Let's say 800x600.

- What happen if I pick a resolution like 480 x 320 (iPhone landscape mode) and the game is executed in iPad?! Is it automatically centered and gets a black border? Or is stretched? And what about android (and the other supported platforms)?

- Is it a best practice to code with fixed minimum resolution and stretch the screen for higher resolutions (or center the game) or should we code relative x,y, so we can use the getdesktopsize and use it? What is your experience?

- Can we force a user to play the game in landscape mode in hardware that supports it?

Sorry for all the questions but as I don't have any mobile hardware is difficult to get the picture :)

Thanks in advance,
António

ampos

On iOS if you make your game 480x320 it will be scaled by the iOS himself (with black borders on iPad). I think it is the same on WebOS TouchPad.

On Android, the game will be drawn at coordinate 0,0 of the screen, so you get a (little) screen game in a corner of the device; I have no way to scaleup by the os as iOS do.

You can force to play in any orientation. The target device will open the orientation as you set in GLB projects settings.

About how to design your game... thats the matter.

Perhaps you want to do it in the lowest resolution, but on devices with larger screens your game will look pixelated.

Another solution is the one by ... where you have your graphics on the highest resolution and they are scaled by his function; so you end with all your graphics resized to your current device resolution.

And another one is to draw all the game into a virtual screen and resize it to fill your target. This solution is the easiest one, but also has the highest performance drop. If you want a high fps game perhaps this is not your solution.
check my web and/or my blog :D
http://diniplay.blogspot.com (devblog)
http://www.ampostata.org
http://ampostata.blogspot.com
I own PC-Win, MacBook 13", iPhone 3G/3GS/4G and iPAC-WinCE

spacefractal

You could also choice to use 2 set of texture:
One small and one double up texture (example one 1024x1024 and one 2048x2048 for the tile texture).

The game logic is the same, but all graphics might draw with x2, in that way the game would not look blocky on iPad (example).

Also remember to support both way for landscape mode (can been checked really easy), elsewise Apple reject it (as least for iPad).

and yes Ambos is the easist one, just been aware framerate can been dropped for extreme much graphics, but it depend of design of course.
Genius.Greedy Mouse - Karma Miwa - Spot Race - CatchOut - PowerUp Elevation - The beagle Jam - Cave Heroes 2023 - https://spacefractal.itch.io/

AMateus

#18
Quote from: ampos on 2011-Sep-29
where you have your graphics on the highest resolution and they are scaled by his function; so you end with all your graphics resized to your current device resolution.

You mean if the resolution on iOS or Android is higher than the current desktop resolution the SO automatically resize the screen?

So, if I understand correctly, the logical approach is to get the current desktop size with GETSCREENSIZE and code all the positions relatively instead of absolute? Of course that for this solution we should use "separate images sets for each separate device resolution" :)

Thank you,
António

spacefractal

Android can also rescale automatic too, if you not doing high resoulution. But its might been blocky of course.

its depend the game of course.

My game is example a tiled based puzzle game, and its use tree different of tile textures: 1024x1024, 2048x2048 and 4096x4096. The  game pick that one that is closes to the real resolution and downscale the last bit of it. Only onscreen button icons, fonts etc do I use one size texture, because its not need to rescale them, or upscaling here is not a problem really. So its some kind of balance, what is need for the game. This is what I do.

With the above trick in mind, you could also do 2 sizes of offbuffer screen (example do a either 480x320 or 960x640 offbuffer), but gameplay game logic still use one of them (the graphics can either downscaling or upscalering, but users dont detect the game logic internal only use one resoulution)....

There is no reason to use higher texture if it not need to that
Genius.Greedy Mouse - Karma Miwa - Spot Race - CatchOut - PowerUp Elevation - The beagle Jam - Cave Heroes 2023 - https://spacefractal.itch.io/

spicypixel

http://www.spicypixel.net | http://www.facebook.com/SpicyPixel.NET

Comps Owned - ZX.81, ZX.48K, ZX.128K+2, Vic20, C64, Atari-ST, A500.600.1200, PC, Apple Mini-Mac.

ampos

Look now at the first post...
check my web and/or my blog :D
http://diniplay.blogspot.com (devblog)
http://www.ampostata.org
http://ampostata.blogspot.com
I own PC-Win, MacBook 13", iPhone 3G/3GS/4G and iPAC-WinCE

spicypixel

#22
Quote from: ampos on 2011-Sep-19
No, I don't. All my touch areas are defined using ZONES lib, and they are also scaled by the createzone() function himself.

Hi Ampos I've started using your Zones Lib and find it very handy, thank you :) One thing that I noticed was the zones rescale according to a proportional screen. If my screen scaling is proportional and I retain the aspect ratio the zones are perfect. However I wanted to include an option in my menu to have Aspect Ratio On/Off (ugly as it may look sometimes) but in the CreateZone function I can't fathom out how to get it correct.

Code (glbasic) Select

FUNCTION GE_CreateZone: ZoneNum, Xcoord, Ycoord, Width, Height
LOCAL m,r,x1,x2,y1,y2,x,y,xz,yz,z,xd,yd

x1=MIN(Xcoord,Xcoord+Width)
x2=MAX(Xcoord,Xcoord+Width)
y1=MIN(Ycoord,Ycoord+Height)
y2=MAX(Ycoord,Ycoord+Height)


r=GE_ZoneProperty(ZoneNum,6)
IF r=-1
m=BOUNDS(zones[],0)
REDIM zones[m+1]
ELSE
m=r
ENDIF

xz = GE_TargetScrX%/vscreenx ; yz = GE_TargetScrY%/vscreeny
z  = MIN(xz,yz)

IF xz > yz
xd = (GE_TargetScrX%-(vscreenx*z))/2
yd = 0
ELSE
xd = 0
yd = (GE_TargetScrY%-(vscreeny*z))/2
ENDIF

zones[m].x=(x1*z)+xd
zones[m].y=(y1*z)+yd
zones[m].w=(x2-x1)*z
zones[m].h=(y2-y1)*z
zones[m].n=ZoneNum
ENDFUNCTION


I've added the "IF xz > yz" part as changes only need to be made in one axis dependent on portrait or landscape but I can't get my head around how to correctly calculate the .x start and .w in my (portrait) game. How can I make the routine not be aspect ratio correct??

Thanks in advance :doubt:
http://www.spicypixel.net | http://www.facebook.com/SpicyPixel.NET

Comps Owned - ZX.81, ZX.48K, ZX.128K+2, Vic20, C64, Atari-ST, A500.600.1200, PC, Apple Mini-Mac.

Falstaff

Just an FYI to everyone, I *love* this technique and implemented it in my game, but for whatever reason even though it may work on many devices, it didn't work on my ASUS eeePad Transformer tablet running android honeycomb 3.2. Nothing drawn onto a virtual screen that used CREATESCREEN would later render, meaning using this technique you only get a black screen. So far I haven't decided on what other approach would work on that device.. (although apparently stretchsprite worked on that one device)

So yeah.. frustrating ;/

ampos

It should be something similar to this (pseudocode)

Code (glbasic) Select
xz=targetscrx/vscreenx; yz=targetscry/vscreeny

zone.x=x1*xz
zone.y=y1*yz
zone.w=(x2-x1)*xz
zone.h=(y2-y1)*yz


If the screen does not maintain ratio, all x,y,w,h coordinates/sizes are just multiplied by the zoom, no "delta x" (xd as I call it) are used.
check my web and/or my blog :D
http://diniplay.blogspot.com (devblog)
http://www.ampostata.org
http://ampostata.blogspot.com
I own PC-Win, MacBook 13", iPhone 3G/3GS/4G and iPAC-WinCE

spicypixel

Quote from: ampos on 2011-Oct-17
If the screen does not maintain ratio, all x,y,w,h coordinates/sizes are just multiplied by the zoom, no "delta x" (xd as I call it) are used.

Cheers Ampos, will experiment later ;)
http://www.spicypixel.net | http://www.facebook.com/SpicyPixel.NET

Comps Owned - ZX.81, ZX.48K, ZX.128K+2, Vic20, C64, Atari-ST, A500.600.1200, PC, Apple Mini-Mac.