class ReadyToSingleGameState():
	def __init__(self):
		self.background = Image("background_draw", "assets/images/quickdraw_draw.jpg", 0,0, True )
		self.timer_text = TextField("round_timer", "TIMER", 0, -(gv.screen_height/2)+40, True)

	def enter(self):
		# TODO Kill the sound effect from wait here 
		#
    # Give the players 30 seconds to hit the target first
		gv.round_time = 30
		gv.round_start_time = time.time()
		gc.readyToHit()
		self.timer_text.text = 'START'
		

	def processEvents(self):
		if (gc.checkTargetsSingle()):
			changeState("WIN_STATE")


	def update(self, deltaTime):
    #Increment the timer and exit to the timeout state after 30 seconds
		gv.cur_elapsed = time.time() - gv.round_start_time
		self.timer_text.text = str(round(gv.cur_elapsed,4))

		if gv.cur_elapsed > gv.round_time:
      # TODO Change state to timrout when created
			changeState("TIMEOUT_STATE")

	def draw(self):
		self.background.draw(gv.screen)
		self.timer_text.draw(gv.screen)
    
	def leave(self):
		pass
示例#2
0
 def __init__(self):
     self.bg1 = Image("background_p1win",
                      "assets/images/quickdraw_p1win.jpg", 0, 0, True)
     self.bg2 = Image("background_p2win",
                      "assets/images/quickdraw_p2win.jpg", 0, 0, True)
     self.background = self.bg1
     self.text = TextField("win_text", "test", 200, 400, True)
 def __init__(self):
     self.background = Image("background_start",
                             "assets/images/screen_bg.jpg", 0, 0, True)
     self.debug = TextField("debug_text", "test",
                            -(gv.screen_width / 2) + 100,
                            -(gv.screen_height / 2) + 40, False)
     self.gameObjects = []
     clintImg = Image("fore_clint",
                      "assets/images/clint.png",
                      0,
                      250,
                      True,
                      alpha=True)
     clintObj = GameObject(10, 10, True, clintImg)
     self.gameObjects.append(clintObj)
示例#4
0
class WinGameState:
    def __init__(self):
        self.bg1 = Image("background_p1win",
                         "assets/images/quickdraw_p1win.jpg", 0, 0, True)
        self.bg2 = Image("background_p2win",
                         "assets/images/quickdraw_p2win.jpg", 0, 0, True)
        self.background = self.bg1
        self.text = TextField("win_text", "test", 200, 400, True)

    def enter(self):
        # TODO Kill the sound effect from wait here
        #
        # Wait 30 seconds to switch to home screen
        if (gv.winner == 1):
            self.background = self.bg1
        else:
            self.background = self.bg2
        gv.round_time = 30
        gv.round_start_time = time.time()

        #Reveal the time for the player who won to hit the target
        lastTime = gv.cur_elapsed
        self.text.text = "Time elapsed " + str(round(lastTime, 3)) + " seconds"

    def processEvents(self):
        #check if the ready button has been pressed and transit to the title state
        gc.continueCheck(True, "TITLE_SCREEN_STATE")

    def update(self, deltaTime):
        # Increment the timer and exit to the timeout state after 30 seconds
        gv.cur_elapsed = time.time() - gv.round_start_time

        if gv.cur_elapsed > gv.round_time:
            # Timeout to main screen
            changeState("TITLE_SCREEN_STATE")

    def draw(self):
        self.background.draw(gv.screen)
        self.text.draw(gv.screen)

    def leave(self):
        #TODO leave on screen correctly
        time.sleep(2)
        pass
示例#5
0
class PenaltyGameState:
	def __init__(self):
		self.background = Image("background_penalty", "assets/images/quickdraw_penalty.jpg", 0,0, True )
		self.text = TextField("penalty", "test", 350, -60, True, color=(255,255,255))

	def enter(self):
		# TODO Kill the sound effect from wait here 
		#
    # Wait 30 seconds to switch to home screen
		gv.round_time = 30
		gv.round_start_time = time.time()

		#Reveal the play who initiated a penalty
		self.text.text = "Player " + str(gv.penalty)
		

	def processEvents(self):
		#check if the ready button has been pressed and transit to the title state
		gc.continueCheck(True, "TITLE_SCREEN_STATE")

	def update(self, deltaTime):
    # Increment the timer and exit to the timeout state after 30 seconds
		gv.cur_elapsed = time.time() - gv.round_start_time

		if gv.cur_elapsed > gv.round_time:
      # Timeout to main screen
			changeState("TITLE_SCREEN_STATE")

	def draw(self):
		self.background.draw(gv.screen)
		self.text.draw(gv.screen)
    
	def leave(self):
		#TODO do it right
		time.sleep(2)
		pass
class StartRoundGameState:
    def __init__(self):
        self.background = Image("background_start",
                                "assets/images/screen_bg.jpg", 0, 0, True)
        self.debug = TextField("debug_text", "test",
                               -(gv.screen_width / 2) + 100,
                               -(gv.screen_height / 2) + 40, False)
        self.gameObjects = []
        clintImg = Image("fore_clint",
                         "assets/images/clint.png",
                         0,
                         250,
                         True,
                         alpha=True)
        clintObj = GameObject(10, 10, True, clintImg)
        self.gameObjects.append(clintObj)

    def enter(self):
        #Pause the music and start the round musix
        pauseMusic()
        gv.round_start_effect.play()

        #kill the lights
        gv.lightController._pixels.fill((0, 0, 0))
        gv.lightController._pixels.show()
        #generate the round interval period
        gv.round_time = random.randint(gv.round_min, gv.round_max)
        gv.round_start_time = time.time()

        #reset clint for his slow travel
        animation = TranslationController(250, 100, 600, 100, 10000, True)
        self.gameObjects[0].add_animation(animation)

        #self.foreground.pos_x = 250
        #self.background.pos_x = -50
        #self.background.pos_y = -45
        scale = 1.1
        #self.background.image = pygame.transform.scale(self.background.image, (int(gv.screen_width * scale), int(gv.screen_height * scale)))
        if gv.debug:
            self.debug.drawable = True

    def processEvents(self):
        if (gc.checkHands()):
            changeState("PENALTY_STATE")

    def update(self, deltaTime):
        #Get elapsed time since thr round started
        gv.cur_elapsed = time.time() - gv.round_start_time

        #traverse the parallax
        #self.foreground.pos_x += (.125 * deltaTime)
        self.background.pos_x -= (.0125 * deltaTime)

        #display a counter for debug purposes
        if gv.debug:
            self.debug.text = str(round(gv.cur_elapsed, 3))

        #Check to see if the round is over
        if gv.cur_elapsed > gv.round_time:
            if gv.next_round_state == "MULTIPLAYER_STATE":
                changeState("READY_TO_FIRE_STATE")
            else:
                changeState("READY_TO_SINGLE_STATE")

        for obj in self.gameObjects:
            obj.update(deltaTime)

    def draw(self):
        self.background.draw(gv.screen)
        #self.foreground.draw(gv.screen)
        self.debug.draw(gv.screen)
        for obj in self.gameObjects:
            obj.draw(gv.screen)

    def leave(self):
        pass
	def __init__(self):
		self.background = Image("background_draw", "assets/images/quickdraw_draw.jpg", 0,0, True )
		self.timer_text = TextField("round_timer", "TIMER", 0, -(gv.screen_height/2)+40, True)
示例#8
0
	def __init__(self):
		self.background = Image("background_penalty", "assets/images/quickdraw_penalty.jpg", 0,0, True )
		self.text = TextField("penalty", "test", 350, -60, True, color=(255,255,255))