class TimeoutGameState:
	def __init__(self):
		self.background = Image("background_timeout", "assets/images/quickdraw_timeout.jpg", 0,0, True )

	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()
		

	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)
    
	def leave(self):
		pass
Esempio n. 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)
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
 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)
Esempio n. 5
0
 def __init__(self):
     self.background = Image("background_title",
                             "assets/images/quickdraw_title.jpg", 0, 0,
                             True)
     self.gameObjects = []
     gameImage = Image("crosshairs",
                       "assets/images/crosshair.png",
                       0,
                       0,
                       True,
                       alpha=True)
     gameObject = GameObject(10, 10, True, gameImage)
     self.gameObjects.append(gameObject)
     self.text = TextField("readyTxt", "test", 200, 400, True)
     self.text2 = TextField("readyTxt", "test", 200, 300, True)
Esempio n. 6
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)
Esempio n. 9
0
class TitleScreenGameState:
    def __init__(self):
        self.background = Image("background_title",
                                "assets/images/quickdraw_title.jpg", 0, 0,
                                True)
        self.gameObjects = []
        gameImage = Image("crosshairs",
                          "assets/images/crosshair.png",
                          0,
                          0,
                          True,
                          alpha=True)
        gameObject = GameObject(10, 10, True, gameImage)
        self.gameObjects.append(gameObject)
        self.text = TextField("readyTxt", "test", 200, 400, True)
        self.text2 = TextField("readyTxt", "test", 200, 300, True)

    def addGameObj(self, gameObject):
        self.gameObjects.append(gameObject)

    def removeGameObj(self, target):
        self.gameObjects.remove(target)

    def enter(self):
        #Turn the music on if not playing, checks at beginning of init to make sure, unpauses when re-entering state
        if not gv.musicIsOn:
            gv.musicIsOn = True
            gv.music.play()
        #if any sounds are playing, stop them
        pygame.mixer.stop()
        unpauseMusic()
        animation = TranslationController(10, 10, 1400, 700, 10000, True)
        rotation = RotationController(0, 360, 5000, True)
        self.gameObjects[0].add_animation(animation)
        self.gameObjects[0].add_animation(rotation)
        self.addGameObj(gv.lightsObject)
        # for light in gv.lightsObject.lights:
        #   light.setGlow(500, Color(255,0,0), 'GlowFadeIn')
        gv.lightsObject.lights[0].setGlow(500, Color(255, 0, 0), 'GlowFadeIn')

    def processEvents(self):
        #check if the ready button has been pressed and transit to the start state
        gc.checkReady(True, "SINGLE_PLAYER_STATE", "MULTIPLAYER_STATE")

    def update(self, deltaTime):
        self.text.text = "Multiplayer Ready: " + str(
            round(gv.multiPlayerReadyCount, 3)) + " seconds"
        self.text2.text = "Single player Ready: " + str(
            round(gv.singlePlayerReadyCount, 3)) + " seconds"
        for obj in self.gameObjects:
            obj.update(deltaTime)

    def draw(self):
        self.background.draw(gv.screen)
        self.text.draw(gv.screen)
        self.text2.draw(gv.screen)
        for obj in self.gameObjects:
            obj.draw(gv.screen)

    def leave(self):
        #cleanup after yourself
        for light in gv.lightsObject.lights:
            light.clearAnim()
        self.removeGameObj(gv.lightsObject)
        pass
Esempio n. 10
0
	def __init__(self):
		self.background = Image("background_timeout", "assets/images/quickdraw_timeout.jpg", 0,0, True )
Esempio n. 11
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))