Author Topic: Z Project - universal screen size scaling system  (Read 30028 times)

Offline r0ber7

  • Dr. Type
  • ****
  • Posts: 477
    • View Profile
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?

Offline onumad

  • Mc. Print
  • *
  • Posts: 15
    • View Profile
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=0
and
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]
« Last Edit: 2012-Jun-15 by onumad »

Offline onumad

  • Mc. Print
  • *
  • Posts: 15
    • View Profile
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]

Offline onumad

  • Mc. Print
  • *
  • Posts: 15
    • View Profile
SOLVED!!! The problems was in GLBASIC Font Creator!.

If I use DingsFont z_print/print functions works ok.

Thank you all for helps!
« Last Edit: 2012-Jun-16 by onumad »

Offline kaotiklabs

  • Dr. Type
  • ****
  • Posts: 313
  • Spain is diferent
    • View Profile
Fine, this font app also fixed my alpha problem.
Vote Cthulhu! Because the stars are right!!!!
Ia Ia Cthulhu F' tang!

Offline r0ber7

  • Dr. Type
  • ****
  • Posts: 477
    • View Profile
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.

Offline planetm

  • Mr. Drawsprite
  • **
  • Posts: 56
    • View Profile
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.

Offline galiksoft

  • Mc. Print
  • *
  • Posts: 19
    • View Profile
z_drawsprite borders...
« Reply #52 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?

Offline Ian Price

  • Administrator
  • Prof. Inline
  • *******
  • Posts: 4115
  • On the shoulders of giants.
    • View Profile
    • My Apps
Make sure you use SMOOTHSHADING FALSE before drawing anything.
I came. I saw. I played.

Offline marovada

  • Mr. Drawsprite
  • **
  • Posts: 51
    • View Profile
    • Wee Basic (NDS), TapBASIC (ios), scifi
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

Offline quangdx

  • Mr. Polyvector
  • ***
  • Posts: 233
  • work hard / play hard
    • View Profile
    • Asobi tech
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.
Asobi tech - the science of play.
Spare time indiegame developer.

Offline Ian Price

  • Administrator
  • Prof. Inline
  • *******
  • Posts: 4115
  • On the shoulders of giants.
    • View Profile
    • My Apps
Sadly ampos no longer frequents the forums, but his work will live on forever...
I came. I saw. I played.

Offline Hemlos

  • To boldy go where no pixel has gone before!
  • Global Moderator
  • Prof. Inline
  • *******
  • Posts: 1577
  • Particle Hawk
    • View Profile
    • Silver Volumetric Software
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.
Volume_of_Earth(km^3) = 4/3*3.14*POW(6371.392896,3)

http://silver.binhoster.com/

Offline spacefractal

  • Community Developer
  • Prof. Inline
  • ******
  • Posts: 3394
    • View Profile
    • Space Fractal
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 :-).
Greedy Mouse - Karma Miwa - Spot Race - CatchOut - Android Extras - is on a vacation trip, home before end of few days in jan.