Exemplo n.º 1
0
 def test_elapsed(self):
     # Test that the elapsed attribute is calculated correctly.
     sw = Stopwatch(timer=mock_time, verbose=False)
     self.assertEqual(sw.elapsed, 0.0)
     for i in range(5):
         sw.start(); sw.stop()
         self.assertEqual(sw.elapsed, DELTA)
Exemplo n.º 2
0
 def test_count(self):
     # Test that the count attribute is incremented correctly.
     sw = Stopwatch(verbose=False)
     self.assertEqual(sw.count, 0)
     for i in range(1, 6):
         sw.start(); sw.stop()
         self.assertEqual(sw.count, i)
Exemplo n.º 3
0
 def test_running(self):
     # Test that the running flag is set and cleared correctly.
     sw = Stopwatch(verbose=False)
     self.assertFalse(sw.running)
     sw.start()
     self.assertTrue(sw.running)
     sw.stop()
     self.assertFalse(sw.running)
Exemplo n.º 4
0
 def test_total(self):
     # Test that the total attribute is calculated correctly.
     sw = Stopwatch(timer=mock_time, verbose=False)
     self.assertEqual(sw.total, 0.0)
     for i in range(5):
         self.assertEqual(sw.total, i*DELTA)
         sw.start(); sw.stop()
     self.assertEqual(sw.total, (i+1)*DELTA)
Exemplo n.º 5
0
 def test_count_while_running(self):
     # Test that count is calculated correctly while running.
     sw = Stopwatch(verbose=False)
     self.assertEqual(sw.count, 0)
     sw.start()
     self.assertEqual(sw.count, 1)
     sw.stop()
     self.assertEqual(sw.count, 1)
Exemplo n.º 6
0
 def test_total_while_running(self):
     # Test that total is calculated correctly while running.
     sw = Stopwatch(timer=mock_time, verbose=False)
     sw.start()
     self.assertEqual(sw.total, DELTA)
     self.assertEqual(sw.total, 2*DELTA)
     sw.stop()
     self.assertEqual(sw.total, 3*DELTA)
     # Check it again, to be sure it's no longer increasing.
     self.assertEqual(sw.total, 3*DELTA)
Exemplo n.º 7
0
 def test_reset(self):
     # Test the reset method.
     sw = Stopwatch(verbose=False)
     for i in range(5):
         sw.start()
         sw.stop()
     sw.reset()
     self.assertEqual(sw.count, 0)
     self.assertEqual(sw.total, 0.0)
     self.assertEqual(sw.elapsed, 0.0)
     self.assertFalse(sw.running)
Exemplo n.º 8
0
 def test_reset(self):
     # Test the reset method.
     sw = Stopwatch(verbose=False)
     for i in range(5):
         sw.start(); sw.stop()
     sw.reset()
     self.assertEqual(sw.count, 0)
     self.assertEqual(sw.total, 0.0)
     self.assertEqual(sw.elapsed, 0.0)
     self.assertFalse(sw.running)
Exemplo n.º 9
0
 def test_running(self):
     # Test that the running flag is set and cleared correctly.
     sw = Stopwatch(verbose=False)
     self.assertFalse(sw.running)
     sw.start()
     self.assertTrue(sw.running)
     sw.stop()
     self.assertFalse(sw.running)
Exemplo n.º 10
0
 def test_elapsed(self):
     # Test that the elapsed attribute is calculated correctly.
     sw = Stopwatch(timer=mock_time, verbose=False)
     self.assertEqual(sw.elapsed, 0.0)
     for i in range(5):
         sw.start()
         sw.stop()
         self.assertEqual(sw.elapsed, DELTA)
Exemplo n.º 11
0
 def test_count(self):
     # Test that the count attribute is incremented correctly.
     sw = Stopwatch(verbose=False)
     self.assertEqual(sw.count, 0)
     for i in range(1, 6):
         sw.start()
         sw.stop()
         self.assertEqual(sw.count, i)
Exemplo n.º 12
0
 def test_count_while_running(self):
     # Test that count is calculated correctly while running.
     sw = Stopwatch(verbose=False)
     self.assertEqual(sw.count, 0)
     sw.start()
     self.assertEqual(sw.count, 1)
     sw.stop()
     self.assertEqual(sw.count, 1)
Exemplo n.º 13
0
 def test_total(self):
     # Test that the total attribute is calculated correctly.
     sw = Stopwatch(timer=mock_time, verbose=False)
     self.assertEqual(sw.total, 0.0)
     for i in range(5):
         self.assertEqual(sw.total, i * DELTA)
         sw.start()
         sw.stop()
     self.assertEqual(sw.total, (i + 1) * DELTA)
Exemplo n.º 14
0
 def test_total_while_running(self):
     # Test that total is calculated correctly while running.
     sw = Stopwatch(timer=mock_time, verbose=False)
     sw.start()
     self.assertEqual(sw.total, DELTA)
     self.assertEqual(sw.total, 2 * DELTA)
     sw.stop()
     self.assertEqual(sw.total, 3 * DELTA)
     # Check it again, to be sure it's no longer increasing.
     self.assertEqual(sw.total, 3 * DELTA)
Exemplo n.º 15
0
 def test_attributes(self):
     # Test that Stopwatch instances have the expected attributes.
     sw = Stopwatch(mock_time, True, 0.1)
     self.assertEqual(sw.timer, mock_time)
     self.assertEqual(sw.verbose, True)
     self.assertEqual(sw.cutoff, 0.1)
Exemplo n.º 16
0
screen = None
running = True

backdropImage = None
blockImage = None
block = None
nextBlock = None
moveLeft = False
moveRight = False

baseFallSpeed = 150
fastFallSpeed = 50
fallSpeed = baseFallSpeed

clock = pygame.time.Clock()
dropStopwatch = Stopwatch(pygame.time.get_ticks())

playFieldArea = pygame.Rect(322, 110, 150, 300)
nextBlockArea = pygame.Rect(496, 110, 60, 60)
scoreArea = pygame.Rect(496, 194, 159, 62)

font = None
scoreLabel = None
highScoreLabel = None
score = 0
highScore = 0
lastLineWasTetris = False


def start():
    initialize()