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 / Newbie Needs Help

Author
Message
Troysmadhouse
13
Years of Service
User Offline
Joined: 6th Feb 2013
Location:
Posted: 6th Feb 2013 16:34
I am a teacher and have just started learning Dark Basic Pro, along with my students. We are building a game, but we are stuck on something that may seem very elementary. It's in the first part of the game, we have a screen that comes up and asks, "What Is Your Name?" We centered the text in the middle of the screen. When the user inputs their name, however, that input shows up in the upper left corner. We don't know what the command would be for centering the input. Can anyone help with this? We would be most appreciative. Thank you!

Troysmadhouse
zeroSlave
17
Years of Service
User Offline
Joined: 13th Jun 2009
Location: Springfield
Posted: 6th Feb 2013 18:19 Edited at: 6th Feb 2013 18:20
Hello, Troysmadhouse! Welcome to the forums. My wife is a teacher as well.

Look into SET CURSOR x, y:




Everybody is a genius. But if you judge a fish by its ability to climb a tree, it will live its whole life believing that it is stupid.
Libervurto
20
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 6th Feb 2013 19:14 Edited at: 6th Feb 2013 19:14
Great to hear this is being used in schools!

From your description I assume you're using TEXT to display the question rather than PRINT. INPUT displays the input in the same way as PRINT, by writing to the "output stream" as you might call it. That was a bit garbled, here see for yourself:

As you can see, set cursor only applies to the next output. Since I flooded the background you can also see that input doesn't really "delete" characters, it just overwrites them with the second colour attributed to INK. (This is also the colour that CLS will use if you don't specify a value.) SET CURSOR only effects the output stream.

Go with Zero's solution for now, INPUT is ugly and there are ways to display input in a nicer fashion using the keyboard entry buffer, but that takes a bit more work. Maybe that could be your next challenge!

Here are some commands you might like to read up on:
ENTRY$()
CLEAR ENTRY BUFFER
ASC()
CHR$()
MID$()
LEFT$()
RIGHT$()

^ That's what she said.
MrValentine
AGK Backer
15
Years of Service
User Offline
Joined: 5th Dec 2010
Playing: FFVII
Posted: 6th Feb 2013 21:07
Hi Troysmadhouse - Welcome to the forums!

I was going to mention the Entry$() command combined with '/Screen Width(), /Screen Height' for the positioning...

But the above suggestions should be easily adapted to your project

Troysmadhouse
13
Years of Service
User Offline
Joined: 6th Feb 2013
Location:
Posted: 7th Feb 2013 17:02
Thank you everyone! That helped a lot. The kids are working on it right now, but just looking at the code helps understand... and made us both say... "ooooh! That makes sense!"

Thanks again! I really appreciate all the help and time... more than you will ever know!!

Troysmadhouse
Southside Games
16
Years of Service
User Offline
Joined: 1st Jan 2010
Location: Don\'t tell me what to do!
Posted: 8th Feb 2013 03:47 Edited at: 8th Feb 2013 03:48
Hi!

To center text I do as MrValentine says.



This is more or less how I use it.
Libervurto
20
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 10th Feb 2013 16:12
As a side note: give your next thread a more descriptive title.

^ That's what she said.

Login to post a reply

Server time is: 2026-07-07 20:23:32
Your offset time is: 2026-07-07 20:23:32