![]() |
|
[C] HiLo Game Tweaking - Printable Version +- Hack Forums (https://hackforums.net) +-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444) +--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151) +---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118) +---- Thread: [C] HiLo Game Tweaking (/showthread.php?tid=1410767) |
HiLo Game Tweaking - ViciouS - Jun 23, 2011 Alright, so I am a beginner "coder" and I was messing around with a game called "HiLo" and I finally got it to display different results depending on how many guesses you attempt. However, I'm not sure how to implement my next step. What I want to do is tell the user a certain message and end the game if they reach too many guesses. Something like "You've used 20 guesses already. Forget it. Game Over." What line should I use or how should I put it in? Code #include <iostream>Also, I have heard bad things about the system pause but I was taught that way. I replace with "cin.get()" or something like that, right? * - Irritiable - Jun 23, 2011 (Jun 23, 2011 05:42 PM)ViciouS Wrote: Alright, so I am a beginner "coder" and I was messing around with a game called "HiLo" and I finally got it to display different results depending on how many guesses you attempt. However, I'm not sure how to implement my next step. What I want to do is tell the user a certain message and end the game if they reach too many guesses. Something like "You've used 20 guesses already. Forget it. Game Over." What line should I use or how should I put it in? Hello, ViciouS. For your first question, regarding exiting prematurely based on a number of guesses, how would we accomplish this? Because the word "guesses" means there is more than one guess, I am assuming we are using a loop. This means we have to count (keep track of) the number of guesses the user has made. Every iteration we can increment (add to) this count by one; To represent another guess. When the number of guesses has exceeded a certain amount, we exit the loop! Example: Code #include <iostream>I hope this leads to a solution for your problem! 🙂 Yes, you can use cin.get() to 'hold the execution window open.' You can also use an IDE for that, or simply open it with command prompt. |