class Game (object): def __init__(self): """Game encompasses the entirety of all game states/objects/etc. Here we make our game screen and init some variables for holding our game objects.""" self.screen = Screen() self.gameobjects = [] #NOTE: We have to specifically set screen to self.screen otherwise # it will set dimensions to self.screen, which is BAD self.player = Player( (25,50), screen=self.screen ) def run(self): """The main game loop. Handles events""" self.screen.add_object( EvilMage( (100,100), screen=self.screen ) ) self.screen.add_object( Text( (500,0), "Test", screen=self.screen) ) self.screen.add_player( self.player ) self.screen.run() #TODO: eventually have a prompt for saving, etc. self.quit() def quit(self): """Quit the game.""" exit()
def show(): world_size_x = 50 world_size_y = 20 global screen screen = Screen(world_size_x, world_size_y) screen_title = ScreenLabel(screen, lambda: "* Info *") screen_title.model.center_hor = True screen_title.pos_y = 15 screen.add_object(screen_title) author_label = ScreenLabel(screen, lambda: "Author: Alexandr aka Try4W") author_label.model.center_hor = True author_label.pos_y = 12 screen.add_object(author_label) email_label = ScreenLabel(screen, lambda: "Email: [email protected]") email_label.model.center_hor = True email_label.pos_y = 11 screen.add_object(email_label) help_to_exit = ScreenLabel(screen, lambda: "Press enter to return") help_to_exit.model.center_hor = True help_to_exit.pos_y = 8 screen.add_object(help_to_exit) global keyboard_listener keyboard_listener = KeyboardControlListener() keyboard_listener.start()
def show(): world_size_x = 50 world_size_y = 20 global screen screen = Screen(world_size_x, world_size_y) global selected_button_id selected_button_id = 0 logo_frames_map = {"DEFAULT": "models/logo.model"} logo_model = ScreenObjectModel(logo_frames_map) logo_model.set_current_frames("DEFAULT") logo_model.center_hor = True logo = ScreenObject(screen, logo_model) logo.pos_y = 10 screen.add_object(logo) host_game_button = ScreenLabel(screen, lambda: get_button_string(-1)) host_game_button.model.center_hor = True host_game_button.pos_y = 8 screen.add_object(host_game_button) connect_to_button = ScreenLabel(screen, lambda: get_button_string(0)) connect_to_button.model.center_hor = True connect_to_button.pos_y = 7 screen.add_object(connect_to_button) exit_game_button = ScreenLabel(screen, lambda: get_button_string(1)) exit_game_button.model.center_hor = True exit_game_button.pos_y = 6 screen.add_object(exit_game_button) exit_game_button = ScreenLabel(screen, lambda: get_button_string(2)) exit_game_button.model.center_hor = True exit_game_button.pos_y = 5 screen.add_object(exit_game_button) global keyboard_listener keyboard_listener = KeyboardControlListener() keyboard_listener.start()
def main(): pygame.init() glutInit() options = { 'BG': BG, 'ANGLE_VIEW' : ANGLE_VIEW} screen = Screen(WIDTH, HEIGHT, options) screen.launch() n = Node(Color()) screen.add_object(n) while True: glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT) #Clear display for event in pygame.event.get(): if event.type == pygame.QUIT: print("Close painting") sys.exit() screen.draw() screen.refresh()