![]() |
|
[Python] Dice roll game: What do do to only make it roll when I press a key? - 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: [Python] Dice roll game: What do do to only make it roll when I press a key? (/showthread.php?tid=6062216) |
Dice roll game: What do do to only make it roll when I press a key? - ICUP - Apr 1, 2020 Hi. Very beginner here. Just finished the basics yesterday and still watching Automate the Boring Stuff with Python. I'm trying to write my first dice rolling game but I'd like to add more stuff into it since the tut that I followed was very basic. I'd like it to roll only when the user is ready / presses a key . 1st roll for Player1 only when player 1 presses a key 1st roll for Player 2 only when player 2 presses a key 2nd roll for Player1 only when player 1 presses a key and so on loop until they reach round 3 and finds a winner. PHP Code I feel like the main function needs to be changed by I don't know how and I'm stuck. Thank you! RE: Dice roll game: What do do to only make it roll when I press a key? - ihatevim - Apr 1, 2020 Code import randomIt's just a matter of using input again without actually caring about input. I got rid of a useless variable (ready_to_roll) and put your names into a get name function to help you with what needs to be done next. Your next focus should be to check if the user gave a valid response for the name (a null response will break the program). Following that, you should add a conditional for the counters of the wins of each player so that the game ends early if a player wins twice in a row (e.g. if x wins twice there is no reason for them to roll a third time since it is best 2/3). Another thing to consider is clean code practices. Get used to following one naming scheme, if you used snake_case, then keep snake_case. If you use camelCase, then keep camelCase. Avoid mix and matching. RE: Dice roll game: What do do to only make it roll when I press a key? - ICUP - Apr 1, 2020 (Apr 1, 2020 12:38 PM)ihatevim Wrote: Huh. That was very easy. My codes will be very messy for a while, I'm sure. Thanks for the help! RE: Dice roll game: What do do to only make it roll when I press a key? - lockhead - Apr 3, 2020 (Apr 1, 2020 02:03 PM)๖ۣۜƝeil™ Wrote: Huh. lmao. always my reaction after hunting bugs for 8 hours |