I'm trying to make a shooting video game in conole mode but the game pauses to recieve an input from the key board. Ho can I get around this? How do game engines work? DFor exaple in a game like pac-man where the ghosts and other elements in the game work in real-time independently of the player's input, how can I achiev this in console mode?
CodeBoy101
-2
Junior Poster in Training
Recommended Answers
Jump to Post>Ho can I get around this?
You'll have to learn about working with multiple threads or multiple processes. That's a rather broad and complicated topic for a forum post though, try google.
Jump to PostYou don't need threads, just a means of reading all your input device(s) without blocking.
For example, this.
Jump to PostYou need to get familiar with event-driven programming.
SDL is a good place to start.
Running two functions at once is possible by using multi-threading as was pointed out but it is generally used for far more complicated things..
All 12 Replies
Narue
5,707
Bad Cop
Team Colleague
CodeBoy101
commented:
Very helpful, he gave the perfect solution!
+1
Salem
5,138
Posting Sage
phalaris_trip
5
Junior Poster in Training
CodeBoy101
-2
Junior Poster in Training
Salem
5,138
Posting Sage
CodeBoy101
-2
Junior Poster in Training
Narue
5,707
Bad Cop
Team Colleague
Salem
5,138
Posting Sage
CodeBoy101
-2
Junior Poster in Training
CodeBoy101
-2
Junior Poster in Training
jbennet
1,618
Most Valuable Poster
Team Colleague
Featured Poster
CodeBoy101
-2
Junior Poster in Training
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.