In game console<SOLVED>

Whether you're a newbie or an experienced programmer, any questions, help, or just talk of any language will be welcomed here.

Moderator: Coders of Rage

Post Reply
User avatar
mv2112
Chaos Rift Junior
Chaos Rift Junior
Posts: 240
Joined: Sat Feb 20, 2010 4:15 am
Current Project: Java Tower Defence Game
Favorite Gaming Platforms: N64/Xbox 360/PC/GameCube
Programming Language of Choice: C/++, Java
Location: /usr/home/mv2112
Contact:

In game console<SOLVED>

Post by mv2112 »

How would you go about making a in-game console for debugging and such? I'm looking for ideas. Should it be a class? Or should it just be a console function that loops until exit is typed or something? Right now i'm not worried about the functionality, just the rendering. Should i check for every keypress and add the character if that key is pressed? How should i go about this?
Last edited by mv2112 on Thu Jun 17, 2010 3:57 pm, edited 1 time in total.
XianForce
Chaos Rift Devotee
Chaos Rift Devotee
Posts: 767
Joined: Wed Oct 29, 2008 8:36 pm

Re: In game console

Post by XianForce »

Well I'd say it should be a class for sure...

for string input, check this out.

So really just pass any key press events to the instance, and then update it...
User avatar
Milch
Chaos Rift Junior
Chaos Rift Junior
Posts: 241
Joined: Sat Jul 11, 2009 5:55 am
Programming Language of Choice: C++
Location: Austria, Vienna

Re: In game console

Post by Milch »

My console is a class and all of the other variables get registerd in a linked list with a string and a pointer to the real variable.
Also, it has a bitflag if it should be saved in a file if the program is closed.
It has a function called 'ToggleConsole' and whenever this is called, it opens/closes the console.

For the input I have somekind of priority system.
So, my code looks more less like this:

Code: Select all

if( console->IsActive() ) //The highest priority
   console->Input( Event );
else if( menu->IsActive() )
   menu->Input( Event );
else //only normal game left
   game->Input( Event );
In the rendering part, I just check if its active and call the function 'console->Render()' - thats all.

If you use SDL - go with the link XianForce posted above.
But if you use SFML - you have to write your own string input class ( atleast I did that, maybe there is a solution and I didnt find it... )
Follow me on twitter!
User avatar
mv2112
Chaos Rift Junior
Chaos Rift Junior
Posts: 240
Joined: Sat Feb 20, 2010 4:15 am
Current Project: Java Tower Defence Game
Favorite Gaming Platforms: N64/Xbox 360/PC/GameCube
Programming Language of Choice: C/++, Java
Location: /usr/home/mv2112
Contact:

Re: In game console<SOLVED>

Post by mv2112 »

XianForce wrote:Well I'd say it should be a class for sure...

for string input, check this out.

So really just pass any key press events to the instance, and then update it...
Yes, this is perfect, great info. I think im gonna perfect my text system before i make a console though... :mrgreen:
Post Reply