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.

Dark GDK / User Text Input

Author
Message
Zuko
14
Years of Service
User Offline
Joined: 12th Feb 2010
Location:
Posted: 12th Feb 2010 09:47
Hey guys im currently working on a 2d game in c++ darkGDK and have made a few console text applications in the past. My question is, if the user wants to input his character name in the game, how would I go about doing that? Is there some kind of graphical text box function, or would I have to show an image of a keyboard on the screen where the user can click the buttons on the screen to enter each letter individually (like the ones in some nintendo ds games). Im new to darkGDK and havn't been able to find any tutorials on text input in a 2d games.

Thanks in advance
Amnzero
15
Years of Service
User Offline
Joined: 1st Aug 2009
Location:
Posted: 13th Feb 2010 03:17
dbInput ( char* szStatement, int iInput ) will allow you to prompt the user for input. You can use the void dbCursor( int iX, int iY ) function to position the prompt cursor anywhere on the screen.

Optionally you can use dbEntry( void ) and other input functions to poll the entry buffer for key presses.

[url="http://neovance.com/"][/url]
Marsh0
15
Years of Service
User Offline
Joined: 18th Mar 2009
Location:
Posted: 13th Feb 2010 19:04
I think the dbInput pauses your game so dbEntry is a better option.

Here is a backspace function also by Mireben.

http://forum.thegamecreators.com/?m=forum_view&t=165177&b=22

www.touchofdeathproductions.com
Tweety J
14
Years of Service
User Offline
Joined: 28th Jan 2010
Location:
Posted: 13th Feb 2010 20:19
Well...

Games flow best as a frame based state engine... In that situation, it is best (in my opinion) to use a key sample, like dbInKey, and do the text screen placement yourself. You have to trap and lock the key until it is released though, because the sampling happens so fast (30-60 FPS if it is designed right) that just tapping the key will give you at least 3 inputs. Something like this would stop that for you:

with this, consecutive frames that have the input will only process the input one time. The else unlocks the input on the first frame without an input. Never pause a frame based state engine, even for the user typing. always find a way to let the computer run frames as fast as possible. You can do other things, like move sprites, and make it nice and pretty, while the user is typeing

Login to post a reply

Server time is: 2024-11-20 05:36:38
Your offset time is: 2024-11-20 05:36:38