Exemple #1
0
 def __init__(self, current=0):
     State.__init__(self)
     self.ui = UI(self, Jules_UIContext)
     self.nextState = GameStart
     logo_duration = 20 * 1000
     scores_duration = 5 * 1000
     self.displays = [(logo_duration, self.draw_logo),
                      (scores_duration, self.draw_high_scores)]
     self.eventid = TimerEvents.SplashScreen
     self.current = current
     self.draw = self.displays[self.current][1]
     self.instructions = [
         'Can you think fast and react faster?',
         'This game will test both.',
         'Your job is to destroy the bonus blocks.',
         'Sounds easy, right?... Wrong!', 'There are several problems.',
         'If you destroy a penalty block you lose 200 pts.',
         'If you get 3 penalties, you lose a life.',
         'If you lose 3 lives, the game is over.',
         'The bonus and penalty blocks', 'change colors every 5 seconds.',
         'And on top of that, if you do not destroy a',
         'random non-bonus, non-penalty block every',
         'couple of seconds, that will give you a',
         'penalty too. Think you got all that?'
     ]
Exemple #2
0
 def __init__(self, current=0):
     State.__init__(self)
     self.ui = UI(self, Jules_UIContext)
     self.nextState = GameStart
     logo_duration = 20 * 1000
     scores_duration = 5 * 1000
     self.displays = [(logo_duration, self.draw_logo),
                     (scores_duration, self.draw_high_scores)]
     self.eventid = TimerEvents.SplashScreen
     self.current = current
     self.draw = self.displays[self.current][1]
     self.instructions = ['Can you think fast and react faster?',
                          'This game will test both.',
                          'Your job is to destroy the bonus blocks.',
                          'Sounds easy, right?... Wrong!',
                          'There are several problems.',
                          'If you destroy a penalty block you lose 200 pts.',
                          'If you get 3 penalties, you lose a life.',
                          'If you lose 3 lives, the game is over.',
                          'The bonus and penalty blocks',
                          'change colors every 5 seconds.',
                          'And on top of that, if you do not destroy a',
                          'random non-bonus, non-penalty block every',
                          'couple of seconds, that will give you a',
                          'penalty too. Think you got all that?']
 def __init__(self, screen, inputManager, character):
     State.__init__(self, screen, inputManager)
     self.character = character;
     
     
     self.width, self.height = self.screen.get_width(), self.screen.get_height()    
     pygame.display.set_caption("StepFight - Items Menu")
     
     #Items Box dimensions
     self.item_width, self.item_height = 250, 200
     self.item_screen = self.item_width, self.item_height
     
     #Fonts
     self.font_object = pygame.font.Font('freesansbold.ttf', 20)
     
     self.next_state = Consts.STATE_CONTINUE
     
     #Play button
     self.play_button = self._createButton(self.PLAY_BUTTON, Consts.PLAY, (700,525,200,50))
     self.play_button.font_object = pygame.font.Font('freesansbold.ttf', 35)
     self.play_button._setPadding(50, 10)
 
     #Buy buttons
     self.buy_sword_button = self._createButton(self.BUY_SWORD_BUTTON, Consts.BUY, (75, 200,100,40))
     self.buy_helmet_button = self._createButton(self.BUY_HELMET_BUTTON, Consts.BUY, (525, 200,100,40))
     self.buy_armor_button = self._createButton(self.BUY_ARMOR_BUTTON, Consts.BUY, (75, 450,100,40))
     self.buy_spell_button = self._createButton(self.BUY_SPELL_BUTTON, Consts.BUY, (525, 450,100,40))
Exemple #4
0
    def __init__(self, surf, prev):
        """

        :param surf:
        :param prev:
        """
        State.__init__(self, surf, prev)
 def __init__(self, screen, inputManager):
     State.__init__(self, screen, inputManager)
     inputManager.attach(self.player)
     
     self.board_bounds = pygame.Rect(0,0,950,600)
     
     self.fontObj = pygame.font.Font('freesansbold.ttf', 22)
Exemple #6
0
 def __init__(self, monster):
     from elements import Rectangle
     State.__init__(self)
     full_rect = Rectangle(colour = (0, 0, 0), thickness = 4, x_index = 0, y_index = 0, x_tiles = 10, y_tiles = 10)
     rect = Rectangle(colour = (0, 0, 0), thickness = 2, x_index = 0.25, y_index = 7.75, x_tiles = 9.5, y_tiles = 2)
     self._shapes = [full_rect, rect]
     return
Exemple #7
0
    def __init__(self,
                 grid,
                 curr_player,
                 prev_move,
                 prev_prev_move,
                 board=None):
        self.grid = grid
        self.grid_len = GRID_LEN
        self.win_amt = WIN_AMT
        self.options = self.get_options()  # must be called before check_win

        if DEBUG_BOARD:
            self.board = board  #for visual debugging
        else:
            self.board = None

        self.prev_move = prev_move
        self.prev_prev_move = prev_prev_move

        # check win for opponent
        terminal, winning_player = self.check_win(prev_move)

        if LIMIT_TO_WINNING_MOVE:
            # check guaranteed winning move for current player
            almost_win, win_option = self.get_win_info(prev_prev_move)
            if almost_win:
                self.options = [win_option]

        State.__init__(self, curr_player, terminal, winning_player)
 def __init__(self, window, *args, **kwargs):
     print "++++ new level intro state"
     script_name = kwargs["script_name"]
     State.__init__(self, window, "scripted%s" % script_name, *args, **kwargs)
     self.build_scene()
     self.script = kwargs["script"][:]
     self.running_text = False
     self.band_pic = None
    def __init__(self):
        State.__init__(self)
        for player in game.players:
            player.init_phase(self.phase_name)

        self.time_left = self.duration
        self.clock = pygame.time.Clock()
        self.clock.tick()
 def __init__(self, screen, inputManager, client):
     State.__init__(self, screen, inputManager)
     self.client = client
     inputManager.attach(self)
     
     self.board_bounds = pygame.Rect(0,0,screen.get_width(),screen.get_height())
     
     self.fontObj = pygame.font.Font('freesansbold.ttf', 22)
    def __init__(self, start, screen, inputManager):
        State.__init__(self, screen, inputManager)

        self.start = start

        self.board_bounds = pygame.Rect(0, 0, 950, 600)

        self.fontObj1 = pygame.font.Font('freesansbold.ttf', 42)
        self.fontObj2 = pygame.font.Font('freesansbold.ttf', 24)
Exemple #12
0
 def __init__(self, size, max_height):
     State.__init__(self)
     self.size = size
     self.max_height = max_height
     self.stones = [STONES[size][0] for _ in range(2)]
     self.capstones = [STONES[size][1] for _ in range(2)]
     self.board = [[Stack() for _ in range(size)] for _ in range(size)]
     self.history = set()
     self.turn = 1
Exemple #13
0
 def __init__(self, disp):
   State.__init__(self,disp)
   self.inputHandler = input.NonBlockingKeyboardHandler()
   self.inputHandler.initInputs(
     {
       'quit': {
         'key':libtcod.KEY_ESCAPE,
         'ch': None,
         'fn': self.quitToMenu
       },
       'mvUp': {
         'key': libtcod.KEY_KP8,
         'ch': None,
         'fn': self.mvUp
       },
       'mvDn': {
         'key': libtcod.KEY_KP2,
         'ch': None,
         'fn': self.mvDn
       },
       'mvRgt': {
         'key': libtcod.KEY_KP6,
         'ch': None,
         'fn': self.mvRgt
       },
       'mvLft': {
         'key': libtcod.KEY_KP4,
         'ch': None,
         'fn': self.mvLft
       },
       'mvUpLft': {
         'key': libtcod.KEY_KP7,
         'ch': None,
         'fn': self.mvUpLft
       },
       'mvUpRgt': {
         'key': libtcod.KEY_KP9,
         'ch': None,
         'fn': self.mvUpRgt
       },
       'mvDnLft': {
         'key': libtcod.KEY_KP1,
         'ch': None,
         'fn': self.mvDnLft
       },
       'mvDnRgt': {
         'key': libtcod.KEY_KP3,
         'ch': None,
         'fn': self.mvDnRgt
       },
       
       'toggleRope': {
         'key': libtcod.KEY_SPACE,
         'ch': None,
         'fn': self.ropeToggle
       }
   })
 def __init__(self, start, screen, inputManager): 
     State.__init__(self, screen, inputManager)
     
     self.start = start
     
     self.board_bounds = pygame.Rect(0,0, 950, 600)
     
     self.fontObj1 = pygame.font.Font('freesansbold.ttf', 42)
     self.fontObj2 = pygame.font.Font('freesansbold.ttf', 24)
Exemple #15
0
 def __init__(self):
     State.__init__(self)
     self._shapes = shapes()
     self._sprites = sprites()
     self._sword = sword()
     self._sword_top_index = self._sword.y_index
     self._number_of_choices = 2
     self._current_choice = 0 
     return
    def __init__(self, screen, inputManager, client):
        State.__init__(self, screen, inputManager)
        self.client = client
        inputManager.attach(self)

        self.board_bounds = pygame.Rect(0, 0, screen.get_width(),
                                        screen.get_height())

        self.fontObj = pygame.font.Font('freesansbold.ttf', 22)
  def __init__(self, disp, width, height):
    State.__init__(self, disp)
    
    self.initWorld(width, height)

    self.initGui()
    
    self.registerInputHandlers()
    self.update()
 def __init__(self, window, *args, **kwargs):
     print "++++ new fade state"
     State.__init__(self, window, "fade", *args, **kwargs)
     self.old_state_batch = kwargs["old_state"]
     self.duration = kwargs["duration"]
     self.next_state = kwargs["next_state"]
     self.next_state_args = kwargs["next_state_args"]
     self.build_scene()
     self.alpha = 0.0
 def __init__(self, window, *args, **kwargs):
     print "++++ new pause state"
     State.__init__(self, window, "pause", *args, **kwargs)
     audio.attenuate_music()
     self.menuloc = (-0.9, 1.0)
     self.choices = {1: "resume", 2: "quit"}
     self.choice = 1
     self.old_state_batch = args[0]
     self.build_scene()
Exemple #20
0
 def __init__(self, surf, prev):
     State.__init__(self, surf, prev)
     self.generator = self.prev_state.random
     self.max_trains = self.prev_state.train
     self.max_crash = self.prev_state.crash
     self.pause = False
     self.end = False
     self.map_controller = ControlMap()
     self.map_controller.load_map(self.prev_state.cur_map)
     self.map_controller.set_train_generator(self.generator)
Exemple #21
0
 def __init__(self, images, fonts):
     State.__init__(self)
     self.next = 'start_menu'
     self.background = images[0]
     self.fonts = fonts
     self.buttons = pygame.sprite.Group()
     Button.groups = self.buttons
     screen_size = pygame.display.get_surface().get_size()
     self.back_button = Button(
         (images[1], images[2]),
         (screen_size[0] - 140, screen_size[1] - self.y_for_bottom_buttons))
 def __init__(self, lives=3, score=0, penalties=0):
     State.__init__(self)
     self.ui = UI(self, Jules_UIContext)
     self.nextState = None
     self.eventid = TimerEvents.Playing
     self.score = score
     self.lives = lives
     self.penalties = penalties
     self.countdown = 5 * 1000
     self.penalties_per_life = 3
     self.start_time = pygame.time.get_ticks()
 def __init__(self, surf, prev):
     """
     :param surf:
     :param prev:
     :return:
     """
     State.__init__(self, surf, prev)
     self.random = True
     self.train = 6
     self.crash = 4
     self.cur_map = 1
Exemple #24
0
 def __init__(self, lives=3, score=0):
     State.__init__(self)
     self.ui = UI(self, Jules_UIContext)
     self.lives = lives
     self.score = score
     self.nextState = lambda: Playing(self.lives, self.score)
     self.prompt = "Ready?"
     self.countdown_step = 500
     self.count = 3
     self.text = self.prompt
     self.eventid = TimerEvents.GameStart
Exemple #25
0
 def __init__(self):
     State.__init__(self)
     self.fusionData = {
         'gesture': '',
         'soundCreate': '',
         'color': '',
         'soundPosition': ''
     }
     self.clickPosition = []
     self.canvas = None
     self.canvasOpen = False
Exemple #26
0
 def __init__(self, lives=3, score=0):
     State.__init__(self)
     self.ui = UI(self, Jules_UIContext)
     self.lives = lives
     self.score = score
     self.nextState = lambda: Playing(self.lives, self.score)
     self.prompt = "Ready?"
     self.countdown_step = 500
     self.count = 3
     self.text = self.prompt
     self.eventid = TimerEvents.GameStart
Exemple #27
0
    def __init__(self):
        State.__init__(self)
        self.level = None
        self.view = View(self)

        self.feature_manager = FeatureDrawManager(self)
        self.actor_manager = ActorDrawManager(self)
        self.shroud_manager = ShroudDrawManager(self)
        self.effect_draw = EffectDrawManager(self)

        self.turn_manager = None
Exemple #28
0
 def __init__(self, window, level, diff, pair_generator, win_conditions, *args, **kwargs):
     print "++++ new game state"
     self.level = level
     self.diff = diff
     self.pair_generator = pair_generator
     self.win_conditions = win_conditions
     State.__init__(self, window, "game", *args, **kwargs)
     self.build_scene()
     self.current_rung = None
     self.longest_streak = 0
     self.time = 0
     self.mutation_counter = 0
Exemple #29
0
    def __init__(self, images, fonts):
        State.__init__(self)
        self.next = 'game'
        self.background = images[0]
        self.fonts = fonts
        self.farbeaendern = 0
        self.start_window_text_1 = self.fonts[0].render(
            'SPACE', True, Color('White'))
        self.start_window_text_2 = self.fonts[0].render(
            'WARS', True, Color('White'))
        self.text_input = pygame_textinput.TextInput()
        self.high_score = None
        self.text_input_box = pygame.Rect(50, 140, 300, 40)
        default_font = pygame.font.Font(None, 35)
        self.name_text = default_font.render('Name:', True, Color('Cyan'))

        self.bg_text = default_font.render('Spielumgebung:', True,
                                           Color('Cyan'))
        self.bg_box = pygame.Rect(self.text_input_box.x,
                                  self.text_input_box.y + 100, 300, 130)
        self.buttons = pygame.sprite.Group()
        Button.groups = self.buttons
        self.screen_button_1 = Button((images[1], images[2]),
                                      (self.bg_box.x + 20, self.bg_box.y + 20))
        self.screen_button_1.set_clicked(True)
        self.screen_button_2 = Button(
            (images[3], images[4]), (self.bg_box.x + 150, self.bg_box.y + 20))

        self.play_box = pygame.Rect(self.bg_box.x, self.bg_box.y + 190, 300,
                                    130)
        self.play_text = default_font.render('Spiel starten:', True,
                                             Color('Cyan'))
        self.difficulty_5x5_button = Button(
            (images[5], images[6]),
            (self.play_box.x + 20, self.play_box.y + 20))
        self.difficulty_6x6_button = Button(
            (images[7], images[8]),
            (self.play_box.x + 115, self.play_box.y + 20))
        self.difficulty_7x7_button = Button(
            (images[9], images[10]),
            (self.play_box.x + 210, self.play_box.y + 20))

        screen_size = pygame.display.get_surface().get_size()
        self.quit_button = Button(
            (images[13], images[14]),
            (screen_size[0] - 120, screen_size[1] - self.y_for_bottom_buttons))
        self.the_bests_button = Button(
            (images[11], images[12]),
            (screen_size[0] - 270, screen_size[1] - self.y_for_bottom_buttons))
        self.instruction_button = Button(
            (images[15], images[16]),
            (screen_size[0] - 405,
             screen_size[1] - self.y_for_bottom_buttons + 2))
Exemple #30
0
 def __init__(self, score):
     State.__init__(self)
     self.ui = UI(self, Jules_UIContext)
     self.nextState = lambda: SplashScreen(current=1)
     self.eventid = TimerEvents.GameOver
     self.score = score
     self.countdown = 5 * 1000
     for key, (name, value) in sorted(HighScores.high_scores.items()):
         if score > value:
             self.replace = key
             break
     else:
         self.replace = None
Exemple #31
0
 def __init__(self, level_name):
     from display import Level, LevelImages
     from game_sprites import Ray
     from game import Overworld
     State.__init__(self)
     LevelImages.initialize_images()
     self._level = Level(level_name)
     ray = Ray()
     self._sprite = pygame.sprite.RenderPlain(ray)
     self._shapes = [game_sprites.RedSquare(x_index = 2, y_index = 2)]
     Overworld.set_center_x_index(1)
     Overworld.set_center_y_index(1)
     return
Exemple #32
0
 def __init__(self, score):
     State.__init__(self)
     self.ui = UI(self, Jules_UIContext)
     self.nextState = lambda: SplashScreen(current=1)
     self.eventid = TimerEvents.GameOver
     self.score = score
     self.countdown = 5 * 1000
     for key, (name, value) in sorted(HighScores.high_scores.items()):
         if score > value:
             self.replace = key
             break
     else:
         self.replace = None
Exemple #33
0
 def __init__(self, window, *args, **kwargs):
     State.__init__(self, window, *args, **kwargs)
     self.score = ScoreWidget(window)
     self.mf = MoleculeFactory()
     self.blend = pyglet.resource.image("blend.png")
     self.heart = pyglet.resource.image("heart.png")
     self.eat = pyglet.resource.media("eat.wav", streaming=False)
     self.explode = pyglet.resource.media("explode.wav", streaming=False)
     self.cell = Cell(500, 300)
     self.cell_emitter = PositionalBubbleEmitter(window, self.cell)
     self.game_map = GameMap("level1")
     self.camera = Camera(self.cell, self.window, self.game_map)
     self.life = 9
     self.fps_display = pyglet.clock.ClockDisplay()
 def __init__(self, next_phase):
     State.__init__(self)
     announce_text = getattr(game.field.map,
                             next_phase.phase_name + "_phase_text")
     self.make_announce_surface(*announce_text)
     common.blit(
         self.announce_surface,
         divide(
             subtract(common.screen.get_size(),
                      self.announce_surface.get_size()), 2),
     )
     common.update()
     self.start_time = pygame.time.get_ticks()
     self.next_phase = next_phase
Exemple #35
0
    def __init__(self, screen, core):
        State.__init__(self)
        self.core = core

        self.gui = gui.Window(screen, screen.get_rect())
        self.gui.background_color = (255, 255, 255)
        ng_btn = gui.Button("New game", (50, 50, 120, 30))
        ng_btn.set_onclick_callback(self.new_game)
        level_btn = gui.Button("Select level", (200, 50, 120, 30))
        level_btn.set_onclick_callback(lambda: self.stack.push(LevelSelectState(screen, self.core)))
        exit_btn = gui.Button("Exit", (50, 90, 120, 30))
        exit_btn.set_onclick_callback(lambda: self.stack.pop())
        self.gui.add_child(ng_btn)
        self.gui.add_child(level_btn)
        self.gui.add_child(exit_btn)
    def __init__(self, is_p1_turn: bool) -> None:
        """
        initialize a new subclass of state: ChopstickState

        >>> is_p1_turn = True
        >>> c1 = ChopstickState(is_p1_turn)
        >>> c1.is_p1_turn
        True
        >>> c1.is_game_over
        False
        >>> c1.current_list
        [1, 1, 1, 1]
        """
        State.__init__(self, is_p1_turn)
        self.current_list = [1, 1, 1, 1]
Exemple #37
0
	def __init__(self, name, minmax=None, cleanup=False, incremental=False, persistant=True):
		State.__init__(self, name)
		t = self.get("type")
		if (t is not None) and (t != "range"):
			raise ValueError("%s not a range (%s)"%(self.prefix,t))
		self.incremental = incremental
		self.persistant = persistant
		if cleanup:
			self._unpersist()
		if (minmax is None):
			self._loadFromDB()
			persistant = False
		else:
			self._loadFromArgs(minmax)
		if persistant:
			self.persist(not incremental)
Exemple #38
0
    def __init__(self, screen, game):
        State.__init__(self)
        self.game = game
        self.screen = screen
        (w, h) = screen.get_size()
        self.rect = pygame.Rect(w / 4, h / 4, w / 2, h / 2)

        self.gui = gui.Window(screen, self.rect)
        ng_button = gui.Button("New game", pygame.Rect(10, 50, 120, 30))
        ng_button.set_onclick_callback(lambda: self.game.new_game() or self.stack.pop())
        resume_button = gui.Button("Resume", pygame.Rect(10, 90, 120, 30))
        resume_button.set_onclick_callback(lambda: self.stack.pop())
        quit_button = gui.Button("Quit game", pygame.Rect(10, 130, 120, 30))
        quit_button.set_onclick_callback(lambda: self.stack.pop() or self.stack.pop())
        self.gui.add_child(ng_button)
        self.gui.add_child(resume_button)
        self.gui.add_child(quit_button)
Exemple #39
0
 def __init__(self, window, *args, **kwargs):
     """ 
         The initial state. This present the player with a list of choices
         that determine the next game state.
     """
     State.__init__(self, window, *args, **kwargs)
     self.window.set_caption("Survive by Nine")
     self.menuloc = (400, 215)        
     self.choices = {1: 'New',
                     2: 'Quit'
                 }
     self.choice = 1
     self.labels = self.build_labels()
     self.load_resources()
     
     self.emitter = BubbleEmitter(window)
     pyglet.clock.schedule_interval(self.emitter.update, 1.0/60.0)
     self.labels[0].set_style("bold", True)
Exemple #40
0
 def __init__(self, lives=3, score=0, penalties=0):
     State.__init__(self)
     self.ui = UI(self, Jules_UIContext)
     self.nextState = None
     self.eventid = TimerEvents.Playing
     self.eventid2 = TimerEvents.BuzzKill
     self.score = score
     self.lives = lives
     self.penalties = penalties
     self.countdown = 5 * 1000
     self.penalties_per_life = 3
     self.start_time = pygame.time.get_ticks()
     self.squares = []
     self.bonus_color = self.rand_color()
     self.penalty_color = self.bonus_color
     while self.penalty_color == self.bonus_color:
         self.penalty_color = self.rand_color()
     self.limit = 2 * 1000
Exemple #41
0
 def __init__(self, lives=3, score=0, penalties=0):
     State.__init__(self)
     self.ui = UI(self, Jules_UIContext)
     self.nextState = None
     self.eventid = TimerEvents.Playing
     self.eventid2 = TimerEvents.BuzzKill
     self.score = score
     self.lives = lives
     self.penalties = penalties
     self.countdown = 5 * 1000
     self.penalties_per_life = 3
     self.start_time = pygame.time.get_ticks()
     self.squares = []
     self.bonus_color = self.rand_color()
     self.penalty_color = self.bonus_color
     while self.penalty_color == self.bonus_color:
         self.penalty_color = self.rand_color()
     self.limit = 2 * 1000
    def __init__(self, screen, inputManager, character, description):
        State.__init__(self, screen, inputManager)

        self.width, self.height = self.screen.get_width(), self.screen.get_height()
        pygame.display.set_caption("Welcome")

        #Welcome Box Things
        self.activity_description = description
        
        #Fonts
        self.font_object = pygame.font.Font('freesansbold.ttf', 20)


        #Continue Button
        self.continue_button = self._createButton(self.CONTINUE_BUTTON, Consts.CONTINUE, (550,500,300,50))
        self.continue_button.font_object = pygame.font.Font('freesansbold.ttf', 35)
        self.continue_button._setPadding(50, 10)

        self.next_state = Consts.CONTINUE
Exemple #43
0
 def __init__(self, window, *args, **kwargs):
     State.__init__(self, window, *args, **kwargs)
     self.old_state = args[0]
     points = self.old_state.score.get_score()
     self.label1 = pyglet.text.Label(
         text="You scored a total of %d points!" % points,
         font_size=24,
         x=window.width // 2,
         y=window.height - window.height // 3,
         anchor_x="center",
         anchor_y="center",
     )
     self.label2 = pyglet.text.Label(
         text="Press ENTER to return to menu.",
         font_size=24,
         x=window.width // 2,
         y=window.height - window.height // 3 - 50,
         anchor_x="center",
         anchor_y="center",
     )
Exemple #44
0
    def __init__(self, screen, rm, im):
        State.__init__(self, screen, rm, im)  

        # map rendering
        self.map_render = MapRenderer(screen)
        self._load_map()

        # TODO camera should be it's own class... not dependent on gamestate
        # camera
        self.fixed_camera = False
        self.camera_scale = 1
        self.camera_x, self.camera_y = (0,0)
        self.camera_speed = 1

        # timer
        self.ticks = 0

        # entities
        self.entities = []
        self.hero = Hero()
        self.entities.append(self.hero)
Exemple #45
0
    def __init__(self, screen, rm):
        State.__init__(self, screen, rm)

        # board stats
        self.cur_floor_lvl = SETTINGS['default_starting_floor']

        # dice
        self.dice = Dice()

        # floor
        self.ff = FloorFactory()
        self._generate_floor()

        # timer
        self.ticks = 0

        # hero
        self.hero = VikingHero()

        # monster target
        self.cur_monster_target = None
    def __init__(self, p1: bool, starting_number=-1) -> None:
        """
        initialize a new game state for SubtractSquare game.

        >>> is_p1_turn = True
        >>> s1 = SubtractSquareState(is_p1_turn, 20)
        >>> is_p1_turn = False
        >>> s2 = SubtractSquareState(is_p1_turn, 30)
        """
        State.__init__(self, p1)
        if starting_number == -1:
            self.starting_number = int(
                input("Choose a non-negtive whole number"
                      ":"))
        else:
            self.starting_number = starting_number
        if self.starting_number == 0:
            self.is_game_over = True
            if self.is_p1_turn:
                self.is_p1_turn = False
            else:
                self.is_p1_turn = True
Exemple #47
0
    def __init__(self, main):

        State.__init__(self, main)

        self.generating = True
        self.slot_cursor = 0

        self.grid_ref = self.set_grid_ref()
        self.point_ref = self.set_point_ref()
        self.ship_grid = self.init_ship_grid()

        self.selection_grid = self.set_selection_grid()
        self.selector, self.selrect = self.set_selector()

        self.saved_grid = self.set_saved_grid()
        self.saved_icon = pygame.image.load('assets/saved.png')
        self.saved_rect = self.saved_icon.get_rect()

        self.buttons = self.set_buttons()

        self.show_frame = False
        self.show_spine = False
Exemple #48
0
    def __init__(self, game_images, game_sounds, game_fonts, spoken_words):
        State.__init__(self)
        self.next = 'start_menu'
        self.game_images = game_images
        self.game_sounds = game_sounds
        self.game_fonts = game_fonts
        self.spoken_words = spoken_words
        self.__create_sprite_groups()
        self.__assign_sprite_groups()
        self.buttons = pygame.sprite.Group()
        self.game_over_text = self.game_fonts[0].render(
            'Game Over', True, Color('White'))
        self.you_won_text = self.game_fonts[0].render('You Won', True,
                                                      Color('White'))
        self.your_result_text = None
        Button.groups = self.buttons
        screen_size = pygame.display.get_surface().get_size()
        self.back_button = Button(
            (game_images[5], game_images[6]),
            (screen_size[0] - 140, screen_size[1] - self.y_for_bottom_buttons))

        self.level_settings = {
            "current_level": 1,
            "new_level": True,
            1: {
                "alien_speed": 5,
                "bullet_counter": 60
            },
            2: {
                "alien_speed": 6,
                "bullet_counter": 50
            },
            3: {
                "alien_speed": 7,
                "bullet_counter": 40
            },
            "next_level_counter": LEVEL_COUNTER
        }
 def __init__(self, screen, inputManager, character):
     State.__init__(self, screen, inputManager)
     self.character = character;
     self.character.reset()
     
     pygame.display.set_caption("StepFight - Dragon Fight")
     
     self.background = pygame.image.load(Consts.FIGHT_BACKGROUND)
     
     #Create buttons
     self._createButtons()
     #Create characters
     #self.character = Character()
     self.dragon = Dragon(character.level)
     
     self.is_in_resolution = False
     self.text_character_attack = ""
     self.text_dragon_attack = ""
     self.font_object = pygame.font.Font('freesansbold.ttf', 20)
     
     self.fight_ended = False
     
     self.next_state = Consts.STATE_CONTINUE
Exemple #50
0
    def __init__(self, attribute_system, p, ascriptions={}):
        """
        Construct a NamedState object.

        :param attribute_system: The AttributeSystem object \
        :math:`\mathcal{S}` from which the NamedState object comes from.
        :type  attribute_system: AttributeSystem
        :param p: The ConstantAssignment object :math:`\\rho` of the \
        NamedState object.
        :type  p: ConstantAssignment
        :param ascriptions: An optional dictionary of attribute-object pairs \
        :math:`\delta_{i}(s_{j})` to use as ascriptions; if some \
        attribute-object pair is not provided, the full ValueSet of the \
        Attribute object corresponding to the attribute label in the \
        attribute-object pair is used.
        :type  ascriptions: ``dict``

        :raises TypeError: ``p`` parameter must be a ConstantAssignment object.
        :raises ValueError: The AttributeSystem object provided in the \
        ``attribute_system`` parameter and the AttributeSystem object of the \
        ConstantAssignment object in the ``p`` parameter must match.
        """

        if not hasattr(p, "_is_ConstantAssignment"):
            raise TypeError("p parameter must be a ConstantAssignment object")

        if p._attribute_system != attribute_system:
            raise ValueError("ConstantAssignment AttributeSystem and "
                             "State AttributeSystem must match")

        from copy import deepcopy
        State.__init__(self, attribute_system, ascriptions)
        self._p = deepcopy(p)
        # reassign vocabulary to keep reference since Vocabulary's are mutable
        self._p._vocabulary = p._vocabulary
        self._is_NamedState = True
Exemple #51
0
    def __init__(self, main):

        State.__init__(self, main)
        self.needs_update = True
 def __init__(self, owner):
     State.__init__(self, owner)
Exemple #53
0
 def __init__(self, isInit=False, isFinish=False, x=0, y=0):
     State.__init__(self, isInit, isFinish)
     self._x = x
     self._y = y
     self._active = False
Exemple #54
0
 def __init__(self):
     State.__init__(self)
     self.widgets = []
Exemple #55
0
 def __init__(self, name):
     State.__init__(self, name)
Exemple #56
0
 def __init__(self, previousState):
     State.__init__(self)
     self.previousState = previousState
Exemple #57
0
 def __init__(self, size, widget):
     State.__init__(self, size=size, root=widget)
Exemple #58
0
 def __init__(self, app):
     State.__init__(self, app)
     self.img = Image("test.jpg", (200, 200))
     self.app.load_font("font.tga")
     self.a = 0
Exemple #59
0
    def __init__(self, start, screen, inputManager, networkConnector):
        State.__init__(self, screen, inputManager, networkConnector)

        self.board_bounds = pygame.Rect(0, 0, 950, 600)

        self.fontObj = pygame.font.Font('freesansbold.ttf', 42)
Exemple #60
0
 def __init__(self):
     State.__init__(self)