You could have the game engine look for a 'command' file (that you
write) whose contents conform to a lite protocol (1 'opcode' byte
followed by a few data bytes, say), based on the sort of information
you want to debug. Then write a command-line utility that'll parse its
arguments on the command line (in Terminal.App, or the CL of Windows'
DOS-window) and write these to the file.
The game, meanwhile, would maintain a thread to occasionally check
for the existence of this file, and read it in and delete it, if found.
This would separate the game (which I presume you've already written),
from the CLI. Otherwise, you'd have to make the game a daemon process,
and have a CL utility communicate with it (TCP/IP, or other IPC such as
AppleEvents or OLE/ActiveX?)
For example, you could define the following protocol:
opcode | data
0x00 | <none - NOOP (NO OPeration) instruction>
0x01 | <byte>,<word> SPEN (SPawn ENemy) instruction; spawn <byte>
number of enemies <word> distance
from the player (or less if a wall in the way)
0x02 | <byte placeholder> QUPL (QUery PLayer) instruction; examines
<byte placeholer> for the code
representing the player stat you want to query (1 = health, 2
= shields, etc...) The result will
be written back into the file, and the file extension renamed
so the game engine doesn't pick
up the file again! Your CLI utility would have to scan for
this new file, and display the result.
0x03 | <word placeholder> QUGE (QUery Game Engine) instruction;
similar to above, but queries the game
engine for things like; frame rate, # enemies this map, #
spawn points, etc...
0x04 | <none> - pause game
0x05 | <none> - un-pause game
and so on for other things of interest to you. Opcodes 0x02 and 0x03
would be how you could query for variable values (which is one of the
things you mentioned in your post.).
On Jun 17, 2006, at 10:27 AM, Asher Dunn wrote:
Hey all,
I've had more time for game programming recently, and I've run into a
problem. I'm adding a command prompt to my game for debugging
purposes. This prompt will allow me to debug the game while running by
allowing me to see the value of variables, reload data, create enemies
on demand, etc.
Since the game is run from a hard loop, and there won't necessarily be
a window open (using a fullscreen OpenGL context), I can't use KeyDown
events for the typing. Using keyboard.asyncKeyDown() and
keyboard.keyName doesn't work because keyboard.asyncKeyDown() always
reports true for almost every key (bug?).
I could scan through every element of the "keyboard" game input device
and use the element name as the typed letter, but that seems extremely
clunky. I'd have to special case "shift" and "delete" appropriately,
ignore command and option, strip the "[key ##]" part of element names,
and so on.
Ideally I want to receive keyDown events and not have to poll every
key every frame, but I'm open to anything that works.
Ideas?
Asher
-------------------------
Asher Dunn
Head Developer, Fireye Software
http://www.fireyesoftware.com/
AIM, Yahoo, MSN: crazedglkid
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>
William H Squires Jr
4400 Horizon Hill #4006
San Antonio, TX 78229
[EMAIL PROTECTED] <- remove the .nospam
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>