Esempio n. 1
0
 def setUp(self):
     highscore.fn = 'v:\workspace\Python2_Homework04\src\scoreboard_fixture.shlf'
     self.fixture_player1 = 'Mario'
     self.fixture_score_high1 = 300
     self.fixture_score_low1 = highscore.highscore(self.fixture_player1, self.fixture_score_high1)
     self.fixture_player2 = 'Luigi'
     self.fixture_score_high2 = 100
     self.fixture_score_low2 = highscore.highscore(self.fixture_player2, self.fixture_score_high2)
Esempio n. 2
0
	def crash(self):
		global score, LIVES
		self.playing = False
		LIVES += -1
		if LIVES < 0:
			self.message_display("Game Over", black, (160, 640), 70)
			time.sleep(1)
			highscore.highscore(self.screen, file_name, score)
			score = 0
			LIVES = 3
		else:
			self.message_display("Crashed", black, (240, 640), 70)
		pygame.display.flip()
		time.sleep(1)
		self.new()
def highscores():
    # import function
    from highscore import highscore

    # save relevant data
    uuid = session["id"]
    username = session['username']
    score = session['correct']
    category = session['category']

    # set amount of questions
    if session["gamemode"] == "custom":
        amount = session["amount"]
    else:
        # classic game is 10 questions
        amount = 10

    # return highscore data
    return highscore(uuid, username, score, category, amount)
            return hitcount, fullscreen

        pygame.display.flip()

        #if timelimit <= 0:
        #    return hitcount

        if cv2.waitKey(1) & 0xFF == ord('q'):
            break
        # = time.clock()
        #if x>100:
        #s    break
    #with open("pucksizelist","wb") as f:
    #    pickle.dump(pucksizelist,f)


#cProfile.run('main()')

hitcount, screen = main()

resultscreen(hitcount, screen)

fullscreen = pygame.display.set_mode([100, 100])

highscore = highscore.highscore('highscore.txt')
highscore.check(1000)

time.sleep(10)
cap.release()
pygame.quit()
Esempio n. 5
0
 def test_existing_player_with_new_high_score(self):    
     self.fixture_score_high1 += 10
     observed = highscore.highscore(self.fixture_player1, self.fixture_score_high1)
     self.assertEquals(observed, self.fixture_score_high1)
Esempio n. 6
0
 def test_multiple_players_return_own_results(self):
     """Each play should return only it's results"""
     observed = highscore.highscore(self.fixture_player1, self.fixture_score_high1)
     self.assertAlmostEquals(observed, self.fixture_score_high1)
     observed = highscore.highscore(self.fixture_player2, self.fixture_score_high2)
     self.assertAlmostEquals(observed, self.fixture_score_high2)
Esempio n. 7
0
 def test_always_return_higest_score(self):
     for num in range(100, 400, 100):
         self.fixture_score_high1 += num 
         observed = highscore.highscore(self.fixture_player1, self.fixture_score_high1)
         self.assertEquals(observed, self.fixture_score_high1)
Esempio n. 8
0
 def test_existing_player_returns_stored_score(self):
     """when the current score is lower, the stored score should be returned"""
     self.fixture_score_low1 = self.fixture_score_high1 - 10    
     observed = highscore.highscore(self.fixture_player1, self.fixture_score_low1)
     self.assertEquals(observed, self.fixture_score_high1)
Esempio n. 9
0
 def test_new_user_returns_score(self):
     """If the user does not exist, their current score should be returned"""
     observed = highscore.highscore(self.fixture_player, self.fixture_score_high)
     self.assertEquals(observed, self.fixture_score_high)
Esempio n. 10
0
def endgame(points):
    highscore.highscore(points)
            
    soundpt.stop()
    soundlose.play()

    pygame.time.wait(500)
    
    imag=pygame.image.load("assets/images/Menubackground.png")
    imag=pygame.transform.scale(imag,(1000,700))
    display.fill(white)
    display.blit(imag,(0,0))

    pygame.draw.rect(display,(255,0,0),(280,140,440,80))

    rendering="Score: "+str(points)
    fonts1=pygame.font.SysFont("Copperplate Gothic Bold",90)
    label6=fonts1.render(rendering,True,cyan)
    display.blit(label6,(500-label6.get_width()/2,150))

    rendering="High Score: "+str(highscore.read())
    fonts2=pygame.font.SysFont("Copperplate Gothic Bold",90)
    pygame.draw.rect(display,(255,0,0),(280,290,440,80))
    label7=fonts2.render(rendering,True,cyan)
    display.blit(label7,(500-label7.get_width()/2,300))

    pygame.draw.rect(display,(255,0,0),(50,450,250,70))
    pygame.draw.rect(display,(255,0,0),(380,450,250,70))
    pygame.draw.rect(display,(255,0,0),(710,450,250,70))
    
    rendering="Menu"
    fonts1=pygame.font.SysFont("Copperplate Gothic Bold",70)
    label6=fonts1.render(rendering,True,cyan)
    display.blit(label6,(175-label6.get_width()/2,460))

    rendering="Retry"
    fonts1=pygame.font.SysFont("Copperplate Gothic Bold",70)
    label6=fonts1.render(rendering,True,cyan)
    display.blit(label6,(505-label6.get_width()/2,460))

    rendering="Quit"
    fonts1=pygame.font.SysFont("Copperplate Gothic Bold",70)
    label6=fonts1.render(rendering,True,cyan)
    display.blit(label6,(825-label6.get_width()/2,460))

    
    pygame.display.update()
    
    condit=True
    app_exit = False
    setup = 0
    
    while condit==True:
       for event in pygame.event.get():
           if event.type==pygame.QUIT:
                app_exit=True
                condit=False

           elif event.type==pygame.MOUSEBUTTONDOWN:
                pos=event.pos

                if pos[0] in range(45,306) and pos[1] in range(445,525):
                    setup=1
                    condit=False

                if pos[0] in range(375,636) and pos[1] in range(445,525):
                    setup=0
                    condit=False

                if pos[0] in range(705,966) and pos[1] in range(445,525):
                    app_exit=True
                    condit=False
                    
    return (app_exit,setup)
Esempio n. 11
0
        elif pipe_x[3] <= -335:
            pipe_x[3] = 1000

        game_exit = collision(bird_y, pipe_x, pipe_height)

        for i in pipe_x:
            if i == 226:
                points += 1
                break
            if i == 244:
                soundpt.play()

        score(points)

        if game_exit == True:
            highscore.highscore(points)

            soundpt.stop()
            soundlose.play()

            pygame.time.wait(500)

            imag = pygame.image.load("assets/images/Menubackground.png")
            imag = pygame.transform.scale(imag, (1000, 700))
            display.fill(white)
            display.blit(imag, (0, 0))

            pygame.draw.rect(display, (255, 0, 0), (280, 140, 440, 80))

            rendering = "Score: " + str(points)
            fonts1 = pygame.font.SysFont("Copperplate Gothic Bold", 90)
Esempio n. 12
0
def highscoreviewer():
    main = highscore.highscore()
    get_score = main.main(score)
    score_txt = font.render(f"High Score : {str(get_score)}", True,
                            (255, 255, 255))
    screen.blit(score_txt, (800 - 300, 10))