def show_pts_on_screen(mouse_x, mouse_y): score_font = pygame.font.Font('duckHuntFont.TTF', 24) score_num = score_font.render('1500', True, (255, 255, 255)) # cant display + sign text_x = mouse_x + 30 text_y = mouse_y - 20 screen.blit(score_num, (text_x, text_y))
def set_cursor_image(): cursor = pygame.image.load('crosshair.png') cursor = pygame.transform.scale(cursor, (100, 98)) # set the image size screen.blit(cursor, get_cursor_pos()) # make mouse invisible pygame.mouse.set_cursor((8, 8), (0, 0), (0, 0, 0, 0, 0, 0, 0, 0), (0, 0, 0, 0, 0, 0, 0, 0))
def game_over_text(): if d.strike == 3: gg = pygame.font.Font('duckHuntFont.TTF', 72).render("GAME OVER", True, (0, 0, 0)) gg_rect = gg.get_rect( center=(width / 2, height / 2)) # center the text in the middle of screen screen.blit(gg, gg_rect)
def drawTurtle(self): if self.speed < self.maxSpeed: self.speed += self.acceleration self.y += self.speed if self.speed > 0: self.speed += self.acceleration screen.blit(turtleImage, (self.x, self.y))
def player_melee(p): global swing_cooldown global frame_count global player_swing if swing_cooldown <= 0: # at 0 turn off swing animation and reset cooldown player_swing = False swing_cooldown = 11 frame_count = 0 if swing_cooldown > 0: if player_swing: screen.blit(swing_animation[frame_count], (p.player_x + 17, p.player_y + 17)) swing_cooldown -= 1 # countdown frame_count += 1 if frame_count + 1 > 14: # 10 frames to cycle through frame_count = 0
def draw_duck(duck): if duck.is_falling: # blit falling duck at pos where duck was clicked screen.blit( fall_animation_frames[duck.fall_frame_count], ( duck.store_x - 20, # -20 to center img. because im a retard who cant crop images properly duck.store_y)) duck.fall_frame_count += 1 # cycle through the frames if duck.fall_frame_count + 1 > 8: # 8 is num of frames duck.fall_frame_count = 0 # reset back to first frame to keep the cycle goings if duck.dead: screen.blit(duck_shot, (duck.x, duck.y)) show_pts_on_screen(duck.x, duck.y) else: screen.blit(fly_animation_frames[duck.animation_frame_count], (duck.x, duck.y)) duck.animation_frame_count += 1 # cycle through the frames if duck.animation_frame_count + 1 > 12: # 12 is num of frames duck.animation_frame_count = 0 # reset back to first frame to keep the cycle goings
def ducks(x, y): screen.blit(duck_frame, (x, y))
def create_light(): # window lights screen.blit(window_light_vert, (484, 475)) screen.blit(window_light_horiz, (598, 773)) screen.blit(window_light_horiz, (1105, 773)) screen.blit(glow, (810, 685)) screen.blit(fp_floor, (840, 765)) # windows screen.blit(window_vert, (485, 485)) screen.blit(window_horiz, (1120, 850)) screen.blit(window_horiz, (610, 850))
def draw_strike(): if d.strike == 1: screen.blit(strike, (50, 980)) if d.strike == 2: screen.blit(strike, (50, 980)) screen.blit(strike, (125, 980)) if d.strike == 3: screen.blit(strike, (50, 980)) screen.blit(strike, (125, 980)) screen.blit(strike, (200, 980))
def draw_player(p): global frame_count # screen.blit(player_standing_still_right, (p.player_x, p.player_y)) if right: screen.blit(player_animation_right[frame_count], (p.player_x, p.player_y)) if left: screen.blit(player_animation_left[frame_count], (p.player_x, p.player_y)) if up: screen.blit(player_animation_up[frame_count], (p.player_x, p.player_y)) if down: screen.blit(player_animation_down[frame_count], (p.player_x, p.player_y)) if still_right: screen.blit(player_standing_still_right, (p.player_x, p.player_y)) if still_left: screen.blit(player_standing_still_left, (p.player_x, p.player_y)) if still_up: screen.blit(player_standing_still_up, (p.player_x, p.player_y)) if still_down: screen.blit(player_standing_still_down, (p.player_x, p.player_y)) frame_count += 1 if frame_count + 1 > 30: # 30 frames to cycle through frame_count = 0
def show_score(x, y): score_num = score_font.render("SCORE: " + str(score_val), True, (255, 255, 255)) screen.blit(score_num, (x, y))