Z Project - universal screen size scaling system

Previous topic - Next topic

r0ber7

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?

onumad

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]

onumad

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]

onumad

SOLVED!!! The problems was in GLBASIC Font Creator!.

If I use DingsFont z_print/print functions works ok.

Thank you all for helps!

kaotiklabs

Fine, this font app also fixed my alpha problem.
Vote Cthulhu! Because the stars are right!!!!
Ia Ia Cthulhu F' tang!

r0ber7

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.

planetm

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.

galiksoft

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?

Ian Price

Make sure you use SMOOTHSHADING FALSE before drawing anything.
I came. I saw. I played.

marovada

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

quangdx

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.

Ian Price

Sadly ampos no longer frequents the forums, but his work will live on forever...
I came. I saw. I played.

Hemlos

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.
Bing ChatGpt is pretty smart :O

spacefractal

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 :-).
Genius.Greedy Mouse - Karma Miwa - Spot Race - CatchOut - PowerUp Elevation - The beagle Jam - Cave Heroes 2023 - https://spacefractal.itch.io/