def testAddObj(self): self.addThreeObjects() self.assertIn(self.o1, ObjectManager()) self.assertIn(self.o2, ObjectManager()) self.assertIn(self.o3, ObjectManager()) self.assertEqual(3, ObjectManager().getNumObjects())
def testRemoveObj(self): self.addThreeObjects() ObjectManager().removeObj(self.o2) self.assertIn(self.o1, ObjectManager()) self.assertNotIn(self.o2, ObjectManager()) self.assertIn(self.o3, ObjectManager()) self.assertEqual(2, ObjectManager().getNumObjects())
def testGetObjects(self): self.addThreeObjects() todos = ObjectManager().getObjects() self.assertIn(self.o1, todos) self.assertIn(self.o2, todos) self.assertIn(self.o3, todos) self.assertEqual(3, len(todos))
from paddle import Paddle from ball import Ball from scoreboard import Scoreboard from objectManager import ObjectManager import time screen = Screen() screen.setup(width=800, height=850) screen.bgcolor('black') screen.title('Breakout Game') screen.tracer(0) paddle = Paddle(0, -250) ball = Ball() scoreboard = Scoreboard() objects = ObjectManager() objects_dict = objects.objects_generate() screen.listen() screen.onkey(paddle.move_left, 'a') screen.onkey(paddle.move_right, 'd') count = 0 speed = 0.05 game_is_on = True checker_blue = 0 checker_orange = 0 while game_is_on: time.sleep(speed) screen.update()
def setUp(self): self.o1 = object() self.o2 = object() self.o3 = object() ObjectManager().clearObjects()
def addThreeObjects(self): ObjectManager().addObj(self.o1) ObjectManager().addObj(self.o2) ObjectManager().addObj(self.o3)
def testClearObjects(self): self.addThreeObjects() self.assertEqual(3, ObjectManager().getNumObjects()) ObjectManager().clearObjects() self.assertEqual(0, ObjectManager().getNumObjects())
def testSingletonDesign(self): self.assertEqual(ObjectManager(), ObjectManager())