def load_next_GIF(self): print('LOAD NEXT CALLED') self.loadingNextGIF = True self.nextGIF = GIFImage(self.choose_next_GIF()) modes = pygame.display.list_modes() self.nextGIF.scale_image(modes[0]) print(self.nextGIF.loaded)
def __init__(self, petType, name, isImage, moveCycleLen=30): WHITE = (255, 255, 255) picture = os.getcwd() + "/graphicAssets/SpriteBala.png" self.petType = petType self.name = name self.isImage = isImage self.moveCycleLen = moveCycleLen self.frameCycleCount = 1 self.currX = 0 self.currY = 0 if (str(petType) == str(PetType.BALA)): picture = os.getcwd() + "/graphicAssets/SpriteBala.png" elif (str(petType) == str(PetType.MAMAU)): picture = os.getcwd() + "/graphicAssets/SpriteMamau.png" elif (str(petType) == str(PetType.TORA)): picture = os.getcwd() + "/graphicAssets/SpriteTora.png" elif (str(petType) == str(PetType.BALAGIF)): picture = os.getcwd() + "/graphicAssets/SpriteBalaGif" elif (str(petType) == str(PetType.MAMAUGIF)): picture = os.getcwd() + "/graphicAssets/SpriteMamauGif" elif (str(petType) == str(PetType.TORAGIF)): picture = os.getcwd() + "/graphicAssets/SpriteToraGif" if (self.isImage): self.image = pg.image.load(picture) self.image.set_colorkey(WHITE) self.image = pg.transform.smoothscale(self.image, (105, 135)) else: self.image = GIFImage(picture, 0, 0, PETFRAMECYCLE) self.image.resize(105, 135)
class GIFMode: def __init__(self): self.surface = None self.currentGIF = None self.nextGIF = None self.loadingNextGIF = False self.files = os.listdir(imagePath) self.isActive = True self.playTime = 200 self.currentTime = 0 def set_surface(self, surface): self.surface = surface def play_next_GIF(self): print('PLAY NEXT CALLED') self.currentGIF = self.nextGIF self.currentGIF.play() self.nextGIF = None def load_next_GIF(self): print('LOAD NEXT CALLED') self.loadingNextGIF = True self.nextGIF = GIFImage(self.choose_next_GIF()) modes = pygame.display.list_modes() self.nextGIF.scale_image(modes[0]) print(self.nextGIF.loaded) def choose_next_GIF(self): return (imagePath + self.files[randint(0, len(self.files) - 1)]) def render_current(self): if self.currentGIF is not None: #print('I like to render') self.currentGIF.render(self.surface, (0, 0)) self.currentTime += 1 def run(self): if self.isActive is True: # Check to see if next gif is loaded ---------------------------------- if self.nextGIF is None: self.load_next_GIF() elif self.loadingNextGIF is True: if self.nextGIF.loaded is True: self.nextGIF.pause() self.loadingNextGIF = False #---------------------------------------------------------------------- if self.nextGIF is not None and self.currentGIF is None: self.play_next_GIF() #---------------------------------------------------------------------- self.render_current() #---------------------------------------------------------------------- if self.currentTime >= self.playTime: self.currentGIF = None self.currentTime = 0
def __init__(self): self.image_asriel = GIFImage("gif/test3.gif") self.pos = self.image_asriel.get_rect() self.asrielx = 270 self.pos = self.pos.move(self.asrielx, 10) self.maxlife = 1000 self.life = self.maxlife self.timerC = 0 self.dg = randint(0, 1)
def loading_images(): path = '/home/pi/catkin_ws/src/head_driver_pkg/src/emotions/' dirs = os.listdir(path) for file in dirs: if file[-4:] == ".gif": show_text("loading image : " + file[:-4], 75, (400, 240)) images.update({file[:-4]: GIFImage(path + file)})
def display_loading(): gifs = os.listdir(LOAD_IMAGE_DIR) loading_gif = GIFImage(os.path.join(LOAD_IMAGE_DIR, random.choice(gifs))) x_coord = get_center_width_offset(loading_gif.image) y_coord = get_center_height_offset(loading_gif.image) screen.fill(RGB_BLACK) display.flip() while True: loading_gif.render(screen, (x_coord,y_coord)) display.flip() if not IMAGES_EVENT.isSet(): return check_for_exit()
class DisplayGifScene(Scene): """Affiche un .gif""" _pos = None def __init__(self, name, next_scene): super(DisplayGifScene,self).__init__() if name.endswith('.gif'): self.gif = GIFImage(join(dirname(__file__),'resources',name)) self.next_scene = next_scene def update(self): pass def render(self, screen): if self.gif: if self._pos is None: r = screen.get_rect() self._pos = (int((r[2] - self.gif.image.size[0]) / 2), int((r[3] - self.gif.image.size[1]) / 2)) self.gif.render(screen,self._pos)
def __init__(self): os.environ['SDL_VIDEO_CENTERED'] = '1' # Centramos la ventana # Establecemos algunos atributos iniciales de juego: background, imagen de perdida y de vencedor entre otras self.screen = pygame.display.set_mode( (constants.SCREEN_WIDTH, constants.SCREEN_HEIGHT)) self.background_image = self.load_image( "images/background_initial.png").convert() self.instruccion = GIFImage("intro.gif") self.myMovie = pygame.movie.Movie("introduccion12.mpg") self.gameover = self.load_image("game-over.jpg").convert() self.gana = self.load_image("win.png").convert() self.pause = True self.active = True
def __init__(self, name, next_scene): super(DisplayGifScene,self).__init__() if name.endswith('.gif'): self.gif = GIFImage(join(dirname(__file__),'resources',name)) self.next_scene = next_scene
############################## ############################## ######boucle infini###### while True: ######definition de la fenetre###### pygame.init() pygame.mouse.set_visible(False) fenetre = pygame.display.set_mode((500,300)) #icon+nom icon_32x32 = pygame.image.load("sprite/perso.png").convert_alpha() pygame.display.set_icon(icon_32x32) pygame.display.set_caption("ShooterTale") #fond d'ecran fond = GIFImage("gif/082.gif") ######musique du menu###### menusound = pygame.mixer.Sound("sound/menu.ogg") select = pygame.mixer.Sound("sound/menuselect.wav") menusound.set_volume(zik/100) select.set_volume(sfx/100) menusound.play(loops=-1, maxtime=0, fade_ms=0) ######police d'ecriture + definition des éléments du menu###### font=pygame.font.Font("font/DTM-Sans.otf", 36) jouer=font.render("Jouer",1,(255,255,255)) audio=font.render("Audio",1,(255,255,255)) quitter=font.render("Quitter",1,(255,255,255))
screen: None = pygame.display.set_mode((X, Y), pygame.FULLSCREEN) pygame.display.set_caption('TIMER') fontSize = int(X // 3.2) # fontName = 'digital-7' # font = pygame.font.SysFont(fontName, fontSize) # josefin, laser, mazzard, neon, nidus sans, one day, ostrich sans, rajdhani, sulivan, swgdt, tw cent mt, fontName = 'LASER REGULAR.ttf' font = pygame.font.Font( os.path.dirname(os.path.abspath(__file__)) + "/" + "fonts/" + fontName, fontSize) # BACKGROUND SCREEN # hud1 = GIFImage(os.path.dirname(os.path.abspath(__file__)) + "/" + "images/hud1-1120x702.gif") hud1 = GIFImage( os.path.dirname(os.path.abspath(__file__)) + "/" + "images/network2-432x768.gif") # hud1 = GIFImage(os.path.dirname(os.path.abspath(__file__)) + "/" + "images/network2-768x1366.gif") hud2 = GIFImage( os.path.dirname(os.path.abspath(__file__)) + "/" + "images/blueneon-432x768.gif") # hud2 = GIFImage(os.path.dirname(os.path.abspath(__file__)) + "/" + "images/blueneon-768x1366.gif") # handaccess = GIFImage(os.path.dirname(os.path.abspath(__file__)) + "/" + "images/handaccess1-432x507.gif") handaccess = GIFImage( os.path.dirname(os.path.abspath(__file__)) + "/" + "images/handaccess1.gif") fingerscan = [ GIFImage( os.path.dirname(os.path.abspath(__file__)) + "/" + "images/fingerscan-136x150.gif") ] * 5
def main(): global currPet global currGameState is_draggable = False on_pizza = False on_edamame = False on_fruitTart = False on_rice = False offset_x = 0 offset_y = 0 m_x = 0 m_y = 0 pizza_x = 100 pizza_y = 350 edamame_x = 280 edamame_y = 350 fruitTart_x = 530 fruitTart_y = 350 rice_x = 650 rice_y = 350 savefile = open(os.getcwd() + "/save/saveFile.txt", "a+") FRAMERATE = 12 titleBG = GIFImage(os.getcwd() + "/graphicAssets/BgTitle3") homeBG = GIFImage(os.getcwd() + "/graphicAssets/BgTitle5") homeBG.resize(800, 480) qaBG = GIFImage(os.getcwd() + "/graphicAssets/BgTitle4") qaBG.resize(800, 480) sleepBG = GIFImage(os.getcwd() + "/graphicAssets/SleepBG") sleepBG.resize(800, 480) waterBG = GIFImage(os.getcwd() + "/graphicAssets/BgWater") waterBG.resize(800, 480) foodBG = GIFImage(os.getcwd() + "/graphicAssets/BgFood") foodBG.resize(800, 480) playBG = GIFImage(os.getcwd() + "/graphicAssets/BgPlay") playBG.resize(800, 480) #loading food images pizza = pg.image.load(os.getcwd() + "/graphicAssets/pizza.png") fruitTart = pg.image.load(os.getcwd() + "/graphicAssets/fruitTart.png") rice = pg.image.load(os.getcwd() + "/graphicAssets/rice.png") edamame = pg.image.load(os.getcwd() + "/graphicAssets/edamame.png") eggUnhatched = GIFImage(os.getcwd() + "/graphicAssets/EggUnhatched", WIDTH / 4 + 80, HEIGHT / 2 - 170, 15) eggUnhatched.resize(250, 250) eggHatchedBala = GIFImage(os.getcwd() + "/graphicAssets/EggHatchedBala2") eggHatchedBala.resize(200, 200) eggHatchedBala.setCoords(300, 130) eggHatchedMamau = GIFImage(os.getcwd() + "/graphicAssets/EggHatchedMamau2") eggHatchedMamau.resize(200, 200) eggHatchedMamau.setCoords(300, 130) eggHatchedTora = GIFImage(os.getcwd() + "/graphicAssets/EggHatchedTora2") eggHatchedTora.resize(200, 200) eggHatchedTora.setCoords(300, 130) showerBG = GIFImage(os.getcwd() + "/graphicAssets/ShowerBG") showerBG.resize(800, 480) showerBala = GIFImage(os.getcwd() + "/graphicAssets/ShowerBala", WIDTH / 4 + 80, HEIGHT / 2 + 40, 15) showerBala.resize(150, 200) showerDoneBala = GIFImage(os.getcwd() + "/graphicAssets/ShowerDoneBala", WIDTH / 4 + 80, HEIGHT / 2 + 40, 15) showerDoneBala.resize(150, 200) showerMamau = GIFImage(os.getcwd() + "/graphicAssets/ShowerMamau", WIDTH / 4 + 80, HEIGHT / 2 + 40, 15) showerMamau.resize(150, 200) showerDoneMamau = GIFImage(os.getcwd() + "/graphicAssets/ShowerDoneMamau", WIDTH / 4 + 80, HEIGHT / 2 + 40, 15) showerDoneMamau.resize(150, 200) showerTora = GIFImage(os.getcwd() + "/graphicAssets/ShowerTora", WIDTH / 4 + 80, HEIGHT / 2 + 40, 15) showerTora.resize(150, 200) showerDoneTora = GIFImage(os.getcwd() + "/graphicAssets/ShowerDoneTora", WIDTH / 4 + 80, HEIGHT / 2 + 40, 15) showerDoneTora.resize(150, 200) eggUnhatched = GIFImage(os.getcwd() + "/graphicAssets/EggUnhatched", WIDTH / 4 + 80, HEIGHT / 2 - 170, 15) eggUnhatched.resize(250, 250) startButton = Buttonify(os.getcwd() + "/graphicAssets/startButton.png", screen) startButton.resize(300, 100) startButton.setCoords(100, 300) newGameButton = Buttonify(os.getcwd() + "/graphicAssets/NewGame.png", screen) newGameButton.resize(320, 110) newGameButton.setCoords(75, 180) continueGameButton = Buttonify(os.getcwd() + "/graphicAssets/LoadGame.png", screen) continueGameButton.resize(300, 100) continueGameButton.setCoords(425, 175) qa1LeftButton = RectButton(WIDTH / 4 - 145, HEIGHT / 2 + 55, 215, 50, screen, BLACK, 100) qa1MiddleButton = RectButton(WIDTH / 4 + 98, HEIGHT / 2 + 55, 215, 50, screen, BLACK, 100) qa1RightButton = RectButton(WIDTH / 4 + 340, HEIGHT / 2 + 55, 215, 50, screen, BLACK, 100) qa2LeftButton = RectButton(WIDTH / 4 - 145, HEIGHT / 2 + 55, 215, 50, screen, BLACK, 100) qa2MiddleButton = RectButton(WIDTH / 4 + 98, HEIGHT / 2 + 55, 215, 50, screen, BLACK, 100) qa2RightButton = RectButton(WIDTH / 4 + 340, HEIGHT / 2 + 55, 215, 50, screen, BLACK, 100) qa3LeftButton = RectButton(WIDTH / 4 - 145, HEIGHT / 2 + 55, 215, 50, screen, BLACK, 100) qa3MiddleButton = RectButton(WIDTH / 4 + 98, HEIGHT / 2 + 55, 215, 50, screen, BLACK, 100) qa3RightButton = RectButton(WIDTH / 4 + 340, HEIGHT / 2 + 55, 215, 50, screen, BLACK, 100) qa4LeftButton = RectButton(WIDTH / 4 - 145, HEIGHT / 2 + 55, 215, 50, screen, BLACK, 100) qa4MiddleButton = RectButton(WIDTH / 4 + 98, HEIGHT / 2 + 55, 215, 50, screen, BLACK, 100) qa4RightButton = RectButton(WIDTH / 4 + 340, HEIGHT / 2 + 55, 215, 50, screen, BLACK, 100) HomeFoodButton = RectButton(7 * WIDTH / 8, HEIGHT / 16 + 10, 90, 90, screen, BLACK, 180) HomeWaterButton = RectButton(7 * WIDTH / 8, HEIGHT / 16 + 110, 90, 90, screen, BLACK, 180) HomeSleepButton = RectButton(7 * WIDTH / 8, HEIGHT / 16 + 210, 90, 90, screen, BLACK, 180) HomeStressButton = RectButton(7 * WIDTH / 8, HEIGHT / 16 + 310, 90, 90, screen, BLACK, 180) sleepAffirmationsButton = RectButton(300, 210, 215, 50, screen, BLACK, 100) sleepLogButton = RectButton(300, 140, 215, 50, screen, BLACK, 100) sleepMeditateButton = RectButton(300, 280, 215, 50, screen, BLACK, 100) sleep_checkin_button = RectButton(20, 20, 215, 50, screen, BLACK, 100) sleep_checkin_button.getImageRect().center = (WIDTH / 2, HEIGHT / 2) sleep_question_button = RectButton(20, 20, 550, 50, screen, BLACK) sleep_question_button.getImageRect().center = (WIDTH / 2, HEIGHT / 4) sleep_response_button = RectButton(20, 20, 650, 50, screen, BLACK) sleep_response_button.getImageRect().center = (WIDTH / 2, HEIGHT / 4) backButton = RectButton(10, 10, 215, 50, screen, BLACK, 100) sleepBreatheButton = RectButton(200, 200, 215, 50, screen, BLACK, 100) exitButton = RectButton(20, HEIGHT - 70, 215, 50, screen, BLACK, 100) currPet.setCoords(WIDTH / 2, 3 * HEIGHT / 4) currPet.setMoveCycleCount(45) meditate = Meditate(screen) checkin_button = RectButton(20, 20, 215, 50, screen, BLACK, 100) checkin_button.getImageRect().center = (WIDTH / 2, HEIGHT / 2) water_question_button = RectButton(20, 20, 550, 50, screen, BLACK) water_question_button.getImageRect().center = (WIDTH / 2, HEIGHT / 4) water_response_button = RectButton(20, 20, 650, 50, screen, BLACK) water_response_button.getImageRect().center = (WIDTH / 2, HEIGHT / 4) shower_response_button = RectButton(20, 350, 100, 50, screen, BLACK) shower_response_button.getImageRect().center = (WIDTH / 2, HEIGHT / 4) shower_text_button = RectButton(20, 350, 650, 50, screen, BLACK) shower_text_button.getImageRect().center = (WIDTH / 2, HEIGHT / 4) water_drop1 = Buttonify(os.getcwd() + "/graphicAssets/WaterDrop.png", screen) water_drop2 = Buttonify(os.getcwd() + "/graphicAssets/WaterDrop.png", screen) water_exists1 = True water_exists2 = True water_drop1.resize(100, 100) water_drop2.resize(100, 100) petSum = 0 showerCount = 0 while True: clock = pg.time.Clock() ev = pg.event.get() screen.fill(WHITE) if currGameState.value > Screen.HATCH.value: currPet.food += FOOD_CHANGE_RATE currPet.water += WATER_CHANGE_RATE currPet.sleep += SLEEP_CHANGE_RATE currPet.stress += STRESS_CHANGE_RATE currPet.food = 0 if currPet.food < 0 else 100 if currPet.food > 100 else currPet.food currPet.water = 0 if currPet.water < 0 else 100 if currPet.water > 100 else currPet.water currPet.sleep = 0 if currPet.sleep < 0 else 100 if currPet.sleep > 100 else currPet.sleep currPet.stress = 0 if currPet.stress < 0 else 100 if currPet.stress > 100 else currPet.stress if currGameState == Screen.STARTING: titleBG.animate(screen) title = titleFont.render('JikoAi', True, WHITE) screen.blit(title, (WIDTH / 4 - 15, HEIGHT / 2 - 125)) subtitle = textFont.render('Click to begin!', True, WHITE) screen.blit(subtitle, (WIDTH / 4 + 25, HEIGHT / 2 + 32)) elif currGameState == Screen.SELECTION: titleBG.animate(screen) newGameButton.draw() continueGameButton.draw() elif currGameState == Screen.HOME: homeBG.animate(screen) innerFoodBar = pg.Rect(40, 40, 200, 25) innerWaterBar = pg.Rect(40, 80, 200, 25) innerSleepBar = pg.Rect(40, 120, 200, 25) innerStressBar = pg.Rect(40, 160, 200, 25) currPet.drawStatBar(screen, innerFoodBar, ORANGE, currPet.food) currPet.drawStatBar(screen, innerWaterBar, BLUE, currPet.water) currPet.drawStatBar(screen, innerSleepBar, PURPLE, currPet.sleep) currPet.drawStatBar(screen, innerStressBar, RED, currPet.stress) currPet.draw(screen) HomeFoodButton.draw() HomeFoodButton.draw_text("food") HomeWaterButton.draw() HomeWaterButton.draw_text("water") HomeSleepButton.draw() HomeSleepButton.draw_text("sleep") HomeStressButton.draw() HomeStressButton.draw_text("play") exitButton.draw() exitButton.draw_text("EXIT") elif currGameState == Screen.EGG: print("FILLER") elif currGameState == Screen.HATCH: homeBG.animate(screen) hatchedSubtitle = RectButton(150, 50, 500, 50, screen, BLACK, 128) hatchedSubtitle.draw() hatchedSubtitle.draw_text("Here's your new pet!") underSubtitle = RectButton(150, 350, 500, 50, screen, BLACK, 128) underSubtitle.draw() underSubtitle.draw_text("Click anywhere to continue.") if petSum <= 6: eggHatchedBala.animate(screen) currPet = Pet.init_gifImage(PetType.BALAGIF, "bala") elif petSum <= 9: eggHatchedMamau.animate(screen) currPet = Pet.init_gifImage(PetType.MAMAUGIF, "mamau") else: eggHatchedTora.animate(screen) currPet = Pet.init_gifImage(PetType.TORAGIF, "tora") savefile.write(str(currPet.petType.value) + "\n") currGameState = Screen.HOME currPet.setCoords(WIDTH / 2, HEIGHT / 2) elif currGameState == Screen.Q_A: homeBG.animate(screen) eggUnhatched.animate(screen) bgRect = pg.Surface((600, 75)) bgRect.set_alpha(100) bgRect.fill(BLACK) screen.blit(bgRect, (WIDTH / 4 - 80, HEIGHT / 2 + 70)) eggSubtitle = textFont.render('Who will your pet be?', True, WHITE) screen.blit(eggSubtitle, (WIDTH / 4 - 30, HEIGHT / 2 + 77)) elif currGameState == Screen.Q_A1: qaBG.animate(screen) bgRect = pg.Surface((600, 75)) bgRect.set_alpha(100) bgRect.fill(BLACK) screen.blit(bgRect, (WIDTH / 4 - 90, HEIGHT / 2 - 160)) qTitle = textFont.render('Some questions first!', True, WHITE) screen.blit(qTitle, (WIDTH / 4 - 30, HEIGHT / 2 - 157)) q1Text = textFont.render('Do you often feel stressed?', True, WHITE) bgRect1 = pg.Surface((700, 75)) bgRect1.set_alpha(100) bgRect1.fill(BLACK) screen.blit(bgRect1, (WIDTH / 4 - 145, HEIGHT / 2 - 35)) screen.blit(q1Text, (WIDTH / 4 - 110, HEIGHT / 2 - 30)) bgRect2 = pg.Surface((215, 50)) bgRect2.set_alpha(100) bgRect2.fill(BLACK) qa1LeftButton.draw() qa1LeftButton.draw_text("Not often") qa1MiddleButton.draw() qa1MiddleButton.draw_text("Sometimes") qa1RightButton.draw() qa1RightButton.draw_text("Often") elif currGameState == Screen.Q_A2: qaBG.animate(screen) bgRect = pg.Surface((600, 75)) bgRect.set_alpha(100) bgRect.fill(BLACK) screen.blit(bgRect, (WIDTH / 4 - 90, HEIGHT / 2 - 160)) qTitle = textFont.render('Some questions first!', True, WHITE) screen.blit(qTitle, (WIDTH / 4 - 30, HEIGHT / 2 - 157)) q1Text = textFont.render('I feel good about myself.', True, WHITE) bgRect1 = pg.Surface((700, 75)) bgRect1.set_alpha(100) bgRect1.fill(BLACK) screen.blit(bgRect1, (WIDTH / 4 - 145, HEIGHT / 2 - 35)) screen.blit(q1Text, (WIDTH / 4 - 110, HEIGHT / 2 - 30)) bgRect2 = pg.Surface((215, 50)) bgRect2.set_alpha(100) bgRect2.fill(BLACK) qa2LeftButton.draw() qa2LeftButton.draw_text("Disagree") qa2MiddleButton.draw() qa2MiddleButton.draw_text("Not sure") qa2RightButton.draw() qa2RightButton.draw_text("Agree") elif currGameState == Screen.Q_A3: qaBG.animate(screen) bgRect = pg.Surface((600, 75)) bgRect.set_alpha(100) bgRect.fill(BLACK) screen.blit(bgRect, (WIDTH / 4 - 90, HEIGHT / 2 - 160)) qTitle = textFont.render('Some questions first!', True, WHITE) screen.blit(qTitle, (WIDTH / 4 - 30, HEIGHT / 2 - 157)) q1Text = textFont.render('I have things under control.', True, WHITE) bgRect1 = pg.Surface((700, 75)) bgRect1.set_alpha(100) bgRect1.fill(BLACK) screen.blit(bgRect1, (WIDTH / 4 - 145, HEIGHT / 2 - 35)) screen.blit(q1Text, (WIDTH / 4 - 110, HEIGHT / 2 - 30)) bgRect2 = pg.Surface((215, 50)) bgRect2.set_alpha(100) bgRect2.fill(BLACK) qa3LeftButton.draw() qa3LeftButton.draw_text("Disagree") qa3MiddleButton.draw() qa3MiddleButton.draw_text("Not sure") qa3RightButton.draw() qa3RightButton.draw_text("Agree") elif currGameState == Screen.Q_A4: qaBG.animate(screen) bgRect = pg.Surface((600, 75)) bgRect.set_alpha(100) bgRect.fill(BLACK) screen.blit(bgRect, (WIDTH / 4 - 90, HEIGHT / 2 - 160)) qTitle = textFont.render('Some questions first!', True, WHITE) screen.blit(qTitle, (WIDTH / 4 - 30, HEIGHT / 2 - 157)) q1Text = textFont.render('I take good care of myself.', True, WHITE) bgRect1 = pg.Surface((700, 75)) bgRect1.set_alpha(100) bgRect1.fill(BLACK) screen.blit(bgRect1, (WIDTH / 4 - 145, HEIGHT / 2 - 35)) screen.blit(q1Text, (WIDTH / 4 - 110, HEIGHT / 2 - 30)) bgRect2 = pg.Surface((215, 50)) bgRect2.set_alpha(100) bgRect2.fill(BLACK) qa4LeftButton.draw() qa4LeftButton.draw_text("Disagree") qa4MiddleButton.draw() qa4MiddleButton.draw_text("Not sure") qa4RightButton.draw() qa4RightButton.draw_text("Agree") elif currGameState == Screen.WATER: waterBG.animate(screen) backButton.draw() backButton.draw_text("Back") checkin_button.draw() checkin_button.draw_text("CHECK IN") water_question_button.draw() water_question_button.draw_text( "Have you drank anything recently?") elif currGameState == Screen.WATER_ACTIVE: waterBG.animate(screen) backButton.draw() backButton.draw_text("Back") water_response_button.draw() water_response_button.draw_text( "Thank you for keeping us both healthy!") if water_exists1: water_drop1.draw() if water_exists2: water_drop2.draw() currPet.draw(screen) elif currGameState == Screen.FUN: playBG.animate(screen) backButton.draw() backButton.draw_text("Back") elif currGameState == Screen.SLEEP: sleepBG.animate(screen) # affirmations sleepAffirmationsButton.draw() sleepAffirmationsButton.draw_text("Affirmations") # meditate sleepMeditateButton.draw() sleepMeditateButton.draw_text("Meditation") # sleep sleepLogButton.draw() sleepLogButton.draw_text("Log Sleep") # back backButton.draw() backButton.draw_text("Back") # currPet.draw(screen) elif currGameState == Screen.SHOWER: showerBG.animate(screen) shower_response_button.draw() shower_response_button.draw_text("SHOWER") if currPet.petType == "PetType.BALA" or currPet.petType == "PetType.BALAGIF": showerBala.animate(screen) elif currPet.petType == "PetType.MAMAU" or currPet.petType == "PetType.MAMAUGIF": showerMamau.animate(screen) elif currPet.petType == "PetType.TORA" or currPet.petType == "PetType.TORAGIF": showerTora.animate(screen) backButton.draw() backButton.draw_text("Back") elif currGameState == Screen.SHOWER_TWO: showerBG.animate(screen) if currPet.petType == "PetType.BALA" or currPet.petType == "PetType.BALAGIF": showerBala.animate(screen) elif currPet.petType == "PetType.MAMAU" or currPet.petType == "PetType.MAMAUGIF": showerMamau.animate(screen) elif currPet.petType == "PetType.TORA" or currPet.petType == "PetType.TORAGIF": showerTora.animate(screen) backButton.draw() backButton.draw_text("Back") elif currGameState == Screen.SHOWER_DONE: showerBG.animate(screen) shower_text_button.draw() shower_text_button.draw_text("Thank you for taking care of me!") if currPet.petType == "PetType.BALA" or currPet.petType == "PetType.BALAGIF": showerDoneBala.animate(screen) elif currPet.petType == "PetType.MAMAU" or currPet.petType == "PetType.MAMAUGIF": showerDoneMamau.animate(screen) elif currPet.petType == "PetType.TORA" or currPet.petType == "PetType.TORAGIF": showerDoneTora.animate(screen) backButton.draw() backButton.draw_text("Back") elif currGameState == Screen.FOOD: foodBG.animate(screen) #drawing food images screen.blit(pg.transform.scale(pizza, (100, 100)), (pizza_x, pizza_y)) screen.blit(pg.transform.scale(fruitTart, (100, 100)), (fruitTart_x, fruitTart_y)) screen.blit(pg.transform.scale(rice, (100, 100)), (rice_x, rice_y)) screen.blit(pg.transform.scale(edamame, (100, 100)), (edamame_x, edamame_y)) #drawing the text foodText = textFont.render('Did you eat well today?', True, WHITE) foodRect = pg.Surface((550, 75)) foodRect.set_alpha(100) foodRect.fill(BLACK) screen.blit(foodRect, (150, HEIGHT - 400)) screen.blit(foodText, (150, HEIGHT - 400)) #drawing the character currPet.draw(screen) #other buttons and stuff backButton.draw() backButton.draw_text("Back") elif currGameState == Screen.MEDITATION: sleepBG.animate(screen) backButton.draw() backButton.draw_text("Back") meditate.setOn() elif currGameState == Screen.AFFIRMATIONS: sleepBG.animate(screen) backButton.draw() backButton.draw_text("Back") affirmations.run() elif currGameState == Screen.LOGSLEEP: sleepBG.animate(screen) backButton.draw() backButton.draw_text("Back") sleep_checkin_button.draw() sleep_checkin_button.draw_text("CHECK IN") sleep_question_button.draw() sleep_question_button.draw_text("Have you slept recently?") elif currGameState == Screen.LOGSLEEP_ACTIVE: sleepBG.animate(screen) backButton.draw() backButton.draw_text("Back") sleep_response_button.draw() sleep_response_button.draw_text( "Thank you for keeping us both healthy!") currPet.draw(screen) # meditate.setOn() pg.display.update() clock.tick(FRAMERATE) for event in ev: if event.type == pg.QUIT: pg.quit() sys.exit() if event.type == pg.MOUSEBUTTONUP and event.button == 1: is_draggable = False on_pizza = False on_edamame = False on_fruitTart = False on_rice = False if event.type == pg.MOUSEMOTION: if is_draggable: m_x, m_y = event.pos #test for each image: if on_pizza: pizza_x = m_x + offset_x pizza_y = m_y + offset_y elif on_edamame: edamame_x = m_x + offset_x edamame_y = m_y + offset_y elif on_fruitTart: fruitTart_x = m_x + offset_x fruitTart_y = m_y + offset_y elif on_rice: rice_x = m_x + offset_x rice_y = m_y + offset_y if event.type == pg.MOUSEBUTTONDOWN and event.button == 1: if currGameState == Screen.Q_A: currGameState = Screen.Q_A1 if currGameState.value > Screen.HATCH.value: savefile.close() update_save() savefile = open(os.getcwd() + "/save/saveFile.txt", 'a+') mouse = pg.mouse.get_pos() if currGameState == Screen.STARTING: currGameState = Screen.SELECTION elif newGameButton.getImageRect().collidepoint( mouse) and currGameState == Screen.SELECTION: open(os.getcwd() + "/save/saveFile.txt", 'w').close() currGameState = Screen.Q_A elif continueGameButton.getImageRect().collidepoint( mouse) and currGameState == Screen.SELECTION: lines = open(os.getcwd() + "/save/saveFile.txt", "r").read().splitlines() if len(lines) > 5: savePetType = lines[0] if savePetType.__contains__("GIF"): currPet = Pet.init_gifImage(lines[0], lines[1]) else: currPet = Pet(lines[0], lines[1]) currPet.food = float(lines[2]) currPet.water = float(lines[3]) currPet.sleep = float(lines[4]) currPet.stress = float(lines[5]) dtimeT = (init_time - datetime.datetime.strptime( lines[6], "%Y-%B-%d %I:%M:%S.%f")) dtime = dtimeT.seconds currPet.food += FOOD_CHANGE_RATE * dtime * FRAMERATE currPet.water += WATER_CHANGE_RATE * dtime * FRAMERATE currPet.sleep += SLEEP_CHANGE_RATE * dtime * FRAMERATE currPet.stress += STRESS_CHANGE_RATE * dtime * FRAMERATE currGameState = Screen.HOME currPet.setCoords(WIDTH / 2, HEIGHT / 2) else: print("Save game not found") open(os.getcwd() + "/save/saveFile.txt", 'w').close() currGameState = Screen.Q_A elif qa1LeftButton.getImageRect().collidepoint( mouse) and currGameState == Screen.Q_A1: petSum += 1 currGameState = Screen.Q_A2 elif qa1MiddleButton.getImageRect().collidepoint( mouse) and currGameState == Screen.Q_A1: petSum += 2 currGameState = Screen.Q_A2 elif qa1RightButton.getImageRect().collidepoint( mouse) and currGameState == Screen.Q_A1: petSum += 3 currGameState = Screen.Q_A2 elif qa2LeftButton.getImageRect().collidepoint( mouse) and currGameState == Screen.Q_A2: petSum += 1 currGameState = Screen.Q_A3 elif qa2MiddleButton.getImageRect().collidepoint( mouse) and currGameState == Screen.Q_A2: petSum += 2 currGameState = Screen.Q_A3 elif qa2RightButton.getImageRect().collidepoint( mouse) and currGameState == Screen.Q_A2: petSum += 3 currGameState = Screen.Q_A3 elif qa3LeftButton.getImageRect().collidepoint( mouse) and currGameState == Screen.Q_A3: petSum += 1 currGameState = Screen.Q_A4 elif qa3MiddleButton.getImageRect().collidepoint( mouse) and currGameState == Screen.Q_A3: petSum += 2 currGameState = Screen.Q_A4 elif qa3RightButton.getImageRect().collidepoint( mouse) and currGameState == Screen.Q_A3: petSum += 3 currGameState = Screen.Q_A4 elif qa4LeftButton.getImageRect().collidepoint( mouse) and currGameState == Screen.Q_A4: petSum += 1 currGameState = Screen.HATCH elif qa4MiddleButton.getImageRect().collidepoint( mouse) and currGameState == Screen.Q_A4: petSum += 2 currGameState = Screen.HATCH elif qa4RightButton.getImageRect().collidepoint( mouse) and currGameState == Screen.Q_A4: petSum += 3 currGameState = Screen.HATCH elif currGameState == Screen.HATCH: currGameState = Screen.HOME currPet.setCoords(WIDTH / 2, HEIGHT / 2) elif backButton.getImageRect().collidepoint(mouse) and ( currGameState is Screen.FOOD or currGameState is Screen.WATER or currGameState is Screen.WATER_ACTIVE or currGameState is Screen.SLEEP or currGameState is Screen.FUN): currGameState = Screen.HOME currPet.setCoords(WIDTH / 2, HEIGHT / 2) elif sleepMeditateButton.getImageRect().collidepoint( mouse) and currGameState == Screen.SLEEP: currGameState = Screen.MEDITATION elif sleepAffirmationsButton.getImageRect().collidepoint( mouse) and currGameState == Screen.SLEEP: currGameState = Screen.AFFIRMATIONS elif sleepLogButton.getImageRect().collidepoint( mouse) and currGameState == Screen.SLEEP: currGameState = Screen.LOGSLEEP elif backButton.getImageRect().collidepoint(mouse) and ( currGameState is Screen.FOOD or currGameState is Screen.WATER or currGameState is Screen.SLEEP or currGameState is Screen.FUN or currGameState is Screen.SHOWER or currGameState is Screen.SHOWER_TWO or currGameState is Screen.SHOWER_DONE): currGameState = Screen.HOME elif backButton.getImageRect().collidepoint(mouse) and ( currGameState is Screen.MEDITATION or currGameState is Screen.AFFIRMATIONS or currGameState is Screen.LOGSLEEP or currGameState is Screen.LOGSLEEP_ACTIVE): currPet.sleep = currPet.sleep + 20 currGameState = Screen.SLEEP elif sleep_checkin_button.getImageRect().collidepoint( mouse) and currGameState == Screen.LOGSLEEP: currGameState = Screen.LOGSLEEP_ACTIVE elif currGameState == Screen.HOME: if HomeFoodButton.getImageRect().collidepoint(mouse): currGameState = Screen.FOOD elif HomeWaterButton.getImageRect().collidepoint(mouse): currGameState = Screen.WATER elif HomeSleepButton.getImageRect().collidepoint(mouse): currGameState = Screen.SLEEP elif HomeStressButton.getImageRect().collidepoint(mouse): currGameState = Screen.SHOWER elif exitButton.getImageRect().collidepoint(mouse): update_save() pg.quit() if sys.platform.startswith('linux'): os.system("sudo shutdown -h now") sys.exit() elif currGameState == Screen.WATER: if checkin_button.getImageRect().collidepoint(mouse): water_drop1.getImageRect().center = (random.randint( 100, WIDTH - 100), random.randint(100, HEIGHT - 100)) water_drop2.getImageRect().center = (random.randint( 100, WIDTH - 100), random.randint(100, HEIGHT - 100)) currGameState = Screen.WATER_ACTIVE currPet.setCoords(WIDTH / 2, HEIGHT / 2) water_exists1 = True water_exists2 = True elif currGameState is Screen.WATER_ACTIVE: if water_drop1.getImageRect().collidepoint( mouse) and water_exists1: currPet.water += 12 if currPet.water > 100: currPet.water = 100 water_exists1 = False elif water_drop2.getImageRect().collidepoint( mouse) and water_exists2: currPet.water += 12 if currPet.water > 100: currPet.water = 100 water_exists2 = False elif currGameState == Screen.SHOWER: if shower_response_button.getImageRect().collidepoint( mouse): currGameState = Screen.SHOWER_TWO elif currGameState == Screen.SHOWER_TWO: currPet.stress -= 25 if currPet.stress < 0: currPet.stress = 0 currGameState = Screen.SHOWER_DONE elif currGameState == Screen.FOOD: #we have currPet: and pizza, edamame, rice, fruitTart if pizza.get_rect().collidepoint(mouse): is_draggable = True on_edamame = False on_fruitTart = False on_rice = False on_pizza = True m_x, m_y = event.pos offset_x = pizza.get_rect().x - m_x offset_y = pizza.get_rect().y - m_y elif edamame.get_rect().collidepoint(mouse): is_draggable = True on_edamame = True on_fruitTart = False on_rice = False on_pizza = False m_x, m_y = event.pos offset_x = edamame.get_rect().x - m_x offset_y = edamame.get_rect().y - m_y elif rice.get_rect().collidepoint(mouse): is_draggable = True on_edamame = False on_fruitTart = False on_rice = True on_pizza = False m_x, m_y = event.pos offset_x = rice.get_rect().x - m_x offset_y = rice.get_rect().y - m_y elif fruitTart.get_rect().collidepoint(mouse): is_draggable = True on_edamame = False on_fruitTart = True on_rice = False on_pizza = False m_x, m_y = event.pos offset_x = fruitTart.get_rect().x - m_x offset_y = fruitTart.get_rect().y - m_y
# Settings os.chdir(APP_FOLDER) pygame.display.set_caption(GAME_NAME) icon = pygame.image.load(ICON) pygame.display.set_icon(icon) # Game if __name__ == '__main__': pygame.init() screen = pygame.display.set_mode(SCREEN_RESOLUTION) screen.fill(name_to_rgb('gray')) step = 5 position = {"x": 60, "y": 60} dimension = {'height': 30, 'width': 50} GAME_DONE = False mouse_image = GIFImage("MouseSprite.gif") while not GAME_DONE: pygame.time.delay(25) for event in pygame.event.get(): if event.type == pygame.QUIT: GAME_DONE = True keys = pygame.key.get_pressed() if keys[pygame.K_LEFT] and position["x"] >= 0: position["x"] -= step if keys[pygame.K_RIGHT] and position["x"] <= SCREEN_RESOLUTION[0]: position["x"] += step if keys[pygame.K_UP] and position["y"] >= 0: position["y"] -= step if keys[pygame.K_DOWN] and position["y"] <= SCREEN_RESOLUTION[1]: position["y"] += step
# X, Y = pygame.display.Info().current_w, pygame.display.Info().current_h print (pygame.display.Info().current_w, pygame.display.Info().current_h) screen = pygame.display.set_mode((X, Y))#, pygame.FULLSCREEN) pygame.display.set_caption('TIMER') fontSize = int(X//3.2) # fontName = 'digital-7' fontName = 'laser' # josefin, laser, mazzard, neon, nidus sans, one day, ostrich sans, rajdhani, sulivan, swgdt, tw cent mt, font = pygame.font.SysFont(fontName, fontSize) # BACKGROUND SCREEN screen1 = pygame.Surface((X, Y)) screen1.set_alpha(225) # hud1 = GIFImage(os.path.dirname(os.path.abspath(__file__)) + "/" + "images/hud1-1120x702.gif") hud1 = GIFImage(os.path.dirname(os.path.abspath(__file__)) + "/" + "images/network2-432x768.gif") # hud1 = GIFImage(os.path.dirname(os.path.abspath(__file__)) + "/" + "images/network2-768x1366.gif") # WINNER STICKER winner = pygame.image.load(os.path.dirname(os.path.abspath(__file__)) + "/" + "images/winner.png") winner = pygame.transform.rotozoom(winner, 0, 0.5) # TIMER VARIABLES totalTime = 540 #in seconds startTime = datetime.datetime.now() pauseTime = datetime.datetime.now() totalPause = 0 laserPenalty = 10 laserWallPenalty = 30 laserCuts = 0 laserWallCuts = 0 totalLasers = 90
def main(): global normal_playing global desk_playing global objection_playing print 'Press button 1 + 2 on your Wii Remote...' time.sleep(1) wm = cwiid.Wiimote() print 'Wii Remote connected...' print '\nPress the PLUS button to disconnect the Wii and end the application' time.sleep(1) Rumble = False wm.rpt_mode = cwiid.RPT_BTN | cwiid.RPT_ACC wm.led = 1 pygame.init() size = width, height = 800, 500 screen = pygame.display.set_mode(size) pygame.display.set_caption("testing") myfont = pygame.font.SysFont("monospace", 16) WHITE = (255, 255, 255) GREEN = (0, 140, 50) clock = pygame.time.Clock() deskslam = GIFImage("img/deskslam.gif") objection = GIFImage("img/objection.gif") normal = GIFImage("img/normal.gif") objection_playing = False desk_playing = False normal_playing = True score = 0 while True: pygame.display.flip() for event in pygame.event.get(): if event.type == pygame.QUIT: sys.exit() screen.fill(WHITE) if (objection_playing): objection.render(screen, (0, 0), True, reset) if (desk_playing): deskslam.render(screen, (0, 0), True, reset) if (normal_playing): normal.render(screen, (0, 0)) Xaxis = "X: " + str(wm.state['acc'][0]) Yaxis = "Y: " + str(wm.state['acc'][1]) Zaxis = "Z: " + str(wm.state['acc'][2]) wiimotetext = myfont.render(Xaxis + " " + Yaxis + " " + Zaxis, 1, GREEN) screen.blit(wiimotetext, (300, 5)) if wm.state['acc'][2] <= 40: print "SLAM " + Xaxis + " " + Yaxis + " " + Zaxis desk_playing = True objection_playing = False normal_playing = False deskslam.rewind() pygame.mixer.music.load('sound/sfx-deskslam.wav') pygame.mixer.music.play() if wm.state['acc'][1] <= 50: print "OBJECTION! " + Xaxis + " " + Yaxis + " " + Zaxis objection_playing = True desk_playing = False normal_playing = False objection.rewind() pygame.mixer.music.load('sound/objection.mp3') pygame.mixer.music.play() if wm.state['buttons'] == 512: position = 50 print 'Position: ', position while wm.state['buttons'] == 8: print(wm.state) if wm.state['buttons'] == 2: print 'Button 1 pressed' if wm.state['buttons'] == 1: print 'Button 2 pressed' if wm.state['buttons'] == 16: if Rumble == False: wm.rumble = True Rumble = True elif Rumble == True: wm.rumble = False Rumble = False if wm.state['buttons'] == 4096: print 'closing Bluetooth connection. Good Bye!' time.sleep(1) exit(wm) clock.tick(60)
try: image = pygame.image.load(fullname) except pygame.error as message: print('Cannot load image:', name) raise SystemExit(message) image = image.convert_alpha() if colorkey is not None: if colorkey == -1: colorkey = image.get_at((0, 0)) image.set_colorkey(colorkey) return image raw_logo = load_image(os.path.join('images', settings['textures']['logo'])) tron_gif = GIFImage('data/images/tron-ssh-animated.gif') tron_gif.pause() pygame.display.quit() LOGO_IMAGE = pygame.transform.scale( raw_logo, (raw_logo.get_width() * 3, raw_logo.get_height() * 3)) all_boards = [] music = pygame.mixer.music join = os.path.join BG = pygame.Surface(tron_gif.get_size()) tron_gif.render(BG, (0, 0)) # MODELS models = { "players":
import pygame from pygame.locals import * from GIFImage import GIFImage import sys pygame.init() screen = pygame.display.set_mode((640, 480)) shittingdog = GIFImage('supergif.gif') while True: screen.fill((0,0,0)) shittingdog.render(screen, (0,0)) pygame.display.update()
class Pet(): petType = -1 name = "" food = 100 water = 100 sleep = 100 stress = 0 picture = os.getcwd() + "/graphicAssets/SpriteBala.png" isImage = True def __init__(self, petType, name, isImage, moveCycleLen=30): WHITE = (255, 255, 255) picture = os.getcwd() + "/graphicAssets/SpriteBala.png" self.petType = petType self.name = name self.isImage = isImage self.moveCycleLen = moveCycleLen self.frameCycleCount = 1 self.currX = 0 self.currY = 0 if (str(petType) == str(PetType.BALA)): picture = os.getcwd() + "/graphicAssets/SpriteBala.png" elif (str(petType) == str(PetType.MAMAU)): picture = os.getcwd() + "/graphicAssets/SpriteMamau.png" elif (str(petType) == str(PetType.TORA)): picture = os.getcwd() + "/graphicAssets/SpriteTora.png" elif (str(petType) == str(PetType.BALAGIF)): picture = os.getcwd() + "/graphicAssets/SpriteBalaGif" elif (str(petType) == str(PetType.MAMAUGIF)): picture = os.getcwd() + "/graphicAssets/SpriteMamauGif" elif (str(petType) == str(PetType.TORAGIF)): picture = os.getcwd() + "/graphicAssets/SpriteToraGif" if (self.isImage): self.image = pg.image.load(picture) self.image.set_colorkey(WHITE) self.image = pg.transform.smoothscale(self.image, (105, 135)) else: self.image = GIFImage(picture, 0, 0, PETFRAMECYCLE) self.image.resize(105, 135) @classmethod def init_image(cls, petType, name): return cls(petType, name, True) @classmethod def init_gifImage(cls, petType, name): return cls(petType, name, False) def resize(self, width, height): if (self.isImage): self.image = pg.transform.scale(self.image, (width, height)) else: self.image.resize(width, height) def setCoords(self, x, y): self.currX = x - self.image.get_width() / 2 self.currY = y - self.image.get_width() / 2 def setMoveCycleCount(self, count): self.moveCycleLen = count def draw(self, screen): if (self.isImage): screen.blit(self.image, (self.currX, self.currY)) pg.display.flip() else: self.image.setCoords(self.currX, self.currY) self.image.animate(screen) if (self.frameCycleCount >= self.moveCycleLen): randomx = randint(-40, 40) randomy = randint(-40, 40) if (self.currX + randomx >= WIDTH - 80 or self.currY + randomy >= HEIGHT - 120 or self.currX + randomx <= 50 or self.currY + randomy <= 50): randomx = randint(-40, 40) randomy = randint(-40, 40) self.currX = self.currX + randomx self.currY = self.currY + randomy self.frameCycleCount = 0 self.frameCycleCount = self.frameCycleCount + 1 def drawWithBorder(self, screen, innerRect, color): borderRect = pg.Rect(innerRect.left, innerRect.top, innerRect.width + 10, innerRect.height + 10) borderRect.center = innerRect.center pg.draw.rect(screen, BLACK, borderRect) pg.draw.rect(screen, color, innerRect) def drawStatBar(self, screen, rect, color, val): self.drawWithBorder(screen, rect, WHITE) pg.draw.rect( screen, color, pg.Rect(rect.left, rect.top, rect.width * (val / 100), rect.height))
class Asriel(): def __init__(self): self.image_asriel = GIFImage("gif/test3.gif") self.pos = self.image_asriel.get_rect() self.asrielx = 270 self.pos = self.pos.move(self.asrielx, 10) self.maxlife = 1000 self.life = self.maxlife self.timerC = 0 self.dg = randint(0, 1) #mouvement du boss def mouvasriel(self): self.timerC += 1 if self.dg == 1: if self.timerC > 200 and self.timerC < 500: self.pos = self.pos.move(1, 0) self.asrielx = self.asrielx + 1 if self.timerC > 600 and self.timerC < 900: self.pos = self.pos.move(-1, 0) self.asrielx = self.asrielx - 1 if self.dg == 0: if self.timerC > 200 and self.timerC < 500: self.pos = self.pos.move(-1, 0) self.asrielx = self.asrielx - 1 if self.timerC > 600 and self.timerC < 900: self.pos = self.pos.move(1, 0) self.asrielx = self.asrielx + 1 if self.timerC == 1100: self.dg = randint(0, 1) self.timerC = 200 return self.pos #tir aléatoire du boss def tirprincipale(self, bosstirl, asriel): x = randint(-3, 3) y = randint(1, 3) xx = False yy = False if self.timerC % 5 == 1: bosstirl.append(couloirtir(x, y, xx, yy, asriel)) ############################################################à finir def tirsecondaire(self, bosstirl, asriel, hx, hy): if self.timerC > 0: x = 0 y = 4 xx = 0 yy = 4 if self.timerC >= 200 and self.timerC < 450: x = 1 y = 4 xx = 1 yy = 4 if self.timerC >= 450 and self.timerC < 700: x = 0 y = 4 xx = 0 yy = 4 if self.timerC >= 700 and self.timerC < 950: x = -1 y = 4 xx = -1 yy = 4 if self.timerC >= 950 and self.timerC < 1200: x = 0 y = 4 xx = 0 yy = 4 ## x=0 ## y=4 ## xx=0 ## yy=4 if self.timerC % 10 == 1: bosstirl.append(couloirtir(x, y, xx, yy, asriel))
gameDisplay = pygame.display.set_mode((DISPLAY_WIDTH, DISPLAY_HEIGHT)) pygame.display.set_caption('Space Cowboy') # start clock, we will use this to count frames(fps) clock = pygame.time.Clock() # load our car image(player) jetImg = pygame.image.load('img/red_jetfighter.png') # car image width. we will use it to calculate collisions with other objects car_width = 35 thicQueenImg = pygame.image.load('img/thic_queen.jpg').convert() thicQueenImg.set_alpha(0) galaxyImg = pygame.image.load('img/galaxy.png') pygame.display.set_icon(jetImg) gifImgToMe = GIFImage("img/to_me.gif") #gifImgFoundLove = GIFImage("img/found_lil_love.gif") # gif_grid = [] # for num in range(9): # gif_grid.append(gifImgToMe.copy()) # gif_grid[num].scale(-0.334) # create star falling object stars_list = [] stars_list.append( Stars(100, 1, DISPLAY_WIDTH, DISPLAY_HEIGHT, white, 1, gameDisplay)) stars_list.append( Stars(30, 2, DISPLAY_WIDTH, DISPLAY_HEIGHT, white, 2, gameDisplay)) stars_list.append( Stars(10, 3, DISPLAY_WIDTH, DISPLAY_HEIGHT, white, 2, gameDisplay))