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 / Resolution vs Pixil Positions (Help Please!)

Author
Message
DreamyAbaddon
12
Years of Service
User Offline
Joined: 9th Mar 2014
Location:
Posted: 15th Mar 2014 10:37
Hey everyone!

I am reading Hands On DarkBasic Pro Volume #1 book and I'm having problems understand the "Logic" behind how to fully understand what ((Activity 2.12)) is teaching me.

Basically This is what I need to do:
Create a new project that displays the letters A,B,C, and D so that one letter appears at each corner of the screen.

Here are my Statistics:

In DarkBasic Pro:
Screen:
Screen Type: Window
Window Resolution: 640x480
Full Screen Resolution: 640x480x32

My Display on Windows7:
1360x760, 60Hz

Here is what my theory was:
Because my Window Resolution is 640x480 in Dark Basic Pro, I am assuming that if I put this code in, that the corners will be aligned correctly to finish this task:


Set cursor 0,0
Print "A"

Set cursor 640,0
Print "B"

Set Cursor 0,480
Print "C"

Set Cursor 640,480
Print "D"

wait key
end


This however, is False...
The positions are all wrong. So I'm scratching my head trying to figure out how to make sense out of it.

Note: I did get all 4 corners aligned correctly, however, it does not match my screen resolution in Dark Basic Pro that I have setup. So this confuses me.

Any suggestions?
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 15th Mar 2014 19:28
It confuses me too - and I can't even get that simple code to work.

I think I need to reboot and try again. If that fails I'll try rebooting the computer as well ...



Powered by Free Banners
ShellfishGames
13
Years of Service
User Offline
Joined: 6th Feb 2013
Location:
Posted: 15th Mar 2014 21:12
I'm not too sure, but I believe the reason for the code not to work (what exactly does it do for you? I see a C on the left side, ~100px above the bottom) is that the print command automatically "scrolls" the screen up when printing something below the lower edge of the screen. Hence I'd recommend using text instead of print. However, you'll still not see B, C and D as they are just outside the visible screen. You'll need to position them to screen width()-some value (20 or so) and screen height()-text size() respectively.

MonoCoder
20
Years of Service
User Offline
Joined: 4th Dec 2005
Location: england
Posted: 15th Mar 2014 21:53 Edited at: 15th Mar 2014 21:59
beaten to it, nevertheless here's a picture. I'm not sure what the actual problem is (what you mean by the positions being false) so its just the broad idea.



the bottom left figure is basically what shellfish said.
Attila
FPSC Reloaded TGC Backer
21
Years of Service
User Offline
Joined: 17th Aug 2004
Location:
Posted: 15th Mar 2014 22:00 Edited at: 15th Mar 2014 22:01
Here is an example how positioning with "set cursor" works.



I recommend using the "text x,y,t$"-command. It is more accurate than "set cursor" and allow also to center text at a position.
tiffer
20
Years of Service
User Offline
Joined: 6th Apr 2006
Location: Scotland
Posted: 15th Mar 2014 22:15 Edited at: 15th Mar 2014 22:16
Have you taken into consideration that characters print to the right of the cursor?

Cwatson
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 16th Mar 2014 00:59
Quote: "characters print to the right of the cursor?"


To the right and below.

I used the following snippet to see the difference between print and text - and as noted above I could only get easily predictable results using text instead of print.





Powered by Free Banners
DreamyAbaddon
12
Years of Service
User Offline
Joined: 9th Mar 2014
Location:
Posted: 16th Mar 2014 03:01
You guys are seriously, the best community ever!

@ MonoCoder
Your pictures helped me the most!
The picture on the buttom left gave me a visual reference of were A,B,C,D is located so now I understand why I don't see the other letters. Thanks so much!!!

@ Attila & Green Gandalf
Thank you both for the help and sharing your codes!
This also helps me figure out the problem in different angle.
By the way, how do you copy codes like that into snippets? I like to learn how to do this lol.

@ tiffer
Right of the cursor?
Set Cursor doesn't mean the actual cursor on my mouse position, does it?

@ Everyone else:

I have found a solution using the Text command.

If you're resolution is: 640x480
You subtract the X-axis by 10
You subtract the Y-axis by 13
And your code would look like this:

Text 0,0, "A"
Text 630,0, "B"
Text 0,467, "C"
Text 630,467, "D"

This will align all 4 letters at the correct position.
This applies to ANY Screen Resolution you choose as long as the text size is default.

And to get the position of center, simple math does the trick.

630 divided by 2 = 315
467 divided by 2 = 233

Text 315,233, "X"
tiffer
20
Years of Service
User Offline
Joined: 6th Apr 2006
Location: Scotland
Posted: 16th Mar 2014 05:08
The difference is the text size in pixels /2

Cwatson
Jeff Miller
21
Years of Service
User Offline
Joined: 22nd Mar 2005
Location: New Jersey, USA
Posted: 16th Mar 2014 12:11 Edited at: 16th Mar 2014 12:24
Use a semicolon at the end of the Print commands. If you do not, the command is interpreted as ending with a carriage return, which can cause DBP to shift the printed characters up if the space required for the next line extends below the defined display. You should only omit the semi-colon when you intend to print a list whose length will be less than the screen height and which is left-justified, thereby omitting the need to reset the cursor for each line.
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 16th Mar 2014 12:15 Edited at: 16th Mar 2014 12:16
That fits with the symptoms I was experiencing. Thanks.

Edit Yep, that fixed my code.



Powered by Free Banners
tiffer
20
Years of Service
User Offline
Joined: 6th Apr 2006
Location: Scotland
Posted: 16th Mar 2014 20:49
Quote: "@ tiffer
Right of the cursor?
Set Cursor doesn't mean the actual cursor on my mouse position, does it?"


No I meant DB's print cursor
AS GG said ad you may now have discovered when you use print the text doesn't center with the cursor but is offset so that the first character is just below and to the right of the cursor. So if you were trying to center a string of text on a point you would subtract half the length but it's easier just to use 'center text' or 'text'.

Cwatson

Login to post a reply

Server time is: 2026-07-06 12:45:30
Your offset time is: 2026-07-06 12:45:30