Tests examples for the miniworldmaker engine https://www.miniworldmaker.de
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
miniworldmaker_cookbook/snippets/10 Collisions/10_05_object_based_collisio...

40 lines
985 B

import miniworldmaker
board = miniworldmaker.PixelBoard()
board.columns=300
board.rows=200
board.add_background("images/soccer_green.jpg")
board.add_background("images/space.jpg")
board.speed = 30
player1 = miniworldmaker.Token(position=(30, 4))
player1.size = (40, 40)
player1.add_costume("images/char_blue.png")
player1.costume.orientation = - 90
player2 = miniworldmaker.Token(position=(3, 4))
player2.size = (40, 40)
player2.add_costume("images/char_blue.png")
player2.costume.orientation = - 90
player3 = miniworldmaker.Token(position=(90, 4))
player3.size = (40, 40)
player3.add_costume("images/char_blue.png")
player3.costume.orientation = - 90
@player1.register
def act(self):
print("p1 rect", self.rect)
@player2.register
def act(self):
print("p2 rect", self.rect)
@player1.register
def on_sensing_token(self, token):
global player2
print("player 1: I'm sensing a collision with", token)
print("token is player 2?", token==player2)
board.run()