Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / Beginner confused with positioning

Author
Message
upatree
11
Years of Service
User Offline
Joined: 26th Nov 2012
Location:
Posted: 30th Dec 2012 23:32
Not a newbie to basic (hacked a few things together with Amos on the Amiga years ago) but new to AGK.

I'm trying to draw a 3x3 display on my screen, three squares of equal dimensions filling the screen horizontally, and taking up the same amount of space vertically. I am using the default SetDisplayAspect(0.66) from the wizard.

I have drawn the sprites like so:

and have set each with a unique colour.

However, positioning them is confusing as heck for me.

I am setting the first row of three squares like this:

and this is working fine. However, dealing with the vertical positioning of row two and three is just for me.

Could someone give me an example of calculating the vertical position so that row two sits directly below row one (with no gap) and row three sits directly below row two, of course maintaining the size and aspect of the squares?

Thanks!
The Zoq2
14
Years of Service
User Offline
Joined: 4th Nov 2009
Location: Linköping, Sweden
Posted: 31st Dec 2012 01:01 Edited at: 31st Dec 2012 01:07
I would store the blocks in an array which enables you to go thru them one by 1. Then use 2 for loops, one for vertical and one for horizontal positioning



I hope that does what you want it to
Hodgey
14
Years of Service
User Offline
Joined: 10th Oct 2009
Location: Australia
Posted: 31st Dec 2012 06:54
The funny thing about using the display aspect (aka percentage system) is that 1% along the x-axis is not equal to 1% on the y-axis, in this case, the x-axis is only 66% of the y-axis. Try multiplying the y-values by the display aspect e.g SetSpritePosition(spr, x, y*getDisplayAspect()). You might have to fiddle around with ratios until you've got what you want.

upatree
11
Years of Service
User Offline
Joined: 26th Nov 2012
Location:
Posted: 31st Dec 2012 13:13
Thanks guys, the example code was much cleaner than I had written, and multiplying y by getDisplayAspect worked a treat for positioning the squares. Thanks!

Login to post a reply

Server time is: 2024-05-03 23:06:29
Your offset time is: 2024-05-03 23:06:29