GLBasic forum

Codesnippets => Code Snippets => Topic started by: ampos on 2011-Oct-25

Title: Z Project - universal screen size scaling system
Post by: ampos on 2011-Oct-25
Yes, it is (again) a UNIVERSAL SCREEN SIZE SCALING SYSTEM   :S

I had the idea to port ALL gfx commands to use polyvectors and be resolution independents, so we can code to just 1 resolution and will work at all platforms, using the (almost) fastest polyvector system, targetting any target resolution with/without aspect ratio.

To start, I have made the initialization function and ported the very first function, DRAWSPRITE. If one of each us made 1 function, it could be done real soon. I will copy your functions to this first post to keep it updated. Please, post the function you are going to do before so no one else does the same.

HOW-TO USE

In your proyect, you only need to change the CONSTANTS x_orig and y_orig with the values of the screen size you are coding for (the size that will draw at size 1:1).

Call the "z_init" function at the start of your program. If you dont want it to keep the aspect ratio of your graphics, call it with value=0

That's all, just call the functions as if they were original GLBasic commands, same syntax. (Note that I added the "color" param to the function as optional; as it is going to be used by polyvector anyway, just put it!)

You call the functions with "absolute" values, as if they were for a fixed screen size. The commands themself will scale your graphics to the device resolution, leaving black borders for unused screen.

In many console games (I recall some Wii examples) they draw a background that fills the entire screen and the game is drawn really in a center 4:3 "window" in the center of the screen. An iPAD (1024x768) resolution game will look similar in a 800x480 android device. If you do not want the screen to be filled with black borders, just do this:

Code (glbasic) Select
CLEARSCREEN -1 //if the entire screen is going to be redrawn, do not clear it before!
...your game here
SC()   //use this instead of showscreen

function SC:  //this routine will fill your entire screen with a nice background
   showscreen
   stretchsprite background,0,0,x_res,y_res
endfunction


Example:
   x_orig=1024;z_drawsprite id,512,0 will be always drawn at the center of the screen, even at a 320x240 screen resolution.

Code (glbasic) Select
// --------------------------------- //
// Project: ProjectoZ
// Start: Tuesday, October 25, 2011
// IDE Version: 10.118

GLOBAL x_offset,y_offset //offset to add to X&Y to display correctly
GLOBAL x_res,y_res //X&Y real screen size
GLOBAL x_zoom,y_zoom //zoom to scale sprites and so
GLOBAL x_orig=768,y_orig=1024 //the screen size our app is designed for
GLOBAL single_sheet=0 //1 IF all sprites in a single sheet

FUNCTION initZ: keep_ratio=0
LOCAL z

GETSCREENSIZE x_res,y_res

x_zoom=x_res/x_orig
y_zoom=y_res/y_orig

IF keep_ratio<>0
z=MIN(x_zoom,y_zoom)
x_zoom=z
    y_zoom=z
x_offset=(x_res-(x_orig*x_zoom))/2
y_offset=(y_res-(y_orig*y_zoom))/2
IF x_offset<1 THEN x_offset=0
IF y_offset<1 THEN y_offset=0

ENDIF

init_SC()

ENDFUNCTION

FUNCTION z_drawsprite: num%,x%,y%,color=0xFFFFFF
LOCAL sx,sy,x1,y1,x2,y2

GETSPRITESIZE num,sx,sy

x1=x_offset+(x*x_zoom)
x2=sx*x_zoom
y1=y_offset+(y*y_zoom)
y2=sy*y_zoom

// STRETCHSPRITE num,x1,y1,x2,y2

STARTPOLY num
POLYVECTOR x1,y1,0,0,color
POLYVECTOR x1,y1+y2,0,sy,color
POLYVECTOR x1+x2,y1+y2,sx,sy,color
POLYVECTOR x1+x2,y1,sx,0,color
ENDPOLY

ENDFUNCTION

FUNCTION z_drawanim: num%,frame%,x%,y%,w%,h%,color=0xFFFFFF
LOCAL sx,sy,x1,y1,x2,y2,ancho,alto,xa,ya

GETSPRITESIZE num,sx,sy

x1=x_offset+(x*x_zoom)
x2=w*x_zoom
y1=y_offset+(y*y_zoom)
y2=h*y_zoom

ancho=sx/w;alto=sy/h
ya=INTEGER(frame/ancho)*h
xa=MOD(frame,ancho)*w

// STRETCHANIM num,frame,x1,y1,x2,y2

IF single_sheet=0 THEN STARTPOLY num
POLYVECTOR x1,y1,xa,ya,color //TL
POLYVECTOR x1,y1+y2,xa,ya+h,color //BL
POLYVECTOR x1+x2,y1+y2,xa+w,ya+h,color //
POLYVECTOR x1+x2,y1,xa+w,ya,color
IF single_sheet=0
ENDPOLY
ELSE
POLYNEWSTRIP
ENDIF
ENDFUNCTION

FUNCTION z_rotozoomanim: num%,frame%,x%,y%,w%,h%,ang,size,color=0xFFFFFF
LOCAL sx,sy,x1,y1,x2,y2,ancho,alto,xa,ya,x3,x4,y3,y4,xcos,ysin,xs,ys,sw,sh

GETSPRITESIZE num,sx,sy
sw=w;sh=h

x=x_offset+(x*x_zoom)-(((w*size)-w)/2)
w=w*x_zoom*size
y=y_offset+(y*y_zoom)-(((h*size)-h)/2)
h=h*y_zoom*size
INC x2,x1;INC y2,y1

ancho=sx/sw;alto=sy/sh
ya=INTEGER(frame/ancho)*sh
xa=MOD(frame,ancho)*sw

h=h/2
w=w/2
INC x,w
INC y,h

x1 = x
y1 = y
x2 = x
y2 = (y + h)
x3 = (x + w)
y3 = y
x4 = (x + w)
y4 = (y + h)

xcos = tCOS(ang)
ysin = tSIN(ang)

x1 = x - (xcos * w) - (ysin * h)
y1 = y - (xcos * h) + (ysin * w)

x2 = x - (xcos * w) + (ysin * h)
y2 = y + (xcos * h) + (ysin * w)

x3 = x + (xcos * w) - (ysin * h)
y3 = y - (xcos * h) - (ysin * w)

x4 = x + (xcos * w) + (ysin * h)
y4 = y + (xcos * h) - (ysin * w)

SELECT single_sheet
CASE 0
STARTPOLY num
POLYVECTOR x1, y1, xa, ya,color //TL
POLYVECTOR x2, y2, xa, ya + sh,color //BL
POLYVECTOR x4, y4, xa + sw, ya + sh,color //BR
POLYVECTOR x3, y3, xa + sw, ya,color //TR
ENDPOLY
CASE 1
POLYVECTOR x2, y2, xa, ya + sh,color //BL
POLYVECTOR x1, y1, xa, ya,color //TL
POLYVECTOR x4, y4, xa + sw, ya + sh,color //BR
POLYVECTOR x3, y3, xa + sw, ya,color //TR
POLYNEWSTRIP
ENDSELECT

ENDFUNCTION

FUNCTION z_print: t$,x,y,font=100,centered=1,zoom=1,color=0xFFFFFF,underline=0,italic=0
LOCAL fx,fy,l,c$,tx,ty,dx,dy,fxz,fyz,t1,t2,t3,t4,tl
LOCAL line_width=2 //width of the underline line in pixels at zoom 1 (100%)
LOCAL outline=2 //width of the outline in underline in pixels at zoom 1 (100%)
LOCAL und_pos=.9 //vertical position of underline (in % of Font Y size)
LOCAL ital_ang=.5 //inclination of font (in % of font X size)

GETSPRITESIZE font,fx,fy
fx=fx/16;fy=fy/16 //change to fy/8 if you dont use full charset fonts
        fxz=fx*zoom*x_zoom;fyz=fy*zoom*y_zoom
        tl=LEN(t$,1)*zoom*x_zoom

x=x_offset+(x*x_zoom)
y=y_offset+(y*y_zoom)

DEC x,(LEN(t$,1)*zoom*centered*x_zoom)/2

IF underline=1   
t1=line_width*(zoom*y_zoom);IF t1<1 THEN t1=1
t2=fxz/4
t3=fyz*und_pos
t4=outline*(zoom*x_zoom);IF t4<1 THEN t4=1

STARTPOLY   //this can be changed with a call to z_drawline...
POLYVECTOR x-t2-t4,y+t3-t4,0,0,0
POLYVECTOR x-t2-t4,y+t3+t1+t4,0,0,0
POLYVECTOR x+t2+tl+t4,y+t3+t1+t4,0,0,0
POLYVECTOR x+t2+tl+t4,y+t3-t4,0,0,0
ENDPOLY

STARTPOLY
POLYVECTOR x-t2,y+t3,0,0,color
POLYVECTOR x-t2,y+t3+t1,0,0,color
POLYVECTOR x+t2+tl,y+t3+t1,0,0,color
POLYVECTOR x+t2+tl,y+t3,0,0,color
ENDPOLY

ENDIF

    italic=italic*zoom*fx*ital_ang*x_zoom
STARTPOLY font,2
FOR n=0 TO LEN(t$)-1
c$=MID$(t$,n,1)
l=ASC(c$)

ty=ASR(l,4)
tx=INTEGER(MOD(l,ty*16))
dx=tx*fx
dy=ty*fy

POLYVECTOR x,y+fyz,dx,dy+fy,color //BL
POLYVECTOR x+italic,y,dx,dy+1,color //TL
POLYVECTOR x+fxz,y+fyz,dx+fx,dy+fy,color //BR
POLYVECTOR x+fxz+italic,y,dx+fx,dy+1,color //TR
POLYNEWSTRIP
INC x,LEN(c$,1)*zoom*x_zoom
NEXT
ENDPOLY
ENDFUNCTION

FUNCTION z_drawline: x1,y1,x2,y2,color=0xFFFFFF,width=1
LOCAL w=(x2-x1)*x_zoom
LOCAL h=(y2-y1)*y_zoom

x1=x_offset+(x1*x_zoom)
y1=y_offset+(y1*y_zoom)
x2=x_offset+(x2*x_zoom)
y2=y_offset+(y2*y_zoom)

width=width*x_zoom
glLineWidth (width)
DRAWLINE x1,y1,x2,y2,color
glLineWidth(1)

// STARTPOLY
// POLYVECTOR x1,y1,0,0,color
// POLYVECTOR x1+w,y1+h,0,0,color
// POLYVECTOR x1+w+1,y1+1+h,0,0,color
// POLYVECTOR x1+1,y1+1,0,0,color
// ENDPOLY

ENDFUNCTION

FUNCTION z_drawrect: x,y,w,h,color=0xFFFFFF

x=x_offset+(x*x_zoom)
y=y_offset+(y*y_zoom)
w=w*x_zoom
h=h*y_zoom

STARTPOLY
POLYVECTOR x,y,0,0,color
POLYVECTOR x,y+h,0,0,color
POLYVECTOR x+w,y+h,0,0,color
POLYVECTOR x+w,y,0,0,color
ENDPOLY

ENDFUNCTION

INLINE
#define OGL ::
typedef float           GLfloat;
ENDINLINE

INLINE
} extern "C" { void __stdcall glLineWidth( GLfloat width );; }; namespace __GLBASIC__ {
ENDINLINE
FUNCTION glLineWidth: width
INLINE
OGL glLineWidth(width);
ENDINLINE
ENDFUNCTION


INLINE
} //  + + + A T T E N T I O N + + +
// int __a__ needs to be a n^2 value.
// Higher values give better precision
// but larger lookup tables as well!

const unsigned int __a__ = 131072 ;
const DGInt __b__ = (360.0 / __a__) ;
const unsigned int __c__ = (__a__ - 1) ;
DGInt _sin_tbl_[__c__] ;
DGInt _cos_tbl_[__c__] ;
const DGInt __d__ = (1 / __b__);
namespace __GLBASIC__ {
ENDINLINE

FUNCTION init_SC:
INLINE
for(int i=0; i < __c__; ++i)
{
_sin_tbl_[i] = SIN( i * __b__ ) ;
_cos_tbl_[i] = COS( i * __b__ ) ;
}
ENDINLINE
ENDFUNCTION // INIT_SIN_COS_TABLES

// ------------------------------------------------------------- //
// ---  TCOS  ---
// ------------------------------------------------------------- //
FUNCTION tCOS: x // in degrees
INLINE
return _cos_tbl_[ (int)(x * __d__) & __c__ ] ;
ENDINLINE
ENDFUNCTION // TCOS



// ------------------------------------------------------------- //
// ---  TSIN  ---
// ------------------------------------------------------------- //
FUNCTION tSIN: x  // in degrees
INLINE
return _sin_tbl_[ (int)(x * __d__) & __c__ ] ;
ENDINLINE
ENDFUNCTION // TSIN






HOW TO MAKE FUNCTIONS

I think that the z_drawsprite function is easy enough to understand, but to clarify how to calculate target resolutions

Initial X & Y coordinates are calculated with

Code (glbasic) Select
x1=x_offset+(x*x_zoom)
y1=y_offset+(y*y_zoom)


You have to use, mandatory, x_offset & y_offset, as the init function will set this values correctly if the user wants or not "aspect ratio lock"

The target sprite sizes are easily calculated too with

Code (glbasic) Select
x2=sx*x_zoom
y2=sy*y_zoom


being sx and sy, current sprite size.

0.01 - Initial release
        - DRAWSPRITE
0.02 - PRINT (with attributes)
0.03 - DRAWLINE
          DRAWRECT
          Added a "+1" on z_print text print part to fix gfx glitches
0.04 - DRAWANIM (it needs in the function the size of the anim frame)
          ROTOZOOMANIM (it needs in the function the size of the anim frame
          Uses tCOS and tSIN for faster SIN/COS
          Updated PRINT to use POLYNEWSTRIP
          The variable SINGLESHEET can be used to use POLYNEWSTRIP when drawing multiple sprites from a single sheet.
          The DRAWLINE command has the option WIDTH, through OpenGL itself.
0.05- Minor update. Removed some old lines. Add more explanations for use.
0.06- RotoZoomAnim had a bug
Title: Re: Z Proyect
Post by: Wampus on 2011-Oct-25
Good stuff. Can be used as a basis for scalable control schemes too.
Title: Re: Z Proyect
Post by: ampos on 2011-Oct-26
Added  Z_PRINT.

Nobody wants to contribute?
Title: Re: Z Proyect
Post by: ampos on 2011-Dec-20
I have added more things:

DRAWANIM, that needs also the size of the sprite animation frame.

ROTOZOOMANIM, also need the frame size. It uses also tCOS and tSIN functions for speed.

The DRAWLINE get a WIDTH option, that is set using OpenGL.

PRINT uses POLYNEWSTRIP, making it much more faster.

Some functions read the global variable SINGLESHEET. If =1, they will use POLYNEWSTRIP, making it MUCH faster if you are drawing multiple sprites from the same sprite sheet.

Example:

You have a sheet with multiple flowers pictrures. You normally will use this to draw:

Code (glbasic) Select
FOREACH f IN flowers()
   Z_DRAWSPRITE f.id,f.x,f.y
NEXT
SHOWSCREEN


That will be

Code (glbasic) Select
FOREACH f IN flowers()
   Z_DRAWANIM f.id,f.frame,f.x,f.y
       {STARTPOLY f.id
       ...blah...blah POLYVECTOR
       ENDPOLY}
NEXT
SHOWSCREEN


Ok, the SINGLESHEET has to be done this way:

Code (glbasic) Select
SINGLESHEET=1
STARTPOLY id,2
FOREACH f IN flowers()
   Z_DRAWSPRITE f.id,f.x,f.y
NEXT
ENDPOLY
SHOWSCREEN


Will translate into:

Code (glbasic) Select
SINGLESHEET=1
STARTPOLY id,2
FOREACH f IN flowers()
   Z_DRAWSPRITE f.id,f.x,f.y
      {blah, blah... POLYVECTOR
      NEWPOLYSTRIP}
NEXT
ENDPOLY
SHOWSCREEN


Probably I will not create DRAWANIM or ROTOSPRITE as it can be used easily in ROTOZOOMANIM with frame=0

Title: Re: Z Proyect
Post by: bigsofty on 2011-Dec-20
Congrats and thanks Ampos, great stuff!  :good:
Title: Re: Z Proyect - universal screen size scaling system
Post by: Wampus on 2011-Dec-20
Ampos you are generous with your code.  :booze:

If anyone relatively new to GLBasic is reading this thread and isn't sure if they need code like this, YOU DO! It is kind of essential if you want games to work on multiple resolutions without necessarily knowing what the resolution will be. For example, with Android, your game could start in many different resolutions depending on device. The thing Ampos is doing with POLYVECTOR is also very useful. Although its more complicated than the sprite commands it is also quicker when used properly. That can make a big difference to performance on slower devices.
Title: Re: Z Proyect - universal screen size scaling system
Post by: monono on 2011-Dec-20
Nicely done. Much nicer than copying and scaling the screen. This is some kind of the approach I use too. I would change the name. "z". It reminds me of the 3th dimension."v" like "virtual screen" would suit better. :)
Title: Re: Z Proyect - universal screen size scaling system
Post by: Moru on 2011-Dec-20
Great stuff, this is the way I would like to do it. Naming with Z is a bit strange though, as Z-order usually is the order you paint it on the screen, from back to front. That was what I was expecting to find here :-)
Title: Re: Z Proyect - universal screen size scaling system
Post by: ampos on 2011-Dec-20
Really I dont remember why I call it "Proyect Z", perhaps it is best to call it...

PROJECT USSSS

universal screen size scaling system  :S
Title: Re: Z Project - universal screen size scaling system
Post by: Ruidesco on 2011-Dec-21
Better yet, swap "universal" for "standard" and call it Project S5. :D
Title: Re: Z Project - universal screen size scaling system
Post by: ampos on 2012-Feb-04
RotoZoomAnim had a bug

Code (glbasic) Select
xcos = tCOS(ang/4)
ysin = tSIN(ang/4)


and has to be

Code (glbasic) Select
xcos = tCOS(ang)
ysin = tSIN(ang)
Title: Re: Z Project - universal screen size scaling system
Post by: mrplant on 2012-Feb-05
great!
Title: Re: Z Project - universal screen size scaling system
Post by: mrplant on 2012-Feb-13
Hi Ampos.

In your z_print function you have a line of code:

   DRAWRECT x,y,2,2,0

what is this line for?
Just I remove it and everything still looks the same to me?

thanks
mrp
Title: Re: Z Project - universal screen size scaling system
Post by: ampos on 2012-Feb-13
It was just a reference on-screen "point", should not be gone to "final production"  =D

removed.
Title: Re: Z Project - universal screen size scaling system
Post by: mrplant on 2012-Feb-14
Thought that's what it would be but just wanted to make sure!

cheers Ampos!
Title: Re: Z Project - universal screen size scaling system
Post by: ampos on 2012-Feb-20
Z Proyect uses ployvector for all his drawing, that should be faster than "normal" sprite draws.

Also, some Android devices could not use "create screen"
Title: Re: Z Project - universal screen size scaling system
Post by: sionco on 2012-Feb-21
I'm not sure how to get this working,

I've pasted this, in a new source file in the project, 
Code (glbasic) Select

// --------------------------------- //
// Project: ProjectoZ
// Start: Tuesday, October 25, 2011
// IDE Version: 10.118

GLOBAL x_offset,y_offset //offset to add to X&Y to display correctly
GLOBAL x_res,y_res //X&Y real screen size
GLOBAL x_zoom,y_zoom //zoom to scale sprites and so
GLOBAL x_orig=768,y_orig=1024 //the screen size our app is designed for
GLOBAL single_sheet=0 //1 IF all sprites in a single sheet

FUNCTION initZ: keep_ratio=0
LOCAL z

GETSCREENSIZE x_res,y_res

x_zoom=x_res/x_orig
y_zoom=y_res/y_orig

IF keep_ratio<>0
z=MIN(x_zoom,y_zoom)
x_zoom=z
    y_zoom=z
x_offset=(x_res-(x_orig*x_zoom))/2
y_offset=(y_res-(y_orig*y_zoom))/2
IF x_offset<1 THEN x_offset=0
IF y_offset<1 THEN y_offset=0

ENDIF

init_SC()

ENDFUNCTION

FUNCTION z_drawsprite: num%,x%,y%,color=0xFFFFFF
LOCAL sx,sy,x1,y1,x2,y2

GETSPRITESIZE num,sx,sy

x1=x_offset+(x*x_zoom)
x2=sx*x_zoom
y1=y_offset+(y*y_zoom)
y2=sy*y_zoom

// STRETCHSPRITE num,x1,y1,x2,y2

STARTPOLY num
POLYVECTOR x1,y1,0,0,color
POLYVECTOR x1,y1+y2,0,sy,color
POLYVECTOR x1+x2,y1+y2,sx,sy,color
POLYVECTOR x1+x2,y1,sx,0,color
ENDPOLY

ENDFUNCTION

FUNCTION z_drawanim: num%,frame%,x%,y%,w%,h%,color=0xFFFFFF
LOCAL sx,sy,x1,y1,x2,y2,ancho,alto,xa,ya

GETSPRITESIZE num,sx,sy

x1=x_offset+(x*x_zoom)
x2=w*x_zoom
y1=y_offset+(y*y_zoom)
y2=h*y_zoom

ancho=sx/w;alto=sy/h
ya=INTEGER(frame/ancho)*h
xa=MOD(frame,ancho)*w

// STRETCHANIM num,frame,x1,y1,x2,y2

IF single_sheet=0 THEN STARTPOLY num
POLYVECTOR x1,y1,xa,ya,color //TL
POLYVECTOR x1,y1+y2,xa,ya+h,color //BL
POLYVECTOR x1+x2,y1+y2,xa+w,ya+h,color //
POLYVECTOR x1+x2,y1,xa+w,ya,color
IF single_sheet=0
ENDPOLY
ELSE
POLYNEWSTRIP
ENDIF
ENDFUNCTION

FUNCTION z_rotozoomanim: num%,frame%,x%,y%,w%,h%,ang,size,color=0xFFFFFF
LOCAL sx,sy,x1,y1,x2,y2,ancho,alto,xa,ya,x3,x4,y3,y4,xcos,ysin,xs,ys,sw,sh

GETSPRITESIZE num,sx,sy
sw=w;sh=h

x=x_offset+(x*x_zoom)-(((w*size)-w)/2)
w=w*x_zoom*size
y=y_offset+(y*y_zoom)-(((h*size)-h)/2)
h=h*y_zoom*size
INC x2,x1;INC y2,y1

ancho=sx/sw;alto=sy/sh
ya=INTEGER(frame/ancho)*sh
xa=MOD(frame,ancho)*sw

h=h/2
w=w/2
INC x,w
INC y,h

x1 = x
y1 = y
x2 = x
y2 = (y + h)
x3 = (x + w)
y3 = y
x4 = (x + w)
y4 = (y + h)

xcos = tCOS(ang)
ysin = tSIN(ang)

x1 = x - (xcos * w) - (ysin * h)
y1 = y - (xcos * h) + (ysin * w)

x2 = x - (xcos * w) + (ysin * h)
y2 = y + (xcos * h) + (ysin * w)

x3 = x + (xcos * w) - (ysin * h)
y3 = y - (xcos * h) - (ysin * w)

x4 = x + (xcos * w) + (ysin * h)
y4 = y + (xcos * h) - (ysin * w)

SELECT single_sheet
CASE 0
STARTPOLY num
POLYVECTOR x1, y1, xa, ya,color //TL
POLYVECTOR x2, y2, xa, ya + sh,color //BL
POLYVECTOR x4, y4, xa + sw, ya + sh,color //BR
POLYVECTOR x3, y3, xa + sw, ya,color //TR
ENDPOLY
CASE 1
POLYVECTOR x2, y2, xa, ya + sh,color //BL
POLYVECTOR x1, y1, xa, ya,color //TL
POLYVECTOR x4, y4, xa + sw, ya + sh,color //BR
POLYVECTOR x3, y3, xa + sw, ya,color //TR
POLYNEWSTRIP
ENDSELECT

ENDFUNCTION

FUNCTION z_print: t$,x,y,font=100,centered=1,zoom=1,color=0xFFFFFF,underline=0,italic=0
LOCAL fx,fy,l,c$,tx,ty,dx,dy,fxz,fyz,t1,t2,t3,t4,tl
LOCAL line_width=2 //width of the underline line in pixels at zoom 1 (100%)
LOCAL outline=2 //width of the outline in underline in pixels at zoom 1 (100%)
LOCAL und_pos=.9 //vertical position of underline (in % of Font Y size)
LOCAL ital_ang=.5 //inclination of font (in % of font X size)

GETSPRITESIZE font,fx,fy
fx=fx/16;fy=fy/16 //change to fy/8 if you dont use full charset fonts
        fxz=fx*zoom*x_zoom;fyz=fy*zoom*y_zoom
        tl=LEN(t$,1)*zoom*x_zoom

x=x_offset+(x*x_zoom)
y=y_offset+(y*y_zoom)

DEC x,(LEN(t$,1)*zoom*centered*x_zoom)/2

IF underline=1   
t1=line_width*(zoom*y_zoom);IF t1<1 THEN t1=1
t2=fxz/4
t3=fyz*und_pos
t4=outline*(zoom*x_zoom);IF t4<1 THEN t4=1

STARTPOLY   //this can be changed with a call to z_drawline...
POLYVECTOR x-t2-t4,y+t3-t4,0,0,0
POLYVECTOR x-t2-t4,y+t3+t1+t4,0,0,0
POLYVECTOR x+t2+tl+t4,y+t3+t1+t4,0,0,0
POLYVECTOR x+t2+tl+t4,y+t3-t4,0,0,0
ENDPOLY

STARTPOLY
POLYVECTOR x-t2,y+t3,0,0,color
POLYVECTOR x-t2,y+t3+t1,0,0,color
POLYVECTOR x+t2+tl,y+t3+t1,0,0,color
POLYVECTOR x+t2+tl,y+t3,0,0,color
ENDPOLY

ENDIF

    italic=italic*zoom*fx*ital_ang*x_zoom
STARTPOLY font,2
FOR n=0 TO LEN(t$)-1
c$=MID$(t$,n,1)
l=ASC(c$)

ty=ASR(l,4)
tx=INTEGER(MOD(l,ty*16))
dx=tx*fx
dy=ty*fy

POLYVECTOR x,y+fyz,dx,dy+fy,color //BL
POLYVECTOR x+italic,y,dx,dy+1,color //TL
POLYVECTOR x+fxz,y+fyz,dx+fx,dy+fy,color //BR
POLYVECTOR x+fxz+italic,y,dx+fx,dy+1,color //TR
POLYNEWSTRIP
INC x,LEN(c$,1)*zoom*x_zoom
NEXT
ENDPOLY
ENDFUNCTION

FUNCTION z_drawline: x1,y1,x2,y2,color=0xFFFFFF,width=1
LOCAL w=(x2-x1)*x_zoom
LOCAL h=(y2-y1)*y_zoom

x1=x_offset+(x1*x_zoom)
y1=y_offset+(y1*y_zoom)
x2=x_offset+(x2*x_zoom)
y2=y_offset+(y2*y_zoom)

width=width*x_zoom
glLineWidth (width)
DRAWLINE x1,y1,x2,y2,color
glLineWidth(1)

// STARTPOLY
// POLYVECTOR x1,y1,0,0,color
// POLYVECTOR x1+w,y1+h,0,0,color
// POLYVECTOR x1+w+1,y1+1+h,0,0,color
// POLYVECTOR x1+1,y1+1,0,0,color
// ENDPOLY

ENDFUNCTION

FUNCTION z_drawrect: x,y,w,h,color=0xFFFFFF

x=x_offset+(x*x_zoom)
y=y_offset+(y*y_zoom)
w=w*x_zoom
h=h*y_zoom

STARTPOLY
POLYVECTOR x,y,0,0,color
POLYVECTOR x,y+h,0,0,color
POLYVECTOR x+w,y+h,0,0,color
POLYVECTOR x+w,y,0,0,color
ENDPOLY

ENDFUNCTION

INLINE
#define OGL ::
typedef float           GLfloat;
ENDINLINE

INLINE
} extern "C" { void __stdcall glLineWidth( GLfloat width );; }; namespace __GLBASIC__ {
ENDINLINE
FUNCTION glLineWidth: width
INLINE
OGL glLineWidth(width);
ENDINLINE
ENDFUNCTION


INLINE
} //  + + + A T T E N T I O N + + +
// int __a__ needs to be a n^2 value.
// Higher values give better precision
// but larger lookup tables as well!

const unsigned int __a__ = 131072 ;
const DGInt __b__ = (360.0 / __a__) ;
const unsigned int __c__ = (__a__ - 1) ;
DGInt _sin_tbl_[__c__] ;
DGInt _cos_tbl_[__c__] ;
const DGInt __d__ = (1 / __b__);
namespace __GLBASIC__ {
ENDINLINE

FUNCTION init_SC:
INLINE
for(int i=0; i < __c__; ++i)
{
_sin_tbl_[i] = SIN( i * __b__ ) ;
_cos_tbl_[i] = COS( i * __b__ ) ;
}
ENDINLINE
ENDFUNCTION // INIT_SIN_COS_TABLES

// ------------------------------------------------------------- //
// ---  TCOS  ---
// ------------------------------------------------------------- //
FUNCTION tCOS: x // in degrees
INLINE
return _cos_tbl_[ (int)(x * __d__) & __c__ ] ;
ENDINLINE
ENDFUNCTION // TCOS



// ------------------------------------------------------------- //
// ---  TSIN  ---
// ------------------------------------------------------------- //
FUNCTION tSIN: x  // in degrees
INLINE
return _sin_tbl_[ (int)(x * __d__) & __c__ ] ;
ENDINLINE
ENDFUNCTION // TSIN







I have an image called player.png, could anyone give me a simple basic program showing how to use this to draw the sprite to the screen. I've tried, but can't get my head around it.
Title: Re: Z Project - universal screen size scaling system
Post by: ampos on 2012-Feb-21
Code (glbasic) Select
initz()
loadsprite "player.png",1
z_drawsprite (1,my_x,my_y)
showscreen
keywait


It should work.
Title: Re: Z Project - universal screen size scaling system
Post by: sionco on 2012-Feb-21
Thank you! that's some great work you've done!
Plays well on my pad and smaller mobile phone
Title: Re: Z Project - universal screen size scaling system
Post by: r0ber7 on 2012-Feb-22
This is perfect. I was thinking of doing the same thing, and now I find it has been done before. I'd like a zoom function in my game. Your work saves me a lot of work.   :good:
Title: Re: Z Project - universal screen size scaling system
Post by: ampos on 2012-Feb-22
That's the idea  =D
Title: Re: Z Project - universal screen size scaling system
Post by: sionco on 2012-Feb-24
Hi,

I´m having problems with using the mouse when the screen has been scaled down smaller on my android phone,  the phone is in landscape.   When I run the program and click a part of the screen a little sprite appears there, this works great running from the pc.  but on the android phone, it looks like the mouse hasn´t scaled correctly and the sprite appears much more towards the left of where
I´ve clicked and up. 
I´m using standard code:

Code (glbasic) Select


MOUSESTATE mx, my, b1, b2

if b1
   bombX = mx
   bombY = my
   z_drawanim(30,0,bombX,bombY,32,32)
Title: Re: Z Project - universal screen size scaling system
Post by: sionco on 2012-Feb-24
ps, it´s definetly the scaling, because if I use drawanim 30,0,bombX,bombY,  it draws it in the place it´s meant to be.
Title: Re: Z Project - universal screen size scaling system
Post by: ampos on 2012-Feb-24
The mouse coordinates are not scaled.

The game screen is rendered at 1024x768, but the display (and the mouse coordinates) are, in iphone 3G, 480x320.

The code to read mouse should be something like

Code (glbasic) Select
mousestate mx, my, b1,b2
mx=(mx/x_zoom)-x_offset
my=(my/y_zoom)-y_offset


(ps: I have not tested this, just typing on the fly, perhaps it is mx*x_zoom).

If you want to check mouse/screen clicks to elements, consider use my other lib, ZONES(), that has a CREATEZONE_RELATIVE that creates zones relatives to target screen size using absolute coordinates.
Title: Re: Z Project - universal screen size scaling system
Post by: sionco on 2012-Feb-26
Thanks, it worked perfectly
Title: Re: Z Project - universal screen size scaling system
Post by: mrplant on 2012-Mar-17
Ampos - I am doing some testing here - is there an older version of Z_Print floating about that does not use PolyVectors??

Can't seem to find it but sure I read it somewhere...

Title: Re: Z Project - universal screen size scaling system
Post by: ampos on 2012-Mar-18
No, there is a single/alone z_print function on another post, but it also uses polyvectors, as it is "necesary" to have zoomed print.

Why do not want to use polyvectors?
Title: Re: Z Project - universal screen size scaling system
Post by: mrplant on 2012-Mar-18
I am having a small problem with them - when I rescale the graphics there is the faintest of faintest lines around the outer edges of some graphics - when I replace the commands with STRETCHSPRITE instead - it is slower but doesn't have the problem..
This rears its ugly head when I am rescaling from the native resolution of my app 1024x768 up to say my 27" Mac screen of 2560x1440 or on the iPad3. It also occurs when downscaling to 960x480 for the iPhone 4s but is harder to see - text shows it up quite clearly.
I was using Scalesprite to identify what was causing the problem..
If I recompile using Scalesprite the problem does not occur.


   STRETCHSPRITE SpriteNum,X1,Y1,X2,Y2

//   STARTPOLY SpriteNum
//   POLYVECTOR X1,Y1,0,0,0xFFFFFF
//   POLYVECTOR X1,Y1+Y2,0,SY,0xFFFFFF
//   POLYVECTOR X1+X2,Y1+Y2,SX,SY,0xFFFFFF
//   POLYVECTOR X1+X2,Y1,SX,0,0xFFFFFF
//   ENDPOLY

If you take a look at the screenshots attached (and click to expand them) - Scale Graphics.png was taken running my app designed for 1024x768 - running on my iMac - see the file - it looks fine.
now compare that with the output I get replacing Stretchsprite with Polyvector commands above - see file PV Graphics.png - see the faint lines around graphics that aren't in the other version?
The PV text shows how my text is looking.

I am trying to figure out what the cause is as, as I say - it appears when downscaling or upscaling..
Could it just be rounding errors or something?

It is entirely reproducible here and is not limited to say just macs as I have written my code to conditionally compile  for Windows, Mac, iPhone and iPad  - only on the iPad running at native 1024x768 that I designed my graphics at does it look pixel perfect. All other resolutions have this feint line around the graphics ... Very strange..

It is more noticeable on the iPad 3 which is why I was testing using Stretchsprite - which solved the problem...

Would really like to use Polyvectors of course..

stumped.

[attachment deleted by admin]
Title: Re: Z Project - universal screen size scaling system
Post by: mrplant on 2012-Mar-18
Here is that man - extreme zoomed in using Photoshop to show clearly the unwanted lines alone the top and left side. The graphic itself is clean as you can see from one of my original screenshots.

SMOOTHSHADING TRUE OR FALSE makes no difference by the way. My graphics are all tile based 64x64 pixel sprites with no alpha channel png files. Either black and white or colour.

[attachment deleted by admin]
Title: Re: Z Project - universal screen size scaling system
Post by: Ian Price on 2012-Mar-18
Make sure you are using SMOOTHSHADING FALSE before applying the scaling. That should help.
Title: Re: Z Project - universal screen size scaling system
Post by: kanonet on 2012-Mar-18
Interesting, noticed the same problems with textures of 3D objects, didnt report it, cuz i could track it down to one command.
Maybe its related with the possibility to draw your texture multiple times with just one call, if you use texturecoordinates <0 etc...
to see what i mean use a image with size 64x64 and draw it with this polyvector:
Code (glbasic) Select
STARTPOLY circle
POLYVECTOR 64,64,-64,0, 0xffffff
POLYVECTOR 64,512,-64,128, 0xffffff
POLYVECTOR 512,512,64,128, 0xffffff
POLYVECTOR 512,64,64,0, 0xffffff
ENDPOLY

(you can do the same with textures for 3D objects)
as you can see, you can draw 1 sprite multiple time with only one call (dont know if this is intended/feature or bug). Maybe this +smothshading causes this lines, that you found.

BTW you can get rid of those lines if you set SMOTHSHADING FALSE. At least for polyvector, but it wont solve the problems for Textures of 3D objects.
Maybe someone should write a bugreport about this?
Title: Re: Z Project - universal screen size scaling system
Post by: mrplant on 2012-Mar-18
Its fixed!!! (at least in my Polyvector case like you mention, Kanonet)

:)

All a result of me misunderstanding the scope of the SMOOTHSHADING command.  :S

I had put SMOOTHSHADING FALSE at the start of my program a while back but it seemed to make no difference....
Then I read the docs - a SHOWSCREEN command resets the mode! DOH!

I put it into my main game loop and the problem is now solved...

I take it just doing a SHOWSCREEN followed by a SMOOTHSHADING FALSE (once) in my main game loop, is enough to cover all graphics calls  - polyvectors, grabsprites etc. - until the next SHOWSCREEN resets the Smoothshading mode again?

Seems to work just fine that way anyway...

Title: Re: Z Project - universal screen size scaling system
Post by: Slydog on 2012-Mar-19
You could have also put a transparent 1 pixel border around each of your sprites in your spritesheet.
That slight white line is caused by the polyvector creeping too close to the pixels surrounding your sprite, due to rounding issues, plus (before you set SMOOTHSHADING to false) caused by smoothing issues where it looks at the surrounding pixels in order to average the current pixel.
Title: Re: Z Project - universal screen size scaling system
Post by: mrplant on 2012-Mar-21
Thanks Slydog.

Its good to get a technical description of what caused this outline side effect in the first place - makes perfect sense now..
Title: Re: Z Project - universal screen size scaling system
Post by: r0ber7 on 2012-Apr-05
Ok, gonna try and implement this in my game now. If all goes well, by the end of the day I'll have a zoom function and better future compatibility for things like Android. Wish me luck. :)
Title: Re: Z Project - universal screen size scaling system
Post by: r0ber7 on 2012-Apr-05
Alright, I've got my zoom function working for most things except the spells.

I've run into a problem with z_rotozoomanim(). I'm not sure whether it's my code that's doing it or yours, so here's an example:

http://www.youtube.com/watch?v=TImD3uIc8wY

I'm rotating the fireball image according to the position of the mouse at point of release. The yellow rectangle is done by z_drawrect() and shows the x and y of the fireball type. It seems the x and y are properly scaled. But somehow the actual graphic drawn by z_rotozoomanim is not (when I zoom in, the starting point moves up). Any ideas? Either way, I will get to the bottom of this, because other than this it's been great using your code, muchas gracias.  :good:

Edit: Here is the same effect, taken a single z_rotozoomanim() call as a test to rule out anything from my fireball code causing this.

http://www.youtube.com/watch?v=sVs3DZgbI4c

Another edit: Seems like the size variable is the one giving the problems. Given a size of 1 the position of the sprite stays the same, but with a bigger size, it moves when scaled... I think I'll go see if I can correct that somewhere.

I FIXED IT!

Please edit the first post of this thread and modify z_rotozoomanim() to read like this:

Code (glbasic) Select

w=w*x_zoom
x=x_offset+(x*x_zoom)-(((w*size)-w)/2)
w=w*size

h=h*y_zoom
y=y_offset+(y*y_zoom)-(((h*size)-h)/2)
h=h*size


By multiplying with the zoom factor before calculating x and y position, it doesn't move.  =D

Proof of concept: http://www.youtube.com/watch?v=4BmKC7wKlgE

The dot in the upper left corner is a drawrect that marks the x & y start.  8)

Title: Re: Z Project - universal screen size scaling system
Post by: r0ber7 on 2012-Apr-06
I had some trouble with z_print() as well. It didn't get the font width right so my text would end up with each character overlapping the previous one to the left. I changed this:

Code (glbasic) Select

//INC x,LEN(c$,1)*zoom*x_zoom
INC x, fx*x_zoom


Now it works ok. I've made no effort to check for consistency so this may not be the best solution, but it works for me, so if you have the same problem give it a try.
Title: Re: Z Project - universal screen size scaling system
Post by: ampos on 2012-Apr-09
Thanks!

I will try it later and modify the post.
Title: Re: Z Project - universal screen size scaling system
Post by: ampos on 2012-Apr-18
Quote from: r0ber7 on 2012-Apr-06
I had some trouble with z_print() as well. It didn't get the font width right so my text would end up with each character overlapping the previous one to the left. I changed this:

Code (glbasic) Select

//INC x,LEN(c$,1)*zoom*x_zoom
INC x, fx*x_zoom


Now it works ok. I've made no effort to check for consistency so this may not be the best solution, but it works for me, so if you have the same problem give it a try.

Not tested fully yet, but your modificaction will work if you do not want to use font-kerning.
Title: Re: Z Project - universal screen size scaling system
Post by: kaotiklabs on 2012-Jun-12
Im having troubles with z_print.

the fonts are been writen in a black layer, without aplying alpha.
should I apply something else?
Title: Re: Z Project - universal screen size scaling system
Post by: onumad on 2012-Jun-14
I can't get z_print work fine  :help:

Code (glbasic) Select
GLOBAL myfont
main:
initZ(1)
SETSCREEN 400,600,0

myfont=GENFONT()
LOADSPRITE "Media/myfont.png", myfont
LOADFONT "Media/myfont.png", myfont

z_print("My litle test", 150,50,myfont)

SHOWSCREEN
MOUSEWAIT

END


Font file and screen capture attached


[attachment deleted by admin]
Title: Re: Z Project - universal screen size scaling system
Post by: Slydog on 2012-Jun-14
@onumad

I don't think you need this line, so try removing it and see if that helps:
Code (glbasic) Select
LOADSPRITE "Media/myfont.png", myfont

I don't *think* it would cause problems having that line, but could in the future.
Fonts and Sprites are separate and have different ids, and you shouldn't mix the two.
Title: Re: Z Project - universal screen size scaling system
Post by: kaotiklabs on 2012-Jun-15
Im not 100% sure, but it seems the font should be loaded here as sprite in order to work with polyvector.
At least is how Im using it because if not, anything is been printed in my app.

is that right??
Title: Re: Z Project - universal screen size scaling system
Post by: Slydog on 2012-Jun-15
Ha, after reading what 'z_print' actually is/does, you're right - it needs to be loaded as a sprite.
So, don't remove the 'LOADSPRITE' command, but remove the 'LOADFONT' command.
(I never used any functions of this library, so I was just guessing!)

Again, I don't think it will help the problem, just pointing out that it doesn't need to be there.
(Unless 'z_print' requires it for some reason?!)
Title: Re: Z Project - universal screen size scaling system
Post by: onumad on 2012-Jun-15
Thank you for replies, but If I remove the command LOADSPRITE, the text does not appear. If I remove the command LOADFONT, text is more collapsed   :doubt:
Title: Re: Z Project - universal screen size scaling system
Post by: r0ber7 on 2012-Jun-15
LOADFONT doesn't get used by z_print if I remember correctly. When I ported my game to z_project standards all LOADFONT commands had to be replaced with LOADSPRITE. Could you post a screenshot of the text collapsing? I had a problem with z_print too, it had to do with font kerning or something. Look at my previous posts here, I modified z_print and it now works fine for me. Maybe that helps?
Title: Re: Z Project - universal screen size scaling system
Post by: onumad on 2012-Jun-15
Thank you r0ber7. I saw your fix, but it works without kerning.

I made some changes on z_print function. Changes:
Code (glbasic) Select
FUNCTION z_print:  t$,x,y,font=100,centered=1,zoom=1,color=0xFFFFFF,underline=0,italic=0 to
Code (glbasic) Select
FUNCTION z_print: withkerning, t$,x,y,font=100,centered=1,zoom=1,color=0xFFFFFF,underline=0,italic=0and
Code (glbasic) Select
INC x,LEN(c$,1)*zoom*x_zoom to
Code (glbasic) Select
IF withkerning
    INC x,LEN(c$,1)*zoom*x_zoom
ELSE
    INC x, fx*x_zoom
ENDIF


my test:
Code (glbasic) Select
GLOBAL myfont
main:
initZ(1)
SETSCREEN 400,600,0

myfont=GENFONT()
LOADSPRITE "Media/myfont.png", myfont
//LOADFONT "Media/myfont.png", myfont

z_print(1, "My little test with kerning", 150,50,myfont)

z_print(0, "My little test without kerning", 10,150,myfont, 0)

SHOWSCREEN
MOUSEWAIT
END
And attached the output ::)

[attachment deleted by admin]
Title: Re: Z Project - universal screen size scaling system
Post by: onumad on 2012-Jun-15
Ok, not fault of z_print function, I think is a bug of len() function.
This code:
Code (glbasic) Select
GLOBAL myfont
main:
myfont=GENFONT()
LOADFONT "Media/myfont.png", myfont
SETFONT myfont

LOCAL n%, c$, x%
LOCAL t$ = "My little test with PRINT func"
x=10

FOR n = 0 TO LEN(t$) - 1
c$ = MID$(t$, n, 1)
INC x, LEN(c$,1)
PRINT c$, x,200
NEXT

SHOWSCREEN
MOUSEWAIT

END


and the attached result.

[attachment deleted by admin]
Title: Re: Z Project - universal screen size scaling system
Post by: onumad on 2012-Jun-16
SOLVED!!! The problems was in GLBASIC Font Creator!.

If I use DingsFont (http://www.glbasic.com/forum/index.php?topic=6421.msg64328#msg64328) z_print/print functions works ok.

Thank you all for helps!
Title: Re: Z Project - universal screen size scaling system
Post by: kaotiklabs on 2012-Jun-16
Fine, this font app also fixed my alpha problem.
Title: Re: Z Project - universal screen size scaling system
Post by: r0ber7 on 2012-Aug-02
I'd like to add something else to my comments here. I noticed that, due to not using integers in some calculations, the rescaling of my game would show up on other monitors with thin lines of one pixel error, making it look like the entire thing was "sliced up". After I changed several variables to integers, this problem disappeared.

Code (glbasic) Select

GLOBAL x_offset%,y_offset% //offset to add to X&Y to display correctly
GLOBAL x_res%,y_res% //X&Y real screen size
GLOBAL x_zoom,y_zoom //zoom to scale sprites and so
GLOBAL x_orig%=320,y_orig%=200 //the screen size our app is designed for
GLOBAL single_sheet=0 //1 IF all sprites in a single sheet

FUNCTION z_drawsprite: num%,x%,y%,color=0xFFFFFF
LOCAL sx,sy,x1,y1,x2,y2

FUNCTION z_drawanim: num%,frame%,x%,y%,w%,h%,color=0xFFFFFF
LOCAL sx%,sy%,x1%,y1%,x2%,y2%,ancho,alto,xa%,ya%

FUNCTION z_rotozoomanim: num%,frame%,x%,y%,w%,h%,ang,size,color=0xFFFFFF
LOCAL sx%,sy%,x1%,y1%,x2%,y2%,ancho,alto,xa%,ya%,x3%,x4%,y3%,y4%,xcos,ysin,xs,ys,sw,sh

FUNCTION z_drawrect: x%,y%,w%,h%,color=0xFFFFFF



I'm not sure if that's all I changed, but generally speaking, if you get reports of people using different resolutions with these thin lines slicing up the place, in other words, your polys don't line up as they should, try turning some of the variables into integers. :)

I'm now going to see if I can get z_print to work with the font app suggested above, hope it works, cause I'd like to have font kerning. :P Cheers.
Title: Re: Z Project - universal screen size scaling system
Post by: planetm on 2012-Aug-29
I've just converted my current project to use this method and it has solved all my android scaling issues. Thanks Ampos.

I did have a couple of issues during the conversion. Firstly z_rotozoomanim wasn't placing placing items correctly, this was solved using r0ber7's modification earlier in the thread (thank you!).

Next I had all the issues with overlapping text using z_print as others have described. I noticed that the character spacing remained the same as I tried fonts of various sizes, with the largest therefore having the biggest overlaps. It then occurred to me that the LEN() functions in z_print were not using the correct font. My solution was to use loadfont in addition to loading the font as a sprite (using the same number for both) then adding "SETFONT font" at the start of the z_print function. This allowed LEN() to return the correct pixel sizes for the characters for each font so they spaced correctly.

Thanks again for the functions :)

Matt.
Title: z_drawsprite borders...
Post by: galiksoft on 2012-Sep-02
Hi. I'm using Z Project and so I draw everithing for one resolution with z_drawsprite. I use PNG images with transparency
If the ratio is 1:1 or under, all ok. But if the ratio is above 1:1, the images present white borders,  wich is ugly and I don't want these borders.
How to change that?
Title: Re: Z Project - universal screen size scaling system
Post by: Ian Price on 2012-Sep-02
Make sure you use SMOOTHSHADING FALSE before drawing anything.
Title: Re: Z Project - universal screen size scaling system
Post by: marovada on 2012-Nov-15
Thanks ampos. This is a great tool.

I'm probably not using it correctly and am wondering whether anyone can help. I've got a 2d game. I'm targeting a resolution of 1024x768 and am downscaling for lower resolutions.  My main sprite is a ball/circle.

If I downscale using z without maintaing the aspect ratio, the playing field is squashed into the centre of the screen surrounded by black.  If I maintain the aspect ratio then my sprite becomes distorted - it goes from a circle to an oval/egg shape.

I would like to maintain the aspect ratio as the game doesn't work if the whole playing field is compressed into the centre of the screen, even if I replace the black parts of the screen with a nice background.

What am I doing wrong?

Thanks
Title: Re: Z Project - universal screen size scaling system
Post by: quangdx on 2013-Oct-16
I wanted to add my thanks to Ampos for Project Z,
and all the others that have contributed to it.

It's made my life so much easier now I've started to code for the multitude of mobile devices and their different screen resolutions.

Excellent work.
Title: Re: Z Project - universal screen size scaling system
Post by: Ian Price on 2013-Oct-16
Sadly ampos no longer frequents the forums, but his work will live on forever...
Title: Re: Z Project - universal screen size scaling system
Post by: Hemlos on 2014-Sep-01
For a finished product, i think it would be better to be hardware specific for each program you publish.
The tradeoff for a universal screen scaling system, is performance.
However, this is pretty cool for development purposes and testing on different platforms quickly.
Title: Re: Z Project - universal screen size scaling system
Post by: spacefractal on 2014-Sep-01
hehe its a bit old post, Hemlos. This thread can of course still been sticky and have a lots of good uses. Im have even tested this one quite early, but dedicated to uses my own system without universal virtual screens to boost up the perforcement. But retro style game, this can been quite very perfect :-).