• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
Kurask

In-Game Console

15 posts in this topic

 command parser 

Well, that word helped loads. Searching "console" was not helpful at all with Google, but there are many more results for that. Thanks!

 

I think the way to do it would be to have 2 text boxes (CreateWindow), one read-only and one to type in. The read only would echo whatever goes into a log file and the write one would handle the commands.

Edited by Kurask
0

Share this post


Link to post
Share on other sites
For the console in a couple of my games, I simply display lines of a log (rather than using std::cout) so it can display on an Android device easily.

For writing commands, I simply send the message to all of my ingame objects in the hope that one of them intercepts the message and can react / respond to it.

But depending on what API / engine you are using, it really isn't too hard to implement bespoke rather than dragging in some other project and rigging it up.

That's what I was thinking. I'd have my output go to some text file and have something constantly echo whatever is in that file onto the screen. I don't know the best way to do that though. My project is in C++ using DirectX for the  graphics. I was thinking I'd just make a textbox using CreateWindowEx that displayed all the output and I'd have another textbox slightly below that to handle the input. I'd have to figure out how to do that, but it sounds reasonable.

0

Share this post


Link to post
Share on other sites
Rather than outputing to an intermediate file, why not add the messages to a std::vector?
Then just display the last 10 lines or so or delete the first one until the length is less than 10 messages.

Also, rather than using Windows GUI components to display the messages, perhaps just make the messages draw to the screen as basic bitmap fonts or something. Have a basic boolean to toggle when you press the '`' key to specify if to draw the console or not every game loop.
2

Share this post


Link to post
Share on other sites

[quote name='Kurask' timestamp='1358018205' post='5020803']
That's what I was thinking. I'd have my output go to some text file and have something constantly echo whatever is in that file onto the screen. I don't know the best way to do that though. My project is in C++ using DirectX for the  graphics. I was thinking I'd just make a textbox using CreateWindowEx that displayed all the output and I'd have another textbox slightly below that to handle the input. I'd have to figure out how to do that, but it sounds reasonable.
[/quote]

 

Using CreateWindowEx isn't going to make a console that's really usable in-game, unless you are running windowed mode. IIRC DirectX has some font rendering classes if you are using earlier versions. Check the SDK samples.

 

As for logging: echoing from a file is not the greatest idea. Buffers can take time to flush. You may not want to lock a file constantly while a program is running (and conversely lock it while reading).

 

There are a bunch of good logging frameworks out there (check this thread on stackoverflow) that let you have multiple backend emitters. I use Boost.Log (not officially part of boost) in my projects and it works great for that sort of thing.

2

Share this post


Link to post
Share on other sites
Rather than outputing to an intermediate file, why not add the messages to a std::vector?
Then just display the last 10 lines or so or delete the first one until the length is less than 10 messages.

Also, rather than using Windows GUI components to display the messages, perhaps just make the messages draw to the screen as basic bitmap fonts or something. Have a basic boolean to toggle when you press the '`' key to specify if to draw the console or not every game loop.

 

In my engine I do something similar to this, I have a console class which stores its most recent lines internally in an std::vector and also writes that information to a file. When I use my console::outf() function the line is written to a log and added to an std::vector and the console is then drawn from the std::vector. As for drawing my console it is simply another GUI element.

2

Share this post


Link to post
Share on other sites

That's what I was thinking. I'd have my output go to some text file and have something constantly echo whatever is in that file onto the screen. I don't know the best way to do that though. My project is in C++ using DirectX for the  graphics. I was thinking I'd just make a textbox using CreateWindowEx that displayed all the output and I'd have another textbox slightly below that to handle the input. I'd have to figure out how to do that, but it sounds reasonable.

 

 

Using CreateWindowEx isn't going to make a console that's really usable in-game, unless you are running windowed mode. IIRC DirectX has some font rendering classes if you are using earlier versions. Check the SDK samples.

 

As for logging: echoing from a file is not the greatest idea. Buffers can take time to flush. You may not want to lock a file constantly while a program is running (and conversely lock it while reading).

 

There are a bunch of good logging frameworks out there (check this thread on stackoverflow) that let you have multiple backend emitters. I use Boost.Log (not officially part of boost) in my projects and it works great for that sort of thing.

Yeah, I can render text to the screen, I just wasn't sure if it was efficient to do so.

 

I don't know how I'd get started on binding input to the source, or even getting input to appear on the screen instead of using it to control the camera, as nife87 said above. 

0

Share this post


Link to post
Share on other sites

[quote name='Kurask' timestamp='1358024739' post='5020845']
I don't know how I'd get started on binding input to the source, or even getting input to appear on the screen instead of using it to control the camera, as nife87 said above. 
[/quote]

 

I just added my console as one of the states in my game's state management system. That way it intercepts all of the inputs from the user while it's up, and when you're done you just pop it right off the state stack and go back to the game. You can use your game's internal logging system as a backing store for the console output also, which makes implementing it a bit easier because now your console window is a very watered down input parser/command execution host and log viewer. 

1

Share this post


Link to post
Share on other sites
(the newest edition of id's cvar system in actual source, that I know of, lies accessible in their Half Life 2 SDK)


You could, alternatively, read the source code of one of id's games, like Quake.

Edited by Ectara
1

Share this post


Link to post
Share on other sites

That's what I was thinking. I'd have my output go to some text file and have something constantly echo whatever is in that file onto the screen. I don't know the best way to do that though. My project is in C++ using DirectX for the  graphics. I was thinking I'd just make a textbox using CreateWindowEx that displayed all the output and I'd have another textbox slightly below that to handle the input. I'd have to figure out how to do that, but it sounds reasonable.

 

 

Using CreateWindowEx isn't going to make a console that's really usable in-game, unless you are running windowed mode. IIRC DirectX has some font rendering classes if you are using earlier versions. Check the SDK samples.

 

As for logging: echoing from a file is not the greatest idea. Buffers can take time to flush. You may not want to lock a file constantly while a program is running (and conversely lock it while reading).

 

There are a bunch of good logging frameworks out there (check this thread on stackoverflow) that let you have multiple backend emitters. I use Boost.Log (not officially part of boost) in my projects and it works great for that sort of thing.

Yeah, I can render text to the screen, I just wasn't sure if it was efficient to do so.

 

I don't know how I'd get started on binding input to the source, or even getting input to appear on the screen instead of using it to control the camera, as nife87 said above. 

 

This depends on how you're handling input. If you are directly testing for input in functions to move camera and such you'll need to check if the console is open or not when making those calculations. 

 

Rendering text to the screen, like pretty much everything else in programming, can be efficient or not depending on how it's done. Earlier versions of D3D have ID3DXFont which may simplify this. Newer versions don't come with D3DX, so you'll either need to write your own font renderer, use someone else's, or use DirectWrite.

1

Share this post


Link to post
Share on other sites

Thanks for the suggestions; I ended up getting everything working. I was looking for functions that handled it altogether in case one existed. As stated earlier, the code to make one was pretty simple (I imagined it being a little more difficult than it turned out to be).

0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0