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.

DarkBASIC Professional Discussion / Help with Aspect Ratios

Author
Message
Mobiius
Valued Member
23
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 23rd May 2013 01:03
Hello, I have a maths related question that I'm sure some forum guru can answer in seconds.

I'm porting some AppGameKit code over to DBPro and have successfully managed to get my UI code working directly in DBP without changing any of the source AppGameKit code. (Other than changing the square brackets in arrays of course)

I however am struggling with AGKs ability to automatically sets sprites sizes when using a size of -1. (So setting with the X and height to -1 will ensure that the image maintains the same aspect regardless of what X is set to.)

I have this working fine, but I'm having trouble working out what X would be when I know Y.

I know that:
Aspect# = Y# / X#

So that when I know what X# is, I can work out Y#. (Y# = X# * Aspect#)

But how do I do this the other way?
When I know what Y# is, how do I work out X#?

I live for video games! (And beers, and football, and cars!)
See what I live for here: [url]http:\\www.TeamDefiant.co.uk[/url]
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 23rd May 2013 01:18
Just rearrange the formula in the usual way, i.e.

x# = y# / Aspect#
Mobiius
Valued Member
23
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 23rd May 2013 17:23
Thanks for your help. That worked but my problem was elsewhere...

I was doing integer division which was returning 0, instead of a float value. But I have fixed this issue and my AppGameKit port of my UI engine is working (almost) perfectly.

The trickiest part was recreating AGKs bitmap font system, without using bitmap fonts. (And using DBPro's terrible sprite priority system...)

I live for video games! (And beers, and football, and cars!)
See what I live for here: [url]http:\\www.TeamDefiant.co.uk[/url]

Login to post a reply

Server time is: 2026-07-07 18:22:05
Your offset time is: 2026-07-07 18:22:05