Jump to content

View more

Image of the Day

Boxes as reward for our ranking mode. ヾ(☆▽☆)
#indiedev #gamedev #gameart #screenshotsaturday https://t.co/ALF1InmM7K
IOTD | Top Screenshots

The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.


Sign up now

Fallout 3 Terminal in C++

4: Adsense

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.


  • You cannot reply to this topic
4 replies to this topic

#1 JonathanCCC   Members   

163
Like
0Likes
Like

Posted 11 July 2014 - 02:48 PM

hello,

 

I'm making some console apps and games in C++ while I learn the language.

 

I really like the terminals in the game Fallout 3 and would like to make my console apps similar. Is there a way I can achieve a similar effect to the way text is drawn to the screen without any add-ons like ncurses etc?

 

Say for example drawing 5 characters to the screen, then half a second later another 5 etc to simulate that effect?

 

If you skip to 00:58 on the below link you'll understand what I'm after. Thanks!

 



#2 Erik Rufelt   Members   

5901
Like
0Likes
Like

Posted 11 July 2014 - 04:28 PM

std::string message = "Hi I'm a console with really badly optimized text rendering capabilities";

for(size_t i = 0; i < message.length(); ++i) {
  std::cout << message[i];
  
  Sleep(50);
}

On Windows #include Windows.h for Sleep which is in milliseconds, and on Linux you can use usleep in unistd.h, and usleep is in microseconds.

 

 

EDIT:

Actually, if you have a reasonably up-to-date compiler you can use the built-in sleep if you include <chrono> and <thread>:

std::this_thread::sleep_for(std::chrono::milliseconds(50));

Edited by Erik Rufelt, 11 July 2014 - 04:32 PM.


#3 SeanMiddleditch   Members   

17484
Like
6Likes
Like

Posted 11 July 2014 - 04:46 PM

*
POPULAR

On Windows #include Windows.h for Sleep which is in milliseconds, and on Linux you can use usleep in unistd.h, and usleep is in microseconds.


Or in order to not make your whole game pause, use timers in your game. Something like this semi-pesudo-code:

Draw() {
  timer += elapsed_time;
  if (timer > 0.5f) {
    length = min(max_lenth, length + 5);
    timer -= 0.5f;
  }

  DrawText(string, length);
}
Then every half second, 5 more characters will be added to how many can be drawn at a time. You'll need to account for layout and other VFX of course but that's the gist of it.

Game Developer, C++ Geek, Dragon Slayer - http://seanmiddleditch.com

C++ SG14 "Games & Low Latency" - Co-chair - public forums

Wargaming Seattle - Lead Server Engineer - We're hiring!


#4 NightCreature83   Members   

4949
Like
1Likes
Like

Posted 12 July 2014 - 06:59 AM

The other option is to use a mask that animates per line on the rendering. You can then just set the text of all lines and the mask animation will reveal text as goes a long untill it is finished.

 

Ignore this I missed the console app, my solution will only work if you are doing some fancy rendering


Edited by NightCreature83, 12 July 2014 - 07:00 AM.

Worked on titles: CMR:DiRT2, DiRT 3, DiRT: Showdown, GRID 2, theHunter, theHunter: Primal, Mad Max


#5 JonathanCCC   Members   

163
Like
0Likes
Like

Posted 27 July 2014 - 03:08 PM

on that subject, at the moment i've just been doing exclusively console based games for windows.

 

If I did want to branch out in some graphics for more fancy text games like the fallout terminal, what is the easiest thing to use with C++ do you think to achieve something like that and practice graphics for text games?

 

EDIT: just for the record I'm clueless on graphics and have never done anything but console stuff.


Edited by JonathanCCC, 27 July 2014 - 03:18 PM.





Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.