I have just started and have not any graphics still. I am just
creating .py file that include turns of two players.
It's my first game or a program in python.
Here is a simple code if you can read it:
class Step:
posP1=0
posP2=0
def __init__(self,dice):
self.dice=dice
Step.posP1+=dice
Step.posP2+=dice
def displayMove(self):
print "total move: %d"%Step.move
def displayStep(self):
print ",dice: ",self.dice
import random
print '\n\n\n\n'
def player1():
while Step.posP1!=100:
loop1()
def player2():
while Step.posP2!=100:
loop2()
def loop2():
input=2
reqd=int(raw_input('Player2:- press 2 to throw dice: '))
if reqd==input:
dice=random.choice([1,2,3,4,5,6])
num=Step(dice)
num.displayStep()
print "Player2 position: %d"%Step.posP2
player1()
else:
print "player2 pressed wrong key"
def loop1():
input=1
reqd=int(raw_input('Player1:- press 1 to throw dice: '))
if reqd==input:
dice=random.choice([1,2,3,4,5,6])
num=Step(dice)
num.displayStep()
print "Player1 position: %d"%Step.posP1
player2()
else:
print 'no its wrong'
def main():
player1()
if __name__ == '__main__': main()
#End of program
# I hope you understand my problem
# It's both players using same data
#how should i improve it?
# Thanks for your reply as well as help
Attachment:
pygame-boilerplate.py
Description: Binary data