class Core: in_game = False in_menu = True done = True application_running = True cmd = None def __init__(self): self.render = Screen(main_menu, self) def start_game(self): while application_running: in_menu = self.in_menu done = self.done in_game = self.in_game if self.cmd != None: cmd, self.cmd = self.cmd, None if in_menu and done == False: if cmd == 'TITLE': self.render.load_menu(main_menu) elif cmd == 'PAUSE': self.render.load_menu(pause_menu) self.done = True if in_game: self.world.update_game_state(cmd) image = _get_game_state() self.render.load_game(image) def command(self, cmd): if cmd == 'LOAD_WORLD': self.world = World(self.mappack) self.in_menu = False self.in_game = True if cmd == 'QUIT': self.application_running = False self.in_menu = False self.render.root.destroy() if cmd == 'CONTINUE': self.in_menu = False self.in_game = True if cmd == 'TITLE': self.cmd = cmd if cmd == 'PAUSE': self.cmd = cmd
def __init__(self): self.render = Screen(main_menu, self)
if Input.Get_key_down('escape'): game_exit = True if Input.Get_key_down('space') and player.rigidbody.Dist_from_ground( ) and player.rigidbody.Dist_from_ground() <= 0.05: if crouching: crouching = False cam.transform.Translate((0, 0, 0.9)) player.rigidbody.velocity = vector3.add(player.rigidbody.velocity, (0, 0, 3)) if Input.Mouse_button_down(0): if Gun.current_ammo > 0: shot_sound.play() aim_ray = Screen.Ray_on_pixel(cam.middle_pixel) obj = aim_ray.Collide(ignore=[player, range_collider]).other if obj: if obj.parent.name == "Target": obj.parent.parent.Kill() obj.parent.parent.sleeping = True if training: target_count += 1 Gun.recoil = True Gun.current_ammo -= 1 else: empty_sound.play() if Gun.recoil: cam.transform.Rotate(4 * Other.delta_time / Gun.recoil_time,