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 / Screen height/width wont work with variables??

Author
Message
CocaCola
16
Years of Service
User Offline
Joined: 23rd Mar 2010
Location: CocaCola.x CocaCola.y CocaCola.z
Posted: 3rd Apr 2011 09:34
Im trying this code and getting errors.. I'm not sure why this won't work.



Always program as if the person maintaining your program is a psychopath that knows where you live
Kevin Picone
23
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Australia
Posted: 3rd Apr 2011 09:45
They're functions, so DBpro is expecting the () after them

ie.

print screen width() / 2

CocaCola
16
Years of Service
User Offline
Joined: 23rd Mar 2010
Location: CocaCola.x CocaCola.y CocaCola.z
Posted: 3rd Apr 2011 09:50 Edited at: 3rd Apr 2011 09:58
Thank you
I added the () to the end but it doesn't appear that the test is actually in the center. Is it just me or is it something with DBPro?

EDIT: Also on topic I used "ink rgb(0,255,0),rgb(0,0,255)" to try and color the text and the background, the text gets colored but not the background??
Rem Project: Dark Basic Pro Project
Rem Created: Sunday, April 03, 2011


Always program as if the person maintaining your program is a psychopath that knows where you live
Hodgey
16
Years of Service
User Offline
Joined: 10th Oct 2009
Location: Australia
Posted: 3rd Apr 2011 09:59
Quote: "it doesn't appear that the test is actually in the center. Is it just me or is it something with DBPro?"


No, DBPro is doing what it is supposed to do. When text is drawn it is a bunch of images so the image is drawn at those coordinates remembering that the default x,y coordinates of an image is at the top left of that image. Add the dot command in your little snippet and you can see where the true x and y coordinates are.



A clever person solves a problem, a wise person avoids it - Albert Einstein
CocaCola
16
Years of Service
User Offline
Joined: 23rd Mar 2010
Location: CocaCola.x CocaCola.y CocaCola.z
Posted: 3rd Apr 2011 10:05
Thanks
Now I just need someone to answer my edit, please??

Always program as if the person maintaining your program is a psychopath that knows where you live
Grog Grueslayer
Valued Member
21
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 3rd Apr 2011 10:26 Edited at: 3rd Apr 2011 10:27
Quote: "I added the () to the end but it doesn't appear that the test is actually in the center. Is it just me or is it something with DBPro?"


It won't look like the text is in the center because it doesn't take into account the text size. It just starts at whatever x and y is but if you subtract the TEXT WIDTH()/2 from x and the TEXT HEIGHT()/2 from y you'll get the text in exactly the center.

Quote: "EDIT: Also on topic I used "ink rgb(0,255,0),rgb(0,0,255)" to try and color the text and the background, the text gets colored but not the background??"


The default for text is transparent. If you want to see the background color use SET TEXT OPAQUE to see the background color change.



LBFN
19
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 3rd Apr 2011 15:11
You could also use the CENTER TEXT command:


Grog Grueslayer
Valued Member
21
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 3rd Apr 2011 18:50
Unfortunately CENTER TEXT doesn't center text vertically. We can see how much off it is with bigger text (image attached if you don't feel like running the code). Of course the bigger the text the greater the distance from the actual center.



Login to post a reply

Server time is: 2026-07-11 19:01:02
Your offset time is: 2026-07-11 19:01:02