Ejemplo n.º 1
0
 def renderSelf(self, time, renderer, xMin, yMin):
     if (self.xPos + self.width - xMin <
             0) or (self.yPos + self.height - yMin < 0):
         return
     elif (self.xPos > xMin + 800) or (self.yPos > yMin + 600):
         return
     if self.title is 'pizza' or self.title is 'heart' or self.title is 'carrot' or self.title is 'bombObject':
         time1 = ((int(time / 250)) % 4)  #slowish
         spriteFrame = sdl.Rect((time1 * 50, 0, 50, 50))
         sdl.renderCopy(renderer, self.texture, spriteFrame,
                        self.getRect(xMin, yMin))
     elif self.title is 'explosion':
         time1 = ((int(time / 250)) % 8)
         if time1 is not self.currentTime:
             self.currentFrame += 1
             spriteFrame = sdl.Rect((self.currentFrame * 200, 0, 200, 200))
             sdl.renderCopy(renderer, self.texture, spriteFrame,
                            self.getRect(xMin, yMin))
             if self.currentFrame is 8:
                 self.used = True
             self.currentTime = time1
         else:
             spriteFrame = sdl.Rect((self.currentFrame * 200, 0, 200, 200))
             sdl.renderCopy(renderer, self.texture, spriteFrame,
                            self.getRect(xMin, yMin))
     elif self.title is 'blackScreen':
         self.updateAlpha(1)
         sdl.setTextureAlphaMod(self.texture, int(self.alpha))
         sdl.renderCopy(renderer, self.texture, None,
                        self.getRect(xMin, yMin))
     else:
         sdl.renderCopy(renderer, self.texture, None,
                        self.getRect(xMin, yMin))
Ejemplo n.º 2
0
    def renderLight(self, renderer, xMin, yMin):
        mod = 1
        texture = driver.lightTextures[7]  # default red
        if self.attacking is 1:
            texture = driver.lightTextures[6]  # change to green
            sdl.setTextureAlphaMod(texture, 64)
            mod = 10
        elif self.attacking is 2:
            texture = driver.lightTextures[3]  # change to orange
            sdl.setTextureAlphaMod(texture, 64)
        elif self.attacking is 3:
            texture = driver.lightTextures[4]  # change to purple
            sdl.setTextureAlphaMod(texture, 64)
        if self.hurt:
            texture = driver.lightTextures[5]  # change to blue
            sdl.setTextureAlphaMod(texture, 64)
        if self.dying:
            color = (self.currentFrame % 5) + 3
            texture = driver.lightTextures[
                color]  # change to self.currentFrame % len(driver.lightTextures)
            sdl.setTextureAlphaMod(texture, 255)
            if color is 6:
                mod = 10

        textureW, textureH = chef.textureSize(texture)
        textureW *= mod
        textureH *= mod
        lightRect = sdl.Rect((0, 0, textureW, textureH))
        sdl.setTextureBlendMode(texture, sdl.BLENDMODE_ADD)

        posRect = sdl.Rect(
            (int(self.xPos) - int(xMin) + int(self.width / 2) -
             int(textureW / 2), int(self.yPos) - int(yMin) +
             int(self.height / 2) - int(textureH / 2), textureW, textureH))
        sdl.renderCopy(renderer, texture, lightRect, posRect)
Ejemplo n.º 3
0
	def run(self):
		running = True
		count = 0
		event = sdl.Event()
		#if self.num is 7:
		while running:
			sdl.renderClear(driver.renderer)
			sdl.renderCopy(driver.renderer, self.textures[count], None, textureRect)

			if count ==  0 and self.num is 7:
				self.updateAlpha()
				sdl.setTextureAlphaMod(blackScreen, int(self.alpha))
				sdl.renderCopy(driver.renderer, blackScreen, None, textureRect)

			while sdl.pollEvent(event):
				if event.type == sdl.QUIT:
				 	running = False
				 	game.turnOff()
				elif event.type == sdl.MOUSEBUTTONDOWN: count += 1
				elif event.type == sdl.KEYUP:
					if event.key.keysym.sym in [sdl.K_q, sdl.K_ESCAPE]:
						running = False
						game.turnOff()
					elif event.key.keysym.sym == sdl.K_RETURN:  count += 100
					elif (count < self.length - 1 or self.num is 2 or self.num is 4 or self.num is 6 or self.num is 7) and event.key.keysym.sym == sdl.K_SPACE: count += 1

			if count > self.length - 1:
				running = False
			sdl.renderPresent(driver.renderer)
Ejemplo n.º 4
0
 def renderLight(self, renderer, xMin, yMin):
     if 'carrot' in driver.chef.items:
         textureW, textureH = chef.textureSize(driver.lightTextures[0])
         lightRect = sdl.Rect((0, 0, textureW, textureH))
         sdl.setTextureBlendMode(driver.lightTextures[0], sdl.BLENDMODE_ADD)
         sdl.setTextureAlphaMod(driver.lightTextures[0], 128)
         posRect = sdl.Rect(
             (int(self.xPos) - int(xMin) + int(self.width / 2) -
              int(textureW / 2), int(self.yPos) - int(yMin) +
              int(self.height / 2) - int(textureH / 2), textureW, textureH))
         sdl.renderCopy(renderer, driver.lightTextures[0], lightRect,
                        posRect)
Ejemplo n.º 5
0
    def run(self):
        running = True
        currentTime = 0
        lastTime = 0
        time = 0

        event = sdl.Event()
        textureW, textureH = game.textureSize(full)
        textureRect = game.centeredRect(game.width, game.height, textureW,
                                        textureH)
        sdl.setTextureBlendMode(full, sdl.BLENDMODE_ADD)

        while running:
            currentTime = sdl.getTicks()
            dt = currentTime - lastTime
            time += dt
            lastTime = currentTime

            if time <= 3000:
                sdl.renderClear(driver.renderer)
                alpha = int(round((time / 3000.0) * 255))
                if alpha > 255:
                    time += 3000
                    alpha = 255
                sdl.renderCopy(driver.renderer, fade, None, textureRect)
                sdl.setTextureAlphaMod(full, alpha)
                sdl.renderCopy(driver.renderer, full, None, textureRect)
                while sdl.pollEvent(event):
                    if event.type == sdl.KEYDOWN:
                        time += 3000
                    elif event.type == sdl.MOUSEBUTTONDOWN:
                        time += 3000
                    if event.key.keysym.sym in [sdl.K_q, sdl.K_ESCAPE]:
                        running = False
                        game.turnOff()
            else:
                sdl.renderCopy(driver.renderer, fade, None, textureRect)
                sdl.renderCopy(driver.renderer, full, None, textureRect)
                while sdl.pollEvent(event):
                    if event.type == sdl.MOUSEBUTTONDOWN:
                        running = False
                        self.next = "menu"
                    if event.type == sdl.KEYDOWN:
                        if event.key.keysym.sym in [sdl.K_q, sdl.K_ESCAPE]:
                            running = False
                            game.turnOff()
                        else:
                            running = False
                            self.next = "menu"
            sdl.renderPresent(driver.renderer)
Ejemplo n.º 6
0
 def renderLight(self, renderer, xMin, yMin):
     if (self.identity is "redPipe" or self.identity is "bluePipe"
         ) and self.used is False and 'carrot' in driver.chef.items:
         if self.identity is "redPipe":
             texture = driver.lightTextures[7]
         else:
             texture = driver.lightTextures[5]
         textureW = 100
         textureH = 100
         sdl.setTextureBlendMode(texture, sdl.BLENDMODE_ADD)
         sdl.setTextureAlphaMod(texture, 128)
         xP = int(self.xPos * 50) - int(xMin) + 25 - int(textureW / 2)
         yP = int(self.yPos * 50) - int(yMin) + 25 - int(textureH / 2)
         posRect = sdl.Rect((xP, yP, textureW, textureH))
         sdl.renderCopy(renderer, texture, None, posRect)
     else:
         return
Ejemplo n.º 7
0
    def run(self):
        running = True
        currentTime = 0
        lastTime = 0
        time = 0
        pressed = False

        event = sdl.Event()

        while running:
            currentTime = sdl.getTicks()
            dt = currentTime - lastTime
            time += dt
            lastTime = currentTime

            textureW, textureH = game.textureSize(winTexture)
            goRect = game.centeredRect(game.width, game.height, textureW,
                                       textureH)

            if time <= 3000:
                sdl.renderClear(driver.renderer)
                alpha = int(round((time / 3000.0) * 255))
                sdl.setTextureAlphaMod(winTexture, alpha)
                sdl.renderCopy(driver.renderer, winTexture, None, goRect)
                while sdl.pollEvent(event):
                    if event.type == sdl.KEYDOWN:
                        time += 3000
                    if event.key.keysym.sym in [sdl.K_q, sdl.K_ESCAPE]:
                        running = False
                        game.turnOff()
            else:
                sdl.renderClear(driver.renderer)
                sdl.renderCopy(driver.renderer, winTexture, None, goRect)
                while sdl.pollEvent(event):
                    if event.type == sdl.KEYDOWN:
                        if event.key.keysym.sym in [sdl.K_q, sdl.K_ESCAPE]:
                            running = False
                            game.turnOff()
                        elif event.key.keysym.sym in [
                                sdl.K_SPACE, sdl.K_RETURN
                        ]:
                            running = False
                            self.next = "highScore"
            sdl.renderPresent(driver.renderer)
    def renderLight(self, renderer, xMin, yMin):
        # textureW, textureH = chef.textureSize(driver.lightTextures[1])
        # lightRect = sdl.Rect((0, 0, textureW, textureH))
        # sdl.setTextureBlendMode(driver.lightTextures[1], sdl.BLENDMODE_ADD)
        # sdl.setTextureAlphaMod(driver.lightTextures[1], 128)
        # posRect = sdl.Rect((int(self.xPos) - int(xMin) + int(self.width/2) - int(textureW/2) ,int(self.yPos) - int(yMin) + int(self.height/2) - int(textureH/2), textureW, textureH))
        # sdl.renderCopy(renderer, driver.lightTextures[1], lightRect, posRect)

        mod = 1
        texture = driver.lightTextures[5]  # default blue
        if self.hurt:
            texture = driver.lightTextures[7]  # change to red
            sdl.setTextureAlphaMod(texture, 255)
        elif self.summoning:
            texture = driver.lightTextures[6]  # change to green
            sdl.setTextureAlphaMod(texture, 64)
            mod = 10
        elif self.transforming:
            texture = driver.lightTextures[3]  # change to orange
            sdl.setTextureAlphaMod(texture, 64)
        elif self.transformed:
            texture = driver.lightTextures[7]  # change to red
            sdl.setTextureAlphaMod(texture, 64)

        if self.dying:
            color = (self.currentFrame % 5) + 3
            texture = driver.lightTextures[color]
            sdl.setTextureAlphaMod(texture, 255)
            if color is 6:
                mod = 10

        textureW, textureH = chef.textureSize(texture)
        textureW *= mod
        textureH *= mod
        lightRect = sdl.Rect((0, 0, textureW, textureH))
        sdl.setTextureBlendMode(texture, sdl.BLENDMODE_ADD)

        posRect = sdl.Rect(
            (int(self.xPos) - int(xMin) + int(self.width / 2) -
             int(textureW / 2), int(self.yPos) - int(yMin) +
             int(self.height / 2) - int(textureH / 2), textureW, textureH))
        sdl.renderCopy(renderer, texture, lightRect, posRect)
Ejemplo n.º 9
0
 def renderLight(self, renderer, xMin, yMin):
     texture = driver.lightTextures[7]
     modX = 1
     modY = 1
     if self.title is 'green':
         texture = driver.lightTextures[6]  # change to green
     elif self.title is 'purple':
         texture = driver.lightTextures[4]  # change to purple
         modX = 1
         modY = 1
     elif self.title is 'knife':
         texture = driver.lightTextures[1]  # change to green
         return
     textureW, textureH = chef.textureSize(texture)
     textureW = textureW / modX
     textureH = textureH / modY
     lightRect = sdl.Rect((0, 0, int(textureW), int(textureH)))
     sdl.setTextureBlendMode(texture, sdl.BLENDMODE_ADD)
     sdl.setTextureAlphaMod(texture, 128)
     posRect = sdl.Rect((int(self.xPos) - int(xMin) + int(self.width / 2) -
                         int(textureW / 2), int(self.yPos) - int(yMin) +
                         int(self.height / 2) - int(textureH / 2),
                         int(textureW), int(textureH)))
     sdl.renderCopy(renderer, texture, None, posRect)