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.

Newcomers DBPro Corner / About pixals and their relations...

Author
Message
Big Dog Game Studios
11
Years of Service
User Offline
Joined: 18th Jun 2012
Location: Port Angeles, WA
Posted: 24th Jun 2012 18:45 Edited at: 24th Jun 2012 18:47
When working with DB Pro, obviously you need to know the pixal placement in order to do anything with your game, including displaying text. Now, I realize that resolution plays a big factor when creating your game, and everyone has a different resolution setting depending on their graphics card and monitor.

Is there a good reference for pixal placement that can be found? I know the top corner, no matter what resolution is always considered 0, 0. But in a program that is..640 X 480, the center of the screen is 320 on the X axis. If you go higher, say 1280 X 720.. that placement would change.

Do you have to spend time feeling this out in order to get the correct placement of text and graphics, or has someone figured out an easier method? I know a bit of math would help here by dividing the resolution by 2 to figure out center. I am not looking for the cheat sheet of game design. I enjoy coding a lot. A reference for pixals would be great though

nonZero
12
Years of Service
User Offline
Joined: 10th Jul 2011
Location: Dark Empire HQ, Otherworld, Silent Hill
Posted: 24th Jun 2012 22:03
You can center text using the CENTER TEXT function.
You can calculate an offset for pixEl placement based on the values returned by SCREEN WIDTH() and SCREEN HEIGHT().
You can attain the desktop resolution with DESKTOP WIDTH() and DESKTOP HEIGHT()


Big Dog Game Studios
11
Years of Service
User Offline
Joined: 18th Jun 2012
Location: Port Angeles, WA
Posted: 25th Jun 2012 07:03
Wow.. yet again something that wasn't covered. Thank you for the reply. The book I read covered Center text, but it was more like:



So even though I used the syntax, the book said to enter the coordinates

Hodgey
14
Years of Service
User Offline
Joined: 10th Oct 2009
Location: Australia
Posted: 25th Jun 2012 08:31
Quote: " the book said to enter the coordinates"

That's exactly what nonZero does in his code. The x coordinate being half of the screen width and the y coordinate being half of the screen height. You don't have to use literals for everything. More often than not, you'll be passing variables into functions.

Pincho Paxton
21
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 25th Jun 2012 23:04
Quote: "Wow.. yet again something that wasn't covered. Thank you for the reply. The book I read covered Center text, but it was more like:
CENTER TEXT 320, 90, "This is how it taught me""


Programming examples never cover all situations, because programming is like writing a book. You can start with Once Upon A Time, but after that everything is different for each person writing the book. With programming there are often 20 ways to do the same thing.

BMacZero
18
Years of Service
User Offline
Joined: 30th Dec 2005
Location: E:/ NA / USA
Posted: 27th Jun 2012 23:11
You can allow your program to run at different resolutions and display correctly is to position things based on SCREEN WIDTH() and SCREEN HEIGHT() as nonZero indicated. For example, if you want something to be on the top-left corner of the screen, put it at SCREEN WIDTH() - IMAGE WIDTH(image), 0 instead of 1024 - IMAGE WIDTH(image), 0.

However, for starters I think it's best to code your program at a fixed resolution using something like SET DISPLAY MODE 1024, 768, 32 and let DarkBASIC scale it to the user's display for you. The game may be a tad blurry on larger displays, but the code will be a lot simpler.

Login to post a reply

Server time is: 2024-04-27 12:33:09
Your offset time is: 2024-04-27 12:33:09