Advertisement

Quake like console question...

Started by February 16, 2002 03:51 PM
0 comments, last by RummeL 22 years, 10 months ago
Ok, i''ve sniffed around these forums and have been looked at the Quake/Quake 2 source among others to see how they implement their consoles but being a newbie am having trouble understanding a few things. Onto my main query. As it stands, I am using a two-dimensional array which holds the number of lines + the contents i.e. char line_buffer[15][64]; Any input is put into line_buffer[0] and when the user hits return all the strings are copied from the top to bottom so it gives the effect they have been "shunted" up one. This presents a problem when I want to add info onto the buffer like memory values etc that the user hasn''t entered (for instance their typed buffer will be effectively be cancelled out). So I was thinking of using a separate array for the userinput and what has already been added to the console buffer. I''m thinking this would allow me better use of the memory aswell - I could have a loop using the modulus operator so any new input can be buffered into the line that was just knocked off the "top" as such). I hope that made sense. Anyone have a better way of doing such a console? I''m kinda stuck here... :]
Instead of having big 2d arrays you could allocate the memory as needed, as long as you are handy with pointers and the new keyword.

This topic is closed to new replies.

Advertisement