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.

Author
Message
Gamefreak
20
Years of Service
User Offline
Joined: 20th Jun 2004
Location: Cyberspace
Posted: 22nd Oct 2004 07:19
How would I go about making a text box in a game?
JoelJ
21
Years of Service
User Offline
Joined: 8th Sep 2003
Location: UTAH
Posted: 22nd Oct 2004 07:44 Edited at: 22nd Oct 2004 07:47
well, doing the graphics would be differnt, but here the general idea for getting the input (because the input command wouldnt be of use in this)

when the textbox is selected, have it read what keys are being pressed, so if they press 'A', it adds 'a' to the string. so string VAR = "a", then when they press the letter 'N', it will add that to the string, so string VAR = "an", if they get a BACKSPACE key, it will remove one, so string VAR = "a".

so, in a little more codish looking way :p


you can add a:
if scancode() = 14 `backspace
block too to remove the last char
and you would have to make sure it wont let you hold down like it does now


<[jimmy]> daaaaaaaaaaaaang that KK is cute
Nicholas Thompson
20
Years of Service
User Offline
Joined: 6th Sep 2004
Location: Bognor Regis, UK
Posted: 22nd Oct 2004 11:48
Sounds like a good plan there darwin.. Like he said, you NEED code to check for key release.

If you just say "is backspace down" then it will delete one character every frame.. So at 150fps, it will delete 150 characters PER SECOND.. Not good.. You need to say:
* is key down AND was it UP before? Yes!!
* delete character
* SET KEY UP (a variable somewhere)
* is key down AND was it UP before? NO!!
* recheck ^^

Just a little psuedo code there.. Btw: Can you believe someone on my degree in the second year doing COMPUTER SCIENCE BSC asked if there was a compiler or interpreter for psuedo code? He acually thought it was a language on the same level as Java and C!!! Oh boy did he get slated.. Lol..

Login to post a reply

Server time is: 2025-05-29 05:53:07
Your offset time is: 2025-05-29 05:53:07