Give me feedback

Python Trouble

So I have a program called Turtle Trouble, and a turtle (who follows the mouse) has to eat all the fish on the screen. However, there is a time limit, and the fish disappear 6 seconds after they go on. I have no idea why it just opens then closes when I run the program.

TurtleTrouble.py
/** import random import sys import time from pygame import * import pygame pygame.init() #------Easy-Change Variables mouse_visibility = False turtlespeed = 4 #------Font font = pygame.font.SysFont("C:/Python34/TurtleFont.ttf", 48) #------Theme Music & Sound Effects pygame.mixer.music.load('C:/Python34/Jumpshot.mp3') pygame.mixer.music.play(1, 0.0) chomp = pygame.mixer.Sound("C:/Python34/chomp.wav") #------BG, Screen & Caption pygame.display.set_caption('Turtle Trouble!') screen = pygame.display.set_mode((1024, 616)) bg_img = pygame.image.load("C:/Python34/icebackground.png") screen.blit(bg_img,(0,0)) pygame.display.flip() #------Image Preparation turtle = pygame.image.load("C:/Python34/turtle.png") fish = pygame.image.load("C:/Python34/fish.png") endgame_turtle = pygame.image.load("C:/Python34/endgame_turtle.png" ) #------Movement, Coords, Collisions & Fish turtlepos = pygame.mouse.get_pos() pygame.mouse.set_visible(mouse_visibility) turtle_rect = turtle.get_rect() fish_rect = fish.get_rect() points = 0 fish_pos_list = [] if pygame.mouse.get_pressed()[1] == True: game_time = time.time() while 1 == 1: elapsed_time = time.time() - game_time mousepos = pygame.mouse.get_pos() if elapsed_time >= 45: screen.blit(endgame_turtle,(150, 0)) pygame.display.flip() time.sleep(2.5) sys.exit() text = font.render("Points: %s" % points, True, (0, 128, 0)) screen.blit(text, (0, 0)) new_fish = random.randint(0, 6) fish_x = random.randint(0, 943) fish_y = random.randint(0, 552) if mousepos[1] - turtlepos[1] < 0: turtlepos[1] -= turtlespeed else: turtlepos[1] += turtlespeed if mousepos[2] - turtlepos[2] < 0: turtlepos[2] -= turtlespeed else: turtlepos[2] += turtlespeed screen.blit(turtle_rect,(turtlepos[1],turtlepos[2])) pygame.display.flip() if new_fish == 0: screen.blit(fish_rect,(fish_x, fish_y)) start_time = time.time() positions = {'x':fish_x, 'y':fish_y, 'fishtimer':start_time} fish_pos_list.append(positions) for position in fish_pos_list: if position['fishtimer'] >= 6: screen.blit(bg_img, (position['x'], position['y']), pygame.Rect(position['x'], position['y'], 81, 62)) del fish_pos_list[0] else: break next for position in fish_pos_list: if turtle_rect.colliderect(fish_rect): screen.blit(bg_img, (position['x'], position['y']), pygame.Rect(position['x'], position['y'], 81, 62)) chomp.play() fish_pos_list.remove(position) points += 1 pygame.display.update() mainClock.tick(40) */

Reactions 0 reactions

No reactions yet, be the first: comment or tweak the code

Comment on this code:

Please Login or Register to leave a comment.