-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGame.py
145 lines (127 loc) · 4.46 KB
/
Game.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
import pygame
from Player import Player
import time, threading
from random import randrange
from Mode_ctb import Fruit
from Mode_osu import std
from pygame import mixer
from Mode_taiko import taiko
import math
class Game():
def __init__(self):
self.player = Player()
self.std = std()
self.fruit = Fruit()
self.taiko = taiko()
self.pressed = {}
self.is_playing = False
self.is_playing_ctb = False
self.std.song()
#autre mode de jeux ên construction
def update_ctb(self,screen):
#ajoute du texte
font = pygame.font.Font("freesansbold.ttf", 50)
textScore = font.render("CTBscore :"+str(self.std.score),True,(255,255,255))
textVie = font.render("Vie :"+str(self.std.fail),True,(255,255,255))
#pour la boucle en bas
boucle = True
background = pygame.image.load('image/menu.jpg')
background = pygame.transform.scale(background, (1280, 720))
screen.blit(background,(0,0))
screen.blit(self.player.imagectb,self.player.rect)
#recupere les touche si droite ou gauche
for event in pygame.event.get():
if event.type == pygame.KEYDOWN or event.type == pygame.KEYUP:
if event.key == pygame.K_RIGHT:
self.player.move_right()
screen.blit(self.player.imagectb,self.player.rect)
if event.key == pygame.K_LEFT:
self.player.move_left()
screen.blit(self.player.imagectb,self.player.rect)
while boucle:
#lorsque le perso est en contact avec lobjet tombant
if self.player.rect.colliderect(self.std.rect):
self.std.WhenYouTouch()
screen.blit(textScore, (0, 0))
screen.blit(textVie, (0, 50))
if self.std.fail <=0:
#change d'interface
self.update_Defaite(screen)
break
self.std.fall()
screen.blit(self.std.image, self.std.rect)
boucle = False
#le mode ctb
def update(self,screen):
#ajoute du texte
font = pygame.font.Font("freesansbold.ttf", 50)
textScore = font.render("OSUScore :"+str(self.std.score),True,(255,255,255))
textVie = font.render("Vie :"+str(self.std.fail),True,(255,255,255))
#pour la boucle en bas
boucle = True
background = pygame.image.load('image/menu.jpg')
background = pygame.transform.scale(background, (1280, 720))
screen.blit(background,(0,0))
#lorsque le joueur touche un cercle
for event in pygame.event.get():
if event.type == pygame.MOUSEBUTTONDOWN:
if self.std.rect.collidepoint(event.pos):
self.std.WhenYouTouch()
print("ta gagner un point vous avez ["+str(self.std.score)+"] de point")
while boucle:
screen.blit(textScore, (0, 0))
screen.blit(textVie, (0, 50))
if self.std.fail <=0:
#change d'interface
self.update_Defaite(screen)
break
self.std.fall()
screen.blit(self.std.image, self.std.rect)
boucle = False
#interface defaite
def update_Defaite(self,screen):
#charge une image
boutonQuit = pygame.image.load('image/bouton_quit.png')
#modifie la taille de l'image (x y)
boutonQuit=pygame.transform.scale(boutonQuit,(200,70))
#
boutonQuitRect = boutonQuit.get_rect()
#place l'image dans la fenetre
boutonQuitRect.x = math.ceil(screen.get_width()/2.5)
boutonQuitRect.y = math.ceil(screen.get_height()/3)
screen.blit(boutonQuit,boutonQuitRect)
pygame.display.flip()
#si j'appui sur le bouton quit
for event in pygame.event.get():
if event.type == pygame.MOUSEBUTTONDOWN:
if boutonQuitRect.collidepoint(event.pos):
self.is_playing = False
self.is_playing_ctb = False
self.std.reset()
self.std.song()
def update_taiko(self,screen):
#ajoute du texte
font = pygame.font.Font("freesansbold.ttf", 50)
textScore = font.render("TaikScore :"+str(self.taiko.score),True,(255,255,255))
textVie = font.render("Vie :"+str(self.taiko.fail),True,(255,255,255))
#pour la boucle en bas
boucle = True
background = pygame.image.load('image/menu.jpg')
background = pygame.transform.scale(background, (1280, 720))
screen.blit(background,(0,0))
#lorsque le joueur touche un cercle
for event in pygame.event.get():
if event.type == pygame.MOUSEBUTTONDOWN:
if self.taiko.rect.collidepoint(event.pos):
self.taiko.WhenYouTouch()
print("ta gagner un point vous avez ["+str(self.taiko.score)+"] de point")
while boucle:
screen.blit(textScore, (0, 0))
screen.blit(textVie, (0, 50))
if self.taiko.fail <=0:
#change d'interface
self.update_Defaite(screen)
break
self.taiko.fall()
screen.blit(self.taiko.image, self.taiko.rect)
boucle = False