Example #1
0
wn.bgcolor('#220022')
wn.tracer(0)
wn.listen()

# Goodbye to the game
wn.onkeypress(bye, 'Escape')

# Players
player1 = GameObject('circle', '#880000', 1, 1, -200, 0)
player1.binds(wn, ['w', 's', 'a', 'd'])

player2 = GameObject('square', '#008800', 1, 1, 200, 0)
player2.binds(wn, ['Up', 'Down', 'Left', 'Right'])

# Their lives
player1.lives = 3
player2.lives = 3

# The floors
leftFloor = Obstacle(10, 'x', '#FFFFFF', -350, -250)
middleFloor = Obstacle(10, 'x', '#FFFFFF', 0, -250)
rightFloor = Obstacle(10, 'x', '#FFFFFF', 350, -250)

# Walls in the middle
leftWall = Obstacle(10, 'y', '#FF2806', -270, 150)
leftMidWall = Obstacle(10, 'y', '#FF2806', -135, -50)
midWall = Obstacle(10, 'y', '#FF2806', 0, 150)
rightMidWall = Obstacle(10, 'y', '#FF2806', 135, -50)
rightWall = Obstacle(10, 'y', '#FF2806', 270, 150)

# The pen for writing things