def main(): if len(sys.argv) > 1: save_file = sys.argv[1] else: save_file = None the_world = world.World(save_file) gw = display.Display(the_world) gw.root.mainloop()
def test_bearing(self) -> None: w = world.World(self.scene) self.assertEqual(w.get_bearing(), 0.0) w.rotate_by(1.0 * pi) self.assertEqual(w.get_bearing(), pi) w.rotate_by(2.0 * pi) self.assertEqual(w.get_bearing(), pi) w.rotate_by(-3.0 * pi) self.assertEqual(w.get_bearing(), 0.0)
def test_move_over_pole(self) -> None: step_forward = (0.0, 0.001 * pi) step_right = (0.001 * pi, 0.0) w = world.World(self.scene) w._set_lookat(geometry.Point(0.25 * pi, 0.0)) self.assertEqual(w.get_theta(), 0.25 * pi) self.assertEqual(w.get_phi(), 0.0) self.assertEqual(w.get_bearing(), 0.0) for i in range(0, 500): w.move(*step_forward) self.assertAlmostEqual(w.get_theta(), 0.25 * pi, places=4) self.assertAlmostEqual(w.get_phi(), pi) self.assertAlmostEqual(w.get_bearing(), pi)
def test_move_left_along_equator(self) -> None: step = (-0.001 * pi, 0.0) w = world.World(self.scene) self.assertEqual(w.get_theta(), 0.5 * pi) self.assertEqual(w.get_phi(), 0.0) self.assertEqual(w.get_bearing(), 0.0) w.move(*step) self.assertEqual(w.get_theta(), 0.5 * pi) self.assertAlmostEqual(w.get_phi(), step[0]) self.assertEqual(w.get_bearing(), 0.0) for i in range(0, 499): w.move(*step) self.assertEqual(w.get_theta(), 0.5 * pi) self.assertAlmostEqual(w.get_bearing(), 0.0) self.assertAlmostEqual(w.get_phi(), -0.5 * pi, places=4)
def test_move_left_across_equator(self) -> None: step = (-0.001 * pi, 0.0) w = world.World(self.scene) w._set_lookat(geometry.Point(0.75 * pi, 0.0)) self.assertEqual(w.get_theta(), 0.75 * pi) self.assertEqual(w.get_phi(), 0.0) self.assertEqual(w.get_bearing(), 0.0) for i in range(0, 500): w.move(*step) self.assertAlmostEqual(w.get_theta(), 0.5 * pi, places=5) self.assertAlmostEqual(w.get_phi(), -0.5 * pi, places=5) self.assertAlmostEqual(w.get_bearing(), 0.25 * pi, places=6) for i in range(0, 500): w.move(*step) self.assertAlmostEqual(w.get_theta(), 0.25 * pi, places=5) self.assertAlmostEqual(w.get_phi(), -1.0 * pi, places=4) self.assertAlmostEqual(w.get_bearing(), 0.0, places=4)
def test_move_forward_with_bearing(self) -> None: step = (0.0, 0.001 * pi) w = world.World(self.scene) w.rotate_by(0.25 * pi) self.assertEqual(w.get_theta(), 0.5 * pi) self.assertEqual(w.get_phi(), 0.0) self.assertEqual(w.get_bearing(), 0.25 * pi) for i in range(0, 500): w.move(*step) self.assertAlmostEqual(w.get_phi(), 0.5 * pi, places=4) self.assertAlmostEqual(w.get_theta(), 0.25 * pi, places=5) self.assertAlmostEqual(w.get_bearing(), 0.5 * pi, places=5) for i in range(0, 500): w.move(*step) self.assertAlmostEqual(w.get_phi(), 1.0 * pi, places=4) self.assertAlmostEqual(w.get_theta(), 0.5 * pi, places=4) self.assertAlmostEqual(w.get_bearing(), 0.75 * pi, places=5)
def __init__(self, graphics): self.graphics = graphics self.market_blocks, self.player_blocks = blocks.get_blocks(graphics) self.world = world.World() self.view = 0 # current graphical view self.selected = -1 # currently selected virus self.viruses = [] self.to_render = [] # list of graphical elements self.elements = {} # whether the mouse is pressed self.pressed = False # get resolution display_info = pygame.display.Info() # initialise scalable elements self.resolution = (display_info.current_w, display_info.current_h) self.resolution_change(self.resolution) # amount of scroll on the main view self.main_view_scroll = 0
def test_move_forward_along_meridian(self) -> None: step = (0.0, 0.001 * pi) w = world.World(self.scene) self.assertEqual(w.get_theta(), 0.5 * pi) self.assertEqual(w.get_phi(), 0.0) self.assertEqual(w.get_bearing(), 0.0) w.move(*step) self.assertAlmostEqual(w.get_theta(), 0.5 * pi - step[1]) self.assertAlmostEqual(w.get_phi(), 0.0) self.assertEqual(w.get_bearing(), 0.0) for i in range(0, 249): w.move(*step) self.assertAlmostEqual(w.get_bearing(), 0.0) self.assertAlmostEqual(w.get_phi(), 0.0) self.assertAlmostEqual(w.get_theta(), 0.25 * pi, places=5) for i in range(0, 250): w.move(*step) self.assertAlmostEqual(w.get_bearing(), 0.0) self.assertAlmostEqual(w.get_phi(), 0.0) self.assertAlmostEqual(w.get_theta(), 0.0 * pi, places=4)
def __init__(self): self.world = world.World() self.x, self.y = 0, 0
def main(): the_world = world.World() gw = display.Display(the_world) gw.root.mainloop()