def on_initialize_gui(self): print("initialize gui") self.CELL_SIZE = 1 self.CELL_OFFSET = -3 / 2 * self.CELL_SIZE self.scene.add_action( scene_actions.ChangeCamera( ref=self.scene.rm.get('MainCamera'), clear_flag=scene_actions.ECameraClearFlag.SolidColor, background_color=scene_actions.Vector4(x=1, y=1, z=1, w=1), is_orthographic=True, orthographic_size=2, min_position=scene_actions.Vector3(x=-2, y=-2, z=-10), max_position=scene_actions.Vector3(x=2, y=2, z=-10), min_rotation=scene_actions.Vector2(x=0, y=0), max_rotation=scene_actions.Vector2(x=0, y=0), min_zoom=1, max_zoom=3)) # Draw lines for i in range(1, 3): start = self._get_scene_position(i, 0, get_center=False) end = self._get_scene_position(i, 3, get_center=False) self._draw_line(scene_actions.Vector4(x=0, y=0, z=0), (start['x'], start['y']), (end['x'], end['y'])) self._draw_line(scene_actions.Vector4(x=0, y=0, z=0), (start['y'], start['x']), (end['y'], end['x'])) self.scene.add_action(scene_actions.EndCycle()) self.scene.apply_actions()
def _draw_X(self, x, y): scene_pos = self._get_scene_position(x, y) self._draw_line(scene_actions.Vector4(x=0, y=0, z=1), (scene_pos['x'] - 0.3, scene_pos['y'] + 0.3), (scene_pos['x'] + 0.3, scene_pos['y'] - 0.3)) self._draw_line(scene_actions.Vector4(x=0, y=0, z=1), (scene_pos['x'] - 0.3, scene_pos['y'] - 0.3), (scene_pos['x'] + 0.3, scene_pos['y'] + 0.3))
def initialize(self, config): self._angle = { EDirection.Up: 90, EDirection.Right: 0, EDirection.Down: -90, EDirection.Left: 180, } self._ghost_eyes_index = { EDirection.Up: 5, EDirection.Right: 3, EDirection.Down: 1, EDirection.Left: 2, } self._ghosts_color = [ scene_actions.Vector4(x=213 / 255, y=0, z=0, w=1), scene_actions.Vector4(x=236 / 255, y=64 / 255, z=122 / 255, w=1), scene_actions.Vector4(x=100 / 255, y=181 / 255, z=246 / 255, w=1), scene_actions.Vector4(x=244 / 255, y=81 / 255, z=30 / 255, w=1), ] self._eat_delay = 0.75 self._ghost_eyes_ref = 'Eyes' self._background_music_ref = drm.new() self._wakawaka_music_ref = drm.new() self._eat_ghost_music_ref = drm.new() self._eating_food = False self._ghosts_ref = {} self._foods_ref = {} self._super_foods_ref = {} self._configure(config) self._init_camera() self._init_sounds() self._draw_board() self._draw_players() # Status self._game_status = game_status.GameStatus(self._world, self._scene, eat_delay=self._eat_delay) self._game_status.initialize() self._game_status.draw_statuses() self._scene.add_action(scene_actions.EndCycle())
def _init_camera(self): orthographic_size = self._world.height * self._cell_size / 2 + 2 self._scene.add_action(scene_actions.ChangeCamera( ref = self._rm.get('MainCamera'), clear_flag = scene_actions.ECameraClearFlag.SolidColor, background_color = scene_actions.Vector4(x=0, y=19/255, z=48/255), is_orthographic = True, orthographic_size = orthographic_size, min_position = scene_actions.Vector3(x=self._x_offset, y=self._y_offset, z=-10), max_position = scene_actions.Vector3(x=-self._x_offset, y=-self._y_offset, z=-10), min_rotation = scene_actions.Vector2(x=0, y=0), max_rotation = scene_actions.Vector2(x=0, y=0), min_zoom = self._cell_size * 2, max_zoom = orthographic_size * 2 ))
def _draw_O(self, x, y): scene_pos = self._get_scene_position(x, y) ref = self.scene.rm.new() self.scene.add_action( scene_actions.CreateBasicObject( ref=ref, type=scene_actions.EBasicObjectType.Ellipse2D, )) self.scene.add_action( scene_actions.ChangeTransform( ref=ref, position=scene_actions.Vector3(x=scene_pos['x'], y=scene_pos['y']), )) self.scene.add_action( scene_actions.ChangeEllipse2D( ref=ref, duration_cycles=1, fill_color=scene_actions.Vector4(x=1, y=0, z=0, w=1), x_radius=0.3, y_radius=0.3, ))