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.

DarkBASIC Professional Discussion / console window like in doom 3

Author
Message
nruser
18
Years of Service
User Offline
Joined: 22nd Dec 2007
Location: Serbia
Posted: 31st Oct 2010 16:35
Can someone show me how to make console like one in doom 3? I want to make console so it appears instantly can be scrolled up and down by PageUP and PageDown keys and doesn't pause the game when it is active.
Grog Grueslayer
Valued Member
21
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 31st Oct 2010 17:49 Edited at: 31st Oct 2010 17:55
The easiest method to get string input from the user and not stop the action is with the ENTRY$() command. You make a switch that determines if the console window is open/closed. If it's open detect any keys the user is hitting with ENTRY$(). If they hit keys add it to the string. Don't add any loops to hijack the flow and it goes on to the rest of the code (where the actual game play is).

In the following code snip is a 3D cube rotating. Press the F1 key to bring up the console window and type one of the commands:

STOP = Stop the rotation of the cube
START = Start the rotation of the cube
FAST = Increase the speed of the rotation
SLOW = Decrease the speed of the rotation

Once a command is entered it will automatically close the console window and you should see the change instantly.



nruser
18
Years of Service
User Offline
Joined: 22nd Dec 2007
Location: Serbia
Posted: 31st Oct 2010 18:44
Yes it doesn't stop game play but it still doesn't work like the one in Doom 3. Also, how can i make the console that will show all the messages passed to game system and scroll the contents of console?

I still doesn't know how to achieve this type capability of console.
Indicium
18
Years of Service
User Offline
Joined: 26th May 2008
Location:
Posted: 31st Oct 2010 21:14
Make an array of all the passed orders. You can then make your own system for viewing them. And you can suspend your game loop by making it go to a temporary while-endwhile loop.

Grog Grueslayer
Valued Member
21
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 1st Nov 2010 06:46 Edited at: 1st Nov 2010 06:47
Quote: "Yes it doesn't stop game play but it still doesn't work like the one in Doom 3. Also, how can i make the console that will show all the messages passed to game system and scroll the contents of console?

I still doesn't know how to achieve this type capability of console."


As vast as my video game past is Doom 3 is not one of the games I've played... the first Doom yes but not the third.

I wanted to leave the scrolling part for you to implement yourself. It's achieved with what Mad Nightmare stated.

1. Create an array to store the strings.

2. Set a top-of-the-window variable (starting at 15 lines from the bottom of the array).

3. Instead of "Console Window Open" show the array starting at the top-of-the-window variable to 15 lines down.

4. When a new command is entered or any text you show the user move all the strings in the array up one line and add the new line to the bottom of the array.

5. When the user presses the up/down arrows decrease/increase the top-of-the-window variable by 1.

6. When the user presses pageup/pagedown decrease/increase the top-of-the-window variable by 15.

It's easier to learn if you just try to do this part on your own. If your code isn't quite working right post in this thread and we'll try to help you more. We won't do it all for you.

nruser
18
Years of Service
User Offline
Joined: 22nd Dec 2007
Location: Serbia
Posted: 2nd Nov 2010 11:33
All consoles from the age of quake 3 arena (maybe quake 2) are the some, but some of them doesn't have scrolling.

Quote: "
1. Create an array to store the strings.

2. Set a top-of-the-window variable (starting at 15 lines from the bottom of the array).

3. Instead of "Console Window Open" show the array starting at the top-of-the-window variable to 15 lines down.

4. When a new command is entered or any text you show the user move all the strings in the array up one line and add the new line to the bottom of the array.

5. When the user presses the up/down arrows decrease/increase the top-of-the-window variable by 1.

6. When the user presses pageup/pagedown decrease/increase the top-of-the-window variable by 15.
"


points 2,3,4,5, and 6 are things i don't know how to do, also how

also, i am having difficulties on how can i use the array of strings for the command database

here is the code"


this is the console that i have made from your code, but there is also problem with console that can open and close with the same key, like pressing tilde key for opening and closing of the console.
nruser
18
Years of Service
User Offline
Joined: 22nd Dec 2007
Location: Serbia
Posted: 3rd Nov 2010 00:33
bump
thenerd
17
Years of Service
User Offline
Joined: 9th Mar 2009
Location: Boston, USA
Posted: 3rd Nov 2010 12:41
Don't bump a thread like that, you posted the same day. Be patient. I have a pretty good console example, I'll try to wrap it up in one function when I get home.

Grog Grueslayer
Valued Member
21
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 3rd Nov 2010 19:06 Edited at: 3rd Nov 2010 19:11
Quote: "points 2,3,4,5, and 6 are things i don't know how to do, also how"


#2 it just a standard variable that represents the start of the window viewed text. If you use the command ARRAY COUNT() that shows how big the array is and subtract 10 you'll start 10 lines from the bottom of the array. I changed it to 10 lines to fit in your console window.



#3 is a FOR/NEXT loop that shows the array starting from the top-of-the-window variable to 10 lines after the top-of-the-window variable.



#4 can be done a couple of ways. You can use a FOR/NEXT loop to reassign each element in the array or you can use IanMs Matrix 1 Utilities Plugins ROTATE ARRAY command.





#5 and #6 you use the INC and DEC command to increase/decrease the number.



Quote: "this is the console that i have made from your code, but there is also problem with console that can open and close with the same key, like pressing tilde key for opening and closing of the console."


The easiest way to use the same key for both turning on and off the console and not opening and quickly closing the console window again is to use a REPEAT/UNTIL loop after the user hits the key to check for no keys are being pressed. It does stop all action till the user lets go of the key but generally people don't sit there and hold the key down forever.



Here's the entire program:


And if you really want to make cool programs you need to add IanMs Matrix 1 Utilities Plugin to Darkbasic Pro (so you can use ROTATE ARRAY).

http://forum.thegamecreators.com/?m=forum_view&t=85209&b=18

nruser
18
Years of Service
User Offline
Joined: 22nd Dec 2007
Location: Serbia
Posted: 3rd Nov 2010 21:03
your code works excellent, i wasted around 5 or 10 days on getting console to work, thank you.
Sasuke
20
Years of Service
User Offline
Joined: 2nd Dec 2005
Location: Milton Keynes UK
Posted: 3rd Nov 2010 21:29 Edited at: 3rd Nov 2010 21:40
Another example, closely resembling Doom 3's console:

Wrote it quick, needs editing.


Though, I'd probably not even use an array for this style of console. Just bitmap font and a bitmap, maybe just a log array to dump the console info into for a console log text file, but the console it's self, doesn't really need one.

A dream is a fantasy, if you achieve that fantasy it was never a dream to begin with.
nruser
18
Years of Service
User Offline
Joined: 22nd Dec 2007
Location: Serbia
Posted: 4th Nov 2010 00:44
that some really nice stuff, i wanted to something like this, but can you make contents of the console scrollable so when you press PageUp and PageDown, you move the contents of the console for one row up or down. Also, what does this do

Sasuke
20
Years of Service
User Offline
Joined: 2nd Dec 2005
Location: Milton Keynes UK
Posted: 4th Nov 2010 02:01
array insert at bottom inserts a blank item at the end of the array list, basically expanding it. Though I delete an item before adding one to keep it a fixed size.

Quote: "but can you make contents of the console scrollable so when you press PageUp and PageDown, you move the contents of the console for one row up or down"


Actually you should be able to create that affect based on the knowledge Grog Grueslayer has posted. His example can be easily implemented into mine or mine into his. Give it a try first then if you have issues post back with your problems. Were not here to do all the work remember, but we'll gladly help with any issues you run into.

A dream is a fantasy, if you achieve that fantasy it was never a dream to begin with.
nruser
18
Years of Service
User Offline
Joined: 22nd Dec 2007
Location: Serbia
Posted: 4th Nov 2010 03:39
ok i have tried to combine these two codes from above and sasuke's code confused me, so i ended up with coloring problem what should i do to make colorign work like in sasuke's code

Sasuke
20
Years of Service
User Offline
Joined: 2nd Dec 2005
Location: Milton Keynes UK
Posted: 5th Nov 2010 02:52
Here's how I edited my code to do what you want:



A dream is a fantasy, if you achieve that fantasy it was never a dream to begin with.
nruser
18
Years of Service
User Offline
Joined: 22nd Dec 2007
Location: Serbia
Posted: 7th Nov 2010 22:44
i have find out that there is no way to suspend game's reaction to game controls and mouselook, how can i suspend the game so it doesn't react on controls but only on console window, but i still doesn't want to suspend entire game.
Neuro Fuzzy
19
Years of Service
User Offline
Joined: 11th Jun 2007
Location:
Posted: 7th Nov 2010 23:43
Create a variable, lets call it A. If the console is up, then A=1, if the console is down, then A=0. So only move your player or have game controls working if A=0.

Phaelax
DBPro Master
23
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 8th Nov 2010 20:52
Quote: "The easiest way to use the same key for both turning on and off the console and not opening and quickly closing the console window again is to use a REPEAT/UNTIL loop after the user hits the key to check for no keys are being pressed. It does stop all action till the user lets go of the key but generally people don't sit there and hold the key down forever."

Never assume the user won't try to do something.

I'd use this to toggle the console:



Also, for the buffer, rather than manually shifting the array elements around, why not just use a queue and when it reaches the size limit, just pop the first element and add your new one.

Your signature has been erased by a mod please reduce it to 600 x 120.
nruser
18
Years of Service
User Offline
Joined: 22nd Dec 2007
Location: Serbia
Posted: 9th Nov 2010 01:03
I have encountered the problem with console commands, what if i want to load a level via console command, i could write map level$ where map is command and level$ is the command argument. But it cant be done with select case because it can use string and not additional arguments.
Sasuke
20
Years of Service
User Offline
Joined: 2nd Dec 2005
Location: Milton Keynes UK
Posted: 9th Nov 2010 01:50 Edited at: 9th Nov 2010 01:51


or



The key to coding is experimentation, have a play to see if stuff works.

A dream is a fantasy, if you achieve that fantasy it was never a dream to begin with.
Grog Grueslayer
Valued Member
21
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 9th Nov 2010 07:58
Quote: "Never assume the user won't try to do something."


True but hopefully they wouldn't want to do it very much since it stops the game.

Quote: "I'd use this to toggle the console:"


That's a nice way to do since it doesn't pause the action till the user lets go of the key. The newest coolest method that I've found is using GET KEY STATE() and SET KEY STATE TOGGLE() commands. It treats every key (even the unique buttons on some keyboards like volume up/down) and mouse buttons like a toggle switch so there's no need for any variable switches. Well, not every key... I have yet to find a tilde key unless I'm blind.

This one uses the Tab key:


Phaelax
DBPro Master
23
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 9th Nov 2010 08:08
Are those new key commands? I haven't seen them before.

Your signature has been erased by a mod please reduce it to 600 x 120.
Grog Grueslayer
Valued Member
21
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 9th Nov 2010 16:39
Quote: "Are those new key commands? I haven't seen them before."


I'm not exactly sure when they were added to Darkbasic Pro. I discovered them back in September while helping a newbie. The newbie didn't seem too impressed with the commands but I was totally amazed because of their huge potential. Now if we can just get Lee to add all the keys.

Here's the message I posted after noticing them in the help files (9th post from the top):
http://forum.thegamecreators.com/?m=forum_view&t=175704&b=7&p=0

Login to post a reply

Server time is: 2026-07-26 05:03:42
Your offset time is: 2026-07-26 05:03:42