[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] timing question



 
Hi Again,
    This is the example you want for what you are doing.
 
    Enjoy!
 
        Bruce
 
# File: msvcrt-example-2.py
import msvcrt
import time
print "press SPACE to enter the serial number"
while not msvcrt.kbhit() or msvcrt.getch() != " ":
# do something else while we're waiting
    print ".",
    time.sleep(0.1)
print
# clear the keyboard buffer
while msvcrt.kbhit():
    msvcrt.getch()
serial = raw_input("enter your serial number: ")
print "serial number is", serial
c = raw_input( "Please Hit Enter To Continue __> ")
----- Original Message -----
Sent: Tuesday, January 29, 2008 5:06 AM
Subject: [pygame] timing question

Hi all,

I'm writing a little text-based game and I have stumbled upon a strange newbie problem.
In this game, the player has to input a number of commands in order to interact with the game. I am using raw_input to get input from the player.
My problem is that I want to make it turn based, and I want to limit the amount of time players have per turn. And I don't know how to do that. I have tried to create an event and push it to the event list, but it doesn't act until the player provides input, so it is not working.
So the idea is:
player provides specific input (raw_input)
game objects are affected by input
+1 turn
if turns = x:
game over

I am quite sure this is a simple problem, but I have been going around it for a couple of days with no success - help! :)

thanks!

mundial