def collision_ennemi(self): for e in self.tab_enemy: coord_ennemi = Coord_XY_XY(e.x0, e.y0, e.x1, e.y1) coord_joueur = Coord_XY_XY(self.c.x0, self.c.y0, self.c.x1, self.c.y1) if coord_ennemi.collision(coord_joueur): self.game_over = True self.afficher_texte_sur_canvas(GAME_OVER)
def collision_ennemi(self): for e in self.tab_ennemi: coord_ennemi = Coord_XY_XY(e.x0, e.y0, e.x1, e.y1) A = self.boule_position coord_joueur = Coord_XY_XY(A['x0'], A['y0'], A['x1'], A['y1']) if coord_ennemi.collision(coord_joueur): self.game_over = True self.enregistrer_meilleur_score(self.points)
def collision_mur(self): for bm in self.bloc_mur.tab_bloc_mur: x0, y0, x1, y1 = bm coord_bloc_mur = Coord_XY_XY(x0, y0, x1, y1) coord_joueur = Coord_XY_XY(self.c.x0, self.c.y0, self.c.x1, self.c.y1) if coord_bloc_mur.in_limite(coord_joueur): return False return True
def collision_coin(self): for c in self.coin.tab_coins: x0, y0, x1, y1 = c[0], c[1], c[0] + 15, c[1] + 15 coord_coin = Coord_XY_XY(x0, y0, x1, y1) coord_joueur = Coord_XY_XY(self.c.x0, self.c.y0, self.c.x1, self.c.y1) if coord_coin.collision(coord_joueur): self.points += 10 self.score['text'] = "Score : %d" % (self.points) id = self.can.create_oval(x0, y0, x1, y1, outline=COLOR_VIOLET, fill=COLOR_VIOLET) self.all_id_widget.append(id) self.creer_joueur(self.c.x0, self.c.y0, self.c.x1, self.c.y1)
def win(self): coord_fin = Coord_XY_XY(600, 400, 650, 450) coord_joueur = Coord_XY_XY(self.c.x0, self.c.y0, self.c.x1, self.c.y1) if coord_fin.in_limite(coord_joueur): self.game_over = True self.afficher_texte_sur_canvas(GAME_WIN)
def collision_coin(self): A = self.boule_position A = Coord_XY_XY(A['x0'], A['y0'], A['x1'], A['y1']) B = self.coin_position B = Coord_XY_XY(B['x0'], B['y0'], B['x1'], B['y1']) return A.collision(B)
def est_deplacable(self): A = Coord_XY_XY(X0_CARRE, Y0_CARRE, X1_CARRE, Y1_CARRE) B = self.boule_position B = Coord_XY_XY(B['x0'], B['y0'], B['x1'], B['y1']) return A.in_limite(B)