Esempio n. 1
0
 def player_die(self,dying_of=""):
     sounds.play("pain")
     self.set_mode("dying")
     self.player.die()
     self.dying_of = dying_of
     self.dying_time = 3000
     lighting.light_colour(self.light,(0,0,0,0),self.dying_time)
Esempio n. 2
0
    def on_mouse_release(self, x, y, button, modifiers):
        if self.level_help:
            self.hide_help()
            return

        self.mouse_pos = (x, y)
        self.update_mouse()

        mpos = self.mouse_pos_grid.xy
        grid = self.game_session.game.grid
        block = grid.get(mpos)

        if block and block.locked and not self.editor_mode:
            self.camera.shake(0.1)
            sounds.play('noway.wav')
            return

        try:
            if button == mouse.LEFT:
                tool = self.tool
            if button == mouse.RIGHT or (button == mouse.LEFT and modifiers & key.MOD_SHIFT):
                tool = self.alt_tool

            if tool.apply(mpos, self.game_session.game, self.editor_mode):
                self.renderer.mark_dirty(mpos)

        except Exception as e:
            self.camera.shake(0.2)
            sounds.play('noway.wav')

        self.update_inventory()
Esempio n. 3
0
 def step_balls(self,ms):
     ms = min(ms,27.0) # avoid collision glitches when fps is low
     player = self.player
     dying = (self.mode == "dying")
     pr = player.getgeom('radius',0.49)
     ppos = player.pos
     for ball in self["balls"].contents:
         v = ball.velocity * ms
         bx,by,bz = pos = ball.pos
         newpos = v + pos
         r = ball.getgeom('radius',0.2)
         obstacles = self.level.obstacles_near(bx,by)
         for hc,hr,cell in obstacles:
             P = collision.collides(hc,hr,pos,r,v,collision.COLLIDE_REBOUND)
             if P:
                 newpos, bv_times_ms = P
                 vel = bv_times_ms * (1/ms)
                 if ball.maxdestroy > 0 and not dying:
                     points = self.hexfield.destroy(hc,hr)
                     if points:
                         sounds.play(points[1])
                         ball.maxdestroy -= 1
                         ball.duration -= 1000
                         self.inc_score(points[0])
                         if not ball.bounces:
                             vel = ball.velocity
                         else:
                             vel *= 0.95
                 ball.velocity = vel
                 break
         ball.pos = newpos
         if (ball.lethal
             and not dying 
             and (ball.pos - ppos).length() < (r + pr)):
             self.player_die("{0} trauma".format(ball.__class__.__name__.lower()))
Esempio n. 4
0
 def act(self, ball):
     ball.direction = (
         -ball.direction[0],
         -ball.direction[1],
     )
     sounds.play('wall.wav')
     return True
 def on_collision(self,what,where,direction):
     """ On collision with a ball, die"""
     if isinstance(what,graphics.Ball):
         self._expired = True
         sounds.play("squelch")
     else:
         self.turn_to(direction)
         self.pos = where
Esempio n. 6
0
    def play(self):
#        print "Playing sound " + str(self.snd)
        try:
            sounds.play(self.snd)
        except Exception, inst:
            print "Error, cant play sound "
            print type(inst)     # the exception instance
            print inst.args      # arguments stored in .args
            print inst           # __str__ allows args to printed directly
Esempio n. 7
0
    def die(self):
        if self.status != "death":
            self.status = 'death'
            sounds.play("sfx/hurt.wav")
    #        self.set_animation()

            self.char.remove(self.sprite)
            self.char.add(Sprite(pyglet.image.Animation.from_image_sequence(self.images['death'], 0.05, False)))

            self.char.do(JumpBy(height=150,jumps=3,duration=2) + CallFunc(self.parent.char_die))
 def on_collision(self,what,where,direction):
     if isinstance(what,graphics.Ball):
         self.harm_type = "provoked a"
         sounds.play("roar")
         self.hunt(what,where)
     elif isinstance(what,graphics.Player):
         self.eat(what,direction)
         sounds.play("munch")
     else:
         self.turn_to(direction)
         self.pos = where
Esempio n. 9
0
    def tick(self):
        if not self.level_help:
            self.time += 1

        if self.time == 1 and not self.editor_mode:
            self.charge_player = sounds.play('charge.wav')

        new_status = self.game_session.get_status()
        if self.game_status == core.Game.STATUS_ON and new_status == core.Game.STATUS_DEFEAT:
            self.camera.shake(1)
            sounds.play('boom.wav', 0.4)
        self.game_status = new_status

        if not self.editor_mode:
            if new_status == core.Game.STATUS_VICTORY or self.skip_level:
                next_level_name = self.level_name if self.editor_mode else self.get_next_level_name()
                if next_level_name:
                    self.control.switch_handler("game_mode", False, next_level_name)
                    return
                elif not self.game_complete:
                    self.gui.show_popup("Congrats! You completed the game!")
                    self.game_complete = True

        if not self.editor_mode and self.time > self.SLOW_START and new_status == core.Game.STATUS_NEW:
            self.game_session.start()
            self.stop_charge_player()
            sounds.play('start.wav')

        if self.time > self.next_step and new_status == core.Game.STATUS_ON:
            self.game_session.step()
            self.next_step = self.time + self.STEP_SIZE # / (self.game_session.game.speed + 1)

        cam_idx = 2 if self.keys[key.LSHIFT] or self.keys[key.RSHIFT] else 1
        cam_pos = self.camera.eye.next_value
        if self.keys[key.UP]:
            cam_pos[cam_idx] += 0.2
        if self.keys[key.DOWN]:
            cam_pos[cam_idx] -= 0.2
        if self.keys[key.LEFT]:
            cam_pos.x -= 0.2
        if self.keys[key.RIGHT]:
            cam_pos.x += 0.2

        cam_pos.x = min(20, max(-20, cam_pos.x))
        cam_pos.y = min(20, max(-20, cam_pos.y))
        cam_pos.z = min(40, max(5, cam_pos.z))

        self.camera.tick()
        self.renderer.tick()
Esempio n. 10
0
 def on_collision(self,what,where,direction):
     """ On collision with a ball, pick a random
     direction and speed"""
     if isinstance(what,graphics.Ball):
         r = self.velocity.length()
         if r < 0.001 or r > 0.04:
             r = 0.01
         r *= random.gauss(1.0,0.05)
         self.angle = random.random() * 360
         a = radians(self.angle)
         self.velocity = Vec(cos(a),sin(a)) * r
         sounds.play("chime")
     else:
         self.turn_to(direction)
     self.pos = where
Esempio n. 11
0
    def fire(self):
        if self.wait_time_to_shoot > 0.:
            return

        min_time_between_shots = 1. / self.stats.bullets_per_second

        self.wait_time_to_shoot = min_time_between_shots

        bullet_anim = config.atlas.load_static("player_bullet")
        r = pygame.Rect(0, 0, bullet_anim.width, bullet_anim.height)
        r.top = self.rect.top
        r.centerx = self.rect.centerx

        bullet = Bullet(self.stats.player_bullet, r.center, bullet_anim)

        self.bullet_manager.add(bullet)
        sounds.play("laser1")
Esempio n. 12
0
    def update(self, x, y, mx, my, start, drop, grab):
        if drop:
            if self.active:
                self.active = False
                self.x -= self.shift
                self.iconRect = self.startingIconRect.move(self.x, self.y)
                self.rect = self.clearRect
        if grab:
            if not self.active:
                self.active = True
                self.iconRect = self.clearRect
        if self.active:
            self.x = x - self.shift + self.SpearShift / 2
            self.y = y - self.shift + self.SpearShift * 1.5
            dx, dy = mx - x, my - y - self.SpearShift
            self.angle = math.degrees(math.atan2(dx, dy)) - 135

            if start and not self.attacking and not self.cooldown:
                sounds.play('SpearThrow', self.volume)
                self.attacking = True
            if self.attacking and not self.retracting:
                self.currentFrame += 1
                if self.currentFrame == self.numFrames - 1:
                    self.retracting = True
            elif self.retracting:
                self.currentFrame -= 1
                if self.currentFrame == 0:
                    self.attacking = False
                    self.retracting = False
                    self.cooldown = True
                    self.cooldownTime = self.cooldownDuration
            if self.cooldown:
                if self.cooldownTime <= 0:
                    self.cooldown = False
                else:
                    self.cooldownTime -= 1

            self.hitBoxShift = self.startingHitBoxShift * (
                8 + self.currentFrame * 1.5)
            self.rect = self.startingRect.move(
                self.x + int(
                    math.cos(math.radians(self.angle + 45)) *
                    self.hitBoxShift), self.y - int(
                        math.sin(math.radians(self.angle + 45)) *
                        self.hitBoxShift))
Esempio n. 13
0
	def update(self,x,y,mx,my,start,drop,grab):
		self.mx = mx
		if drop:
			if self.active:
				self.active = False
				self.x -= 100
				self.iconRect = self.startingIconRect.move(self.x,self.y)
				self.rect = self.clearRect
		if grab:
			if not self.active:				
				self.active = True
				self.iconRect = self.clearRect
		if self.active:			
			self.x = x - self.shift + self.RifleShift/2
			self.y = y - self.shift + self.RifleShift*1.3
			dx,dy = mx-x,my-y-self.RifleShift
			self.angle = math.degrees(math.atan2(dx,dy)) - 135
			
			if start and not self.attacking and not self.cooldown:				
				self.attacking = True					
			if self.attacking and not self.retracting:				
				sounds.play('RifleShot')
				self.currentFrame += 1				
				if self.currentFrame == self.numFrames-1:
					self.retracting = True
			elif self.retracting:
				self.currentFrame -= 1
				if self.currentFrame == 0:
					self.attacking = False
					self.retracting = False
					self.cooldown = True
					self.cooldownTime = self.cooldownDuration
			if self.cooldown:
				if self.cooldownTime <= 0:
					self.cooldown = False
				else:
					self.cooldownTime -= 1
			self.hitBoxShift = self.startingHitBoxShift*(-self.endOfRifle-self.currentFrame*0.5)
			self.rect = self.startingRect.move(self.x +  int(math.cos(math.radians(self.angle+60))*self.hitBoxShift) , self.y - int(math.sin(math.radians(self.angle+60))*self.hitBoxShift))
			if self.x+self.shift-self.shift/4 > self.mx:
				self.muzzelx = self.x +  int(math.cos(math.radians(self.angle+60))*(+self.hitBoxShift/3))
				self.muzzely = self.y - int(math.sin(math.radians(self.angle+60))*(+self.hitBoxShift/3))
			else:
				self.muzzelx = self.x +  int(math.cos(math.radians(self.angle+60))*(-self.hitBoxShift))
				self.muzzely = self.y - int(math.sin(math.radians(self.angle+60))*(-self.hitBoxShift))
Esempio n. 14
0
    def pick_up(self):
        if self.wait > 0:
            return

        cell = self.level[self.x, self.y]

        if not cell.item:
            raise NothingHere()

        item = cell.item
        self.inventory.add(item)
        cell.item = None

        if item.name in self.quest.goals:
            sounds.play('goal')
        else:
            sounds.play('pick')

        self.update_quest_status()
Esempio n. 15
0
    def _create_alien_explosion(self, alien, as_points=False):
        """Create an alien explosion located where this alien is"""
        if not as_points:
            explosion_animation = config.atlas.load_animation(alien.alien_stats.sprite_name + "_explosion")
            explosion = OneShotAnimation.from_animation(explosion_animation)
        else:
            score_str = "{:,}".format(alien.alien_stats.points)
            surf = self.font.render(score_str, True, config.green_color)
            explosion = OneShotAnimation(surf, 0.5)

        # a little closure to automatically remove explosion when it's done running
        def die_on_finish():
            self.explosions.remove(explosion)

        explosion.on_complete = die_on_finish
        explosion.rect.center = alien.rect.center

        self.explosions.add(explosion)
        sounds.play("explosion1.wav")
Esempio n. 16
0
 def on_collision(self,what,where,direction):
     if isinstance(what,graphics.Ball):
         self.hunt(what,where,1.1)
         self.harm_type = "provoked a"
         sounds.play("roar")
         self.enrage()
     elif isinstance(what,graphics.Player):
         self.eat(what,direction)
         sounds.play("munch")
     else:
         self.turn_to(direction)
         self.pos = where
         self.rage -= 1
         if self.rage <= 0:
             self.hiding = True
             x,y,_ = where
             hc,hr = collision.nearest_neighbours(x,y,0).next()
             self.pos = collision.h_centre(hc,hr)
             self.velocity = Vec(0,0,0)
             self.prepare()
Esempio n. 17
0
    def __init__(self,name="",level=None,levelnum=1,score=0,
                 ammo=0,special=None, **kw):
        if not level:
            level = self.find_level(levelnum)
        self.level = level
        self.levelnum = levelnum
        self.score = score
        self.light = lighting.claim_light()
        stylesheet.load(monsters.MonsterStyles)
        stylesheet.load(graphics.BallStyles)
        if level.music:
            self.music = level.music
        self.special_ammo = ammo
        self.special_ball = special
        super(GameScreen,self).__init__(name,**kw)
        self.set_mode("story" if self.story_page is not None
                      else "playing")
        Sin60 = collision.Sin60
        self.movekeys = {
            # Gamer keys
            pygletkey.A: Vec(-1,0),
            pygletkey.D: Vec(1,0),
            pygletkey.W: Vec(0,1),
            pygletkey.S: Vec(0,-1),

            # Hexagon around J
            pygletkey.H: Vec(-1,0),
            pygletkey.U: Vec(-0.5,Sin60),
            pygletkey.I: Vec(0.5,Sin60),
            pygletkey.K: Vec(1,0),
            pygletkey.M: Vec(0.5,-Sin60),
            pygletkey.N: Vec(-0.5,-Sin60),
            }
        self.keysdown = set()
        self.first_person = False
        vport = (GLint*4)()
        glGetIntegerv(GL_VIEWPORT, vport)
        self.vport = tuple(vport)
        self.reload = 0
        sounds.play(self.level.sound)
Esempio n. 18
0
	def update(self,x,y,mx,my,start,drop,grab):
		if drop:
			if self.active:
				self.active = False
				self.x -= self.shift
				self.iconRect = self.startingIconRect.move(self.x,self.y)
				self.rect = self.clearRect
		if grab:
			if not self.active:
				self.active = True
				self.iconRect = self.clearRect
		if self.active:
			self.x = x - self.shift + self.SpearShift/2
			self.y = y - self.shift + self.SpearShift*1.5
			dx,dy = mx-x,my-y-self.SpearShift
			self.angle = math.degrees(math.atan2(dx,dy)) - 135
			
			if start and not self.attacking and not self.cooldown:
				sounds.play('SpearThrow',self.volume)
				self.attacking = True
			if self.attacking and not self.retracting:
				self.currentFrame += 1
				if self.currentFrame == self.numFrames-1:
					self.retracting = True
			elif self.retracting:
				self.currentFrame -= 1
				if self.currentFrame == 0:
					self.attacking = False
					self.retracting = False
					self.cooldown = True
					self.cooldownTime = self.cooldownDuration
			if self.cooldown:
				if self.cooldownTime <= 0:
					self.cooldown = False
				else:
					self.cooldownTime -= 1
					
			self.hitBoxShift = self.startingHitBoxShift*(8+self.currentFrame*1.5)
			self.rect = self.startingRect.move(self.x +  int(math.cos(math.radians(self.angle+45))*self.hitBoxShift) , self.y - int(math.sin(math.radians(self.angle+45))*self.hitBoxShift))
Esempio n. 19
0
    def _set_selected(self, idx):
        while idx < 0:
            idx += len(self.options.sprites())

        idx = idx % len(self.options.sprites())

        if hasattr(self, "selected_index") and idx != self.selected_index:
            sounds.play("select")

        self.selected_index = idx

        # align selectors to current option
        for selector in self.selectors.sprites():
            option_rect = self.options.sprites()[idx].rect

            selector.rect.centery = option_rect.centery

            if selector.rect.x < config.screen_width // 2:
                # must be left selector
                selector.rect.right = option_rect.left - 6
            else:
                # right selector
                selector.rect.left = option_rect.right + 6
Esempio n. 20
0
	def update(self,x,y,mx,my,start,drop,grab):
		self.mx = mx
		if drop:
			if self.active:
				self.active = False
				self.x -= 100
				self.iconRect = self.startingIconRect.move(self.x,self.y)
				self.rect = self.clearRect
		if grab:
			if not self.active:				
				self.active = True
				self.iconRect = self.clearRect
		if self.active:			
			self.x = x - self.shift + self.RifleShift/2
			self.y = y - self.shift + self.RifleShift*1.3
			dx,dy = mx-x,my-y-self.RifleShift
			self.angle = math.degrees(math.atan2(dx,dy)) - 135
			
			if start and not self.attacking and not self.cooldown:				
				self.attacking = True
				if self.endOfRifle == 3:
					sounds.play('RifleShot',self.volume)
				elif self.endOfRifle == 2:
					sounds.play('ShotgunShot',self.volume)
			if self.attacking and not self.retracting:				
				self.currentFrame += 1				
				if self.currentFrame == self.numFrames-1:
					self.retracting = True
			elif self.retracting:
				self.currentFrame -= 1
				if self.currentFrame == 0:
					self.attacking = False
					self.retracting = False
					self.cooldown = True
					self.cooldownTime = self.cooldownDuration
			if self.cooldown:
				if self.cooldownTime == 13:
					if self.endOfRifle == 2:
						sounds.play('ShotgunPump',self.volume)
				if self.cooldownTime <= 0:
					self.cooldown = False
				else:
					self.cooldownTime -= 1
			self.hitBoxShift = self.startingHitBoxShift*(-self.endOfRifle-self.currentFrame*0.5)
			self.rect = self.startingRect.move(self.x +  int(math.cos(math.radians(self.angle+60))*self.hitBoxShift) , self.y - int(math.sin(math.radians(self.angle+60))*self.hitBoxShift))
			if self.x+self.shift-self.shift/4 > self.mx:
				self.muzzelx = self.x +  int(math.cos(math.radians(self.angle+60))*(+self.hitBoxShift/3))
				self.muzzely = self.y - int(math.sin(math.radians(self.angle+60))*(+self.hitBoxShift/3))
			else:
				self.muzzelx = self.x +  int(math.cos(math.radians(self.angle+60))*(-self.hitBoxShift))
				self.muzzely = self.y - int(math.sin(math.radians(self.angle+60))*(-self.hitBoxShift))
Esempio n. 21
0
 def on_collision(self,what,where,direction):
     if isinstance(what,graphics.Ball):
         self.harm_type = "provoked the"
         sounds.play("rumble")
         self.hunt(what,where,0.9)
     elif isinstance(what,graphics.Player):
         self.eat(what,direction)
         sounds.play("bellow")
     else:
         r = self.velocity.length()
         to_player = Vec(self.player.pos) - self.pos
         if to_player.dot(direction) > 0:
             # facing towards player...
             direction = to_player.normalise() * r
             if random.random < 0.2:
                 sounds.play("rumble")
         self.pos = where
         self.turn_to(direction)
Esempio n. 22
0
import time

import pygame
pygame.mixer.pre_init(44100, -16, 1,
                      512)  # must be called before pygame.init!!!
pygame.init()
import sounds
sounds = sounds.Sounds()

import hardware
hardware = hardware.Hardware()

hardware.setWeaponCharacteristics(playerid=123, damage=42, laser_duration=1)
while True:
    if hardware.isWeaponButtonDown(0):
        sounds.play('pew', False)
        hardware.shootWeapon(laser0=1, laser1=0)
        time.sleep(0.3)
    time.sleep(0.005)
Esempio n. 23
0
 def jump_down(self):
     jump_to_y = self.grid_y_to_y(self.char_jump_block()+1)
     self.jump_to(jump_to_y)
     self.facing = "up"
     sounds.play("sfx/jump.wav")
Esempio n. 24
0
 def jump_up(self):
     jump_to_y = self.grid_y_to_y(self.char_jump_block() - 2)
     self.jump_to(jump_to_y)
     self.facing = "down"
     sounds.play("sfx/jump.wav")
Esempio n. 25
0
 def act(self, ball):
     super(FlipFlopMirror, self).act(ball)
     self.cycle_states()
     sounds.play('mirror.wav')
Esempio n. 26
0
 def jump_down(self):
     jump_to_y = self.grid_y_to_y(self.char_jump_block() + 1)
     self.jump_to(jump_to_y)
     self.facing = "up"
     sounds.play("sfx/jump.wav")
Esempio n. 27
0
 def affect(self, player):
     sounds.play('fall')
     player.freeze(self.delay)
Esempio n. 28
0
 def on_use(self):
     sounds.play('dig')
Esempio n. 29
0
 def act(self, ball):
     if self.is_on:
         ball.status = Ball.STATUS_LEFT
         sounds.play('victory.wav')
Esempio n. 30
0
 def act(self, ball):
     self.is_on = not self.is_on
     if self.is_on:
         sounds.play('flip-on.wav')
     else:
         sounds.play('flip-off.wav')
Esempio n. 31
0
 def act(self, ball):
     ball.direction = (
         ball.direction[1] * self.slope,
         ball.direction[0] * self.slope,
     )
     sounds.play('mirror.wav')
Esempio n. 32
0
 def act(self, ball):
     sounds.play('mirror.wav')
     ball.direction = self.direction
Esempio n. 33
0
 def begin(self):
     super().begin()
     sounds.play('exp', -1)
     self.bind_keys((p.K_RETURN, p.K_SPACE), self.handle_event)
     self.bind_click((1, ), self.handle_event)
Esempio n. 34
0
 def safe_call(self, func, *args, **kwargs):
     try:
         return func(*args, **kwargs)
     except player.InventoryError as err:
         sounds.play('err')
         print err.__doc__
Esempio n. 35
0
def broken_screen(unit):
    sounds.play('broke')
    room.run_room(
        gui.Label("%s is broken" % unit.weapon.name, f.SMALL, txt_color=c.RED))
Esempio n. 36
0
def main():
	yolo = 0
	##various variables that don't reset every frame
	filenames = os.path.join( s.mapsFolder, "level*.txt" ) #put all the level text files in one list
	maps = glob.glob(filenames)
	maps.sort()
	level = s.startingLevel
	# levelChanged = True
	blocks = []
	peds = []
	#pedCount,pedWeapons = map1(blocks,peds)
	
	pedCount,pedWeapons = levelGen(blocks,peds,maps[level])
	world_x , world_y = user.x,user.y
	world_dx, world_dy = 50*scalar,50*scalar
	fps = s.fps
	weaponEquipped = False
	ridingHor = False
	ridingHorDirection = 1
	ridingVer = False
	ridingVerDirection = 1
	bullets = []
	pedBullets = []
	pelletsList = []
	pedPelletsList = []
	deletePedBulletsList = []
	deletePedPelletsList = []
	volume = s.volume
	
	sounds.loop('Background',s)
	#sounds.play('',volume)	
	
	while True:		
		clock.tick(fps)
		yolo += 1
		
		##resetting variables
		skipLevel = False
		damage = 0
		damages = []
		pedHeadCollisions,pedChestCollisions,pedFeetCollisions,pedTopCollisions = [],[],[],[]
		for p in range(pedCount):
			damages.append(0)
			pedHeadCollisions.append(0)
			pedChestCollisions.append(0)
			pedFeetCollisions.append(0)
			pedTopCollisions.append(0)
		world.fill((0,0,0))
		headCollisions,chestCollisions,feetCollisions,topCollisions = 0,0,0,0
		world_x = -user.x + 100*scalar
		world_y = -user.y + 220*scalar
		message = None
		drop = False
		grabbing = False
		grabSword = False
		drawSword = True
		grabSpear = False
		drawSpear = True
		grabRifle = False
		drawRifle = True
		grabShotGun = False
		drawShotGun = True
		pDamage,pCollisions = 0,0
		
		##slow event getter, for one click events
		for event in pygame.event.get():
			if event.type == pygame.QUIT:
				sys.exit()
			elif event.type == KEYDOWN and event.key == K_ESCAPE:
				sys.exit()
			elif event.type == KEYDOWN and event.key == K_p:
				timestamp = time.localtime()[3:6] #get the current hour, min, sec
				filename = os.path.join('screenshots', 'screenshot'+str(timestamp[0])+str(timestamp[1])+str(timestamp[2])+'.jpg')
				pygame.image.save(screen, filename) #take screenshot and name it after the current time
				message = font.render("Screenshot Taken!", 1, (255,255,255))
			elif event.type == KEYDOWN and event.key == K_q:
				drop = True
			elif event.type == KEYDOWN and event.key == K_j:
				skipLevel = True
				# print "weapons:",len(pedWeapons)
				# print "peds:",len(peds)
				#for w in pedWeapons:
				#	print w.type
			
		##constant  key logger, for "holding" keys
		pressed = pygame.key.get_pressed() #place the state of every key into a list
		# if pressed[K_w]:
			# up = True
		# else:
			# up = False
		# if pressed[K_s]:
			# down = True
		# else:
			# down = False
		if pressed[K_d]:
			right = True
		else:
			right = False
		if pressed[K_a]:
			left = True
		else:
			left = False
		if pressed[K_SPACE]:
			jump = True
		else:
			jump = False
		# if pressed[K_UP]:
			# world_y += world_dy
		# if pressed[K_DOWN]:
			# world_y -= world_dy
		# if pressed[K_LEFT]:
			# world_x += world_dx
		# if pressed[K_RIGHT]:
			# world_x -= world_dx
		# if pressed[K_j]:
			# skipLevel = True
		# else:
			# skipLevel = False
		if pressed[K_g]:
			fps = s.slowMoFPS
		else:
			fps = s.fps
	
		##boundries
		if world_x > 0:
			world_x = 0
		if world_x < -(world_width-width):
			world_x = -(world_width-width)

		if world_y > 0:
			world_y = 0
		if world_y < -(world_height-height):
			world_y = -(world_height-height)
		
		##mouse tracking
		mousePos = pygame.mouse.get_pos()
		mousex = mousePos[0] - world_x
		mousey = mousePos[1] - world_y
		
		##weapon pick up
		#if the user colliides with a weapon coin and isn't holding a weapon
		#then the user picks up the weapon
		if not goldSword.active:
			if goldSword.x < user.x + 1100*scalar and goldSword.x > user.x - 300 * scalar:
				if user.feetRect.colliderect(goldSword.iconRect) or user.chestRect.colliderect(goldSword.iconRect) or user.headRect.colliderect(goldSword.iconRect):
					if not weaponEquipped and not grabbing:
						grabSword = True
						grabbing = True
			else:
				drawSword = False
				
		if not longSpear.active:
			if longSpear.x < user.x + 1100*scalar and longSpear.x > user.x - 300 * scalar:
				if user.feetRect.colliderect(longSpear.iconRect) or user.chestRect.colliderect(longSpear.iconRect) or user.headRect.colliderect(longSpear.iconRect):
					if not weaponEquipped and not grabbing:
						grabSpear = True
						grabbing = True
			else:
				drawSpear = False
				
		if not akRifle.active:
			if akRifle.x < user.x + 1100*scalar and akRifle.x > user.x - 300 * scalar:
				if user.feetRect.colliderect(akRifle.iconRect) or user.chestRect.colliderect(akRifle.iconRect) or user.headRect.colliderect(akRifle.iconRect):
					if not weaponEquipped and not grabbing:
						grabRifle = True
						grabbing = True
			else:
				drawRifle = False
		
		if not shotGun.active:
			if shotGun.x < user.x + 1100*scalar and shotGun.x > user.x - 300 * scalar:
				if user.feetRect.colliderect(shotGun.iconRect) or user.chestRect.colliderect(shotGun.iconRect) or user.headRect.colliderect(shotGun.iconRect):
					if not weaponEquipped and not grabbing:
						grabShotGun = True
						grabbing = True
			else:
				drawShotGun = False
		
		##draw user
		user.draw(world)
		
		##draw the peds and their weapons
		pNum = -1
		for p in peds:
			pNum+=1
			if (p.x < user.x + 1100*scalar and p.x > user.x -300 * scalar) and (p.y < user.y + 580*scalar and p.y > user.y - 580 * scalar):
			#if p.x < user.x + 1100*scalar and p.x > user.x - 300 * scalar:
				p.draw(world)
				pedWeapons[pNum].draw(world)
		
		##hold out fist if the user is unarmed
		if weaponEquipped:
			fist.active = False
		else:
			fist.active = True
		fist.update(user.x,user.y,mousex,mousey,pygame.mouse.get_pressed()[0])
		if not goldSword.active and not longSpear.active and not akRifle.active and not shotGun.active:
			fist.draw(world)
			weaponEquipped = False
		else:
			weaponEquipped = True
		
		##draw weapons
		if drawSword:
			goldSword.update(user.x,user.y,mousex,mousey,pygame.mouse.get_pressed()[0],drop,grabSword)
			goldSword.draw(world)
		
		if drawSpear:
			longSpear.update(user.x,user.y,mousex,mousey,pygame.mouse.get_pressed()[0],drop,grabSpear)
			longSpear.draw(world)
			
		if drawRifle:
			akRifle.update(user.x,user.y,mousex,mousey,pygame.mouse.get_pressed()[0],drop,grabRifle)
			if akRifle.currentFrame == 1 and not akRifle.retracting:
				bullets.append(bullet.Bullet(rifleBulletFrames,akRifle.muzzelx,akRifle.muzzely,akRifle.flipped,akRifle.angle))
			for item in bullets:
				item.update(scalar)
				item.draw(world)
			akRifle.draw(world)
			
		if drawShotGun:
			shotGun.update(user.x,user.y,mousex,mousey,pygame.mouse.get_pressed()[0],drop,grabShotGun)
			if shotGun.currentFrame == 1 and not shotGun.retracting:
				pelletsList.append(pellets.Pellets(pelletFrames,pelletShellImage,shotGun.muzzelx,shotGun.muzzely,shotGun.flipped,shotGun.angle))
			for item in pelletsList:
				item.update(scalar)
				item.draw(world)
			shotGun.draw(world)
		
		##update the mouse pointer
		testBox.update(mousePos,world_x,world_y)
		
		##block collision detection system
		#aka collision loop
		
		#detete lists are used to delete blocks after the collision loop
		deleteList = []
		deleteBulletsList = []
		deletePelletsList = []
		
		#loop through every block in the map
		for block in blocks:
			#variables for the current block
			damage = 0
			collisions = 0
			if block.x < user.x + 1200*scalar and block.x > user.x - 400 * scalar: #is block in range? test
				#find collisions with the portal
				if block.rect.colliderect(portal.rect):
					pCollisions += 1
					collisions += 1
			#if block.x < user.x + 1100*scalar and block.x > user.x - 300 * scalar:
			if (block.x < user.x + 1100*scalar and block.x > user.x - 300 * scalar) and (block.y < user.y + 600*scalar and block.y > user.y - 600 * scalar): #is block in range? test
				
				#find collisions with peds
				pNum = -1
				for p in peds:
					pNum += 1
					if p.x < user.x + 1100*scalar and p.x > user.x - 300 * scalar:
						if not block.broken:
							if not block.falling and block.type != "=":
								if pedFeetCollisions[pNum] == 0:
									if not p.jumping:
										if p.feetRect.colliderect(block.rect):
											pedFeetCollisions[pNum] += 1
									else:
										if p.feetRect.move(0,sampleBlock.size/2).colliderect(block.rect):
											pedFeetCollisions[pNum] += 1
								if pedChestCollisions[pNum] == 0:
									if p.chestRect.colliderect(block.rect):
										pedChestCollisions[pNum] += 1
								if pedHeadCollisions[pNum] == 0:
									if p.headRect.colliderect(block.rect):
										pedHeadCollisions[pNum] += 1
								if pedTopCollisions[pNum] == 0:
									if p.headRect.inflate(p.headSize,0).colliderect(block.rect):
										pedTopCollisions[pNum] += 1
				
				#find collisions with user
				if not block.broken:
					if not block.falling and block.type != "=":
						if feetCollisions == 0:
							if not user.jumping:
								if user.feetRect.colliderect(block.rect):
									feetCollisions += 1
									# if (block.type == "_" or block.type == "|" or block.type == "/" or block.type == "\\"):
										# user.reset(block.x,block.y-user.chestSize*3)
									if block.type == "_" :
										ridingHor = True
										ridingVer = False
										ridingHorDirection = block.direction
									elif block.type == "|":
										ridingVer = True
										ridingHor = False
										ridingVerDirection = block.direction
									elif block.type == "/":
										ridingVer = True
										ridingHor = True
										ridingVerDirection = block.direction
										ridingHorDirection = -block.direction
									elif block.type == "\\":
										ridingVer = True
										ridingHor = True
										ridingVerDirection = block.direction
										ridingHorDirection = block.direction
									else:
										ridingHor = False
										ridingVer = False
										
							else:
								if user.feetRect.move(0,sampleBlock.size/2).colliderect(block.rect): #move the block down a bit so that it detects ground, stops the fall, then falls again... reducing the sink glitch
									feetCollisions += 1
									
						if chestCollisions == 0:
							if user.chestRect.colliderect(block.rect):
								chestCollisions += 1
						if headCollisions == 0:
							if user.headRect.colliderect(block.rect):
								headCollisions += 1
						if topCollisions == 0:
							if user.headRect.inflate(user.headSize,0).colliderect(block.rect):
								topCollisions += 1
								
					#enable for mouse destruction (used for testing)
					# if block.rect.colliderect(testBox.rect):
						# damage += 1
					
					#if the hitbox of a weapon collides with the current block 
					if goldSword.attacking:
						if block.rect.colliderect(goldSword.rect):
							damage += s.swordDmgToBlocks
						
					if longSpear.attacking:
						if block.rect.colliderect(longSpear.rect):
							damage += s.spearDmgToBlocks
						
					if fist.attacking:
						if block.rect.colliderect(fist.rect):
							damage += s.fistDmgToBlocks
					
					#hitting blocks with the back of the gun turned out to be pretty annoying, yolo
					# if akRifle.attacking: #hit with end of rifle
						# if block.rect.colliderect(akRifle.rect):
							# damage += 1
					
					# if shotGun.attacking: #hit with end of rifle
						# if block.rect.colliderect(shotGun.rect):
							# damage += 1
									
					#check if any bullet collides with the current block
					for item in bullets:
						if item.bulletActive:
							if item.bx > user.x+ 1100*scalar and item.bx < user.x - 300 * scalar:
								item.bulletActive = False
							if item.bulletRect.colliderect(block.rect):
								if block.type != "=":
									damage += s.bulletDmgToBlocks
									item.impact = True
						if item.shellActive:
							if item.shellRect.colliderect(block.rect):
								item.shellFalling = False
						if not item.shellActive:
							if not item in deleteBulletsList:
								deleteBulletsList.append(item)
								
					#check if any pellet collides with the current block
					for item in pelletsList:
						for i in range(8):
							if item.pxs[i] < user.x + 1100*scalar and item.pxs[i] > user.x - 300 * scalar:
								if item.px > user.x+ 1100*scalar and item.px < user.x - 300 * scalar:
									item.pelletActives[i] = False
								if item.pelletsActive[i]:
									if item.pelletRects[i].colliderect(block.rect):
										if block.type != "=":
											damage += s.pelletDmgToBlocks
											item.impacts[i] = True
							if item.shellActive:
								if item.shellRect.colliderect(block.rect):
									item.shellFalling = False
							if not item.shellActive:
								if not item in deletePelletsList:
									deletePelletsList.append(item)
									
					#check if any ped bullets shot the block
					for item in pedBullets:
						if item.bulletActive:
							if item.bx > user.x+ 1100*scalar or item.bx < user.x - 300 * scalar:
								item.bulletActive = False
							if item.bx < user.x + 1100*scalar and item.bx > user.x - 300 * scalar:
								if item.bulletRect.colliderect(block.rect):
									if block.type != "=":
										item.impact = True
										damage += s.pedBulletDmgToBlocks
						if not item.shellActive:
							if not item in deletePedBulletsList:
								deletePedBulletsList.append(item)	
								
					#check if any ped pellets shot the block
					for item in pedPelletsList:
						for i in range(8):
							if item.pxs[i] < user.x + 1100*scalar or item.pxs[i] > user.x - 300 * scalar:
								if item.px > user.x+ 1100*scalar and item.px < user.x - 300 * scalar:
									item.pelletActives[i] = False
								if item.pelletsActive[i]:
									if user.x < user.x + 1100*scalar and user.x > user.x - 300 * scalar:
										if item.pelletRects[i].colliderect(block.rect):
											if block.type != "=":
												item.impacts[i] = True
												damage += s.pedPelletDmgToBlocks
							if not item.shellActive:
								if not item in deletePedPelletsList:
									deletePedPelletsList.append(item)
						
					#check if the current block collides with any other block
					for otherBlock in blocks:
						if collisions >= block.limit and not (block.type == "_" or block.type == "|" or block.type == "/" or block.type == "\\"):
							break
						if otherBlock.broken:
							continue
						if (otherBlock.x < user.x + 1100*scalar + sampleBlock.size and otherBlock.x > user.x - 300*scalar - sampleBlock.size) and (otherBlock.y < user.y + 600*scalar + sampleBlock.size and otherBlock.y > user.y - 600*scalar - sampleBlock.size):
							if otherBlock is not block:
								if block.rect.colliderect(otherBlock.rect):
									collisions += 1
									if (block.type == "_" or block.type == "|" or block.type == "/" or block.type == "\\") and not (otherBlock.type == "_" or otherBlock.type == "|" or otherBlock.type == "/" or otherBlock.type == "\\"):
										block.changeDirection()
										
				else:
					block.dustSize += s.dustScaling*scalar
					block.frames[block.currentFrame] = pygame.transform.scale(loadImage(block.dust), (int(block.dustSize),int(block.dustSize)))
					if block.dustSize > block.size*s.dustClearsWhenSizeHasBeenMultipliedBy:
						deleteList.append(block)
				block.update(scalar,damage,collisions)
				block.draw(world)
			if block.rect[1] > world_height:
				deleteList.append(block)
		
		##ped damage calc
		if goldSword.attacking:
			for p in peds:
				if p.headAt < p.headLen-1:
					if goldSword.rect.colliderect(p.headRect):
						sounds.play('EnemyHit',volume)
						p.headAt+=s.swordDmgToPedsHead
				if p.chestAt < p.chestLen-1:
					if goldSword.rect.colliderect(p.chestRect):
						sounds.play('EnemyHit',volume)
						p.chestAt+=s.swordDmgToPedsChest
				if p.feetAt < p.feetLen-1:
					if goldSword.rect.colliderect(p.feetRect):
						sounds.play('EnemyHit',volume)
						p.feetAt+=s.swordDmgToPedsFeet
		if longSpear.attacking:
			for p in peds:
				if p.headAt < p.headLen-1:
					if longSpear.rect.colliderect(p.headRect):
						sounds.play('EnemyHit',volume)
						p.headAt+=s.spearDmgToPedsHead
				if p.chestAt < p.chestLen-1:
					if longSpear.rect.colliderect(p.chestRect):
						sounds.play('EnemyHit',volume)
						p.chestAt+=s.spearDmgToPedsChest
				if p.feetAt < p.feetLen-1:
					if longSpear.rect.colliderect(p.feetRect):
						sounds.play('EnemyHit',volume)
						p.feetAt+=s.spearDmgToPedsFeet
		if fist.attacking:
			for p in peds:
				if p.headAt < p.headLen-1:
					if fist.rect.colliderect(p.headRect):
						sounds.play('EnemyHit',volume)
						p.headAt+=s.fistDmgToPedsHead
				if p.chestAt < p.chestLen-1:
					if fist.rect.colliderect(p.chestRect):
						sounds.play('EnemyHit',volume)
						p.chestAt+=s.fistDmgToPedsChest
				if p.feetAt < p.feetLen-1:
					if fist.rect.colliderect(p.feetRect):
						sounds.play('EnemyHit',volume)
						p.feetAt+=s.fistDmgToPedsFeet
		if akRifle.attacking: #hit with end of rifle
			for p in peds:
				if p.headAt < p.headLen-1:
					if akRifle.rect.colliderect(p.headRect):
						sounds.play('EnemyHit',volume)
						p.headAt+=s.akRifleMeleeDmgToPedsHead
				if p.chestAt < p.chestLen-1:
					if akRifle.rect.colliderect(p.chestRect):
						sounds.play('EnemyHit',volume)
						p.chestAt+=s.akRifleMeleeDmgToPedsChest
				if p.feetAt < p.feetLen-1:
					if akRifle.rect.colliderect(p.feetRect):
						sounds.play('EnemyHit',volume)
						p.feetAt+=s.akRifleMeleeDmgToPedsFeet
		if shotGun.attacking: #hit with end of rifle
			for p in peds:
				if p.headAt < p.headLen-1:
					if shotGun.rect.colliderect(p.headRect):
						sounds.play('EnemyHit',volume)
						p.headAt+=s.shotgunMeleeDmgToPedsHead
				if p.chestAt < p.chestLen-1:
					if shotGun.rect.colliderect(p.chestRect):
						sounds.play('EnemyHit',volume)
						p.chestAt+=s.shotgunMeleeDmgToPedsChest
				if p.feetAt < p.feetLen-1:
					if shotGun.rect.colliderect(p.feetRect):
						sounds.play('EnemyHit',volume)
						p.feetAt+=s.shotgunMeleeDmgToPedsFeet
						
		#check if any bullet collides with any ped
		for item in bullets:
			if item.bulletActive:
				if item.bx > user.x+ 1100*scalar and item.bx < user.x - 300 * scalar:
					item.bulletActive = False
				for p in peds:
					if item.bx < p.x + 50*scalar and item.bx > p.x - 50 * scalar:
						if p.headAt < p.headLen-1:
							if item.bulletRect.colliderect(p.headRect):
								sounds.play('EnemyHit',volume)
								p.headAt+=s.bulletDmgToPedsHead
								item.impact = True
						if p.chestAt < p.chestLen-1:
							if item.bulletRect.colliderect(p.chestRect):
								sounds.play('EnemyHit',volume)
								p.chestAt+=s.bulletDmgToPedsChest
								item.impact = True
						if p.feetAt < p.feetLen-1:
							if item.bulletRect.colliderect(p.feetRect):
								sounds.play('EnemyHit',volume)
								p.feetAt+=s.bulletDmgToPedsFeet
								item.impact = True
				# if item.bulletRect.colliderect(block.rect):
					# damage += s.bulletDmgToBlocks
					# if block.type != "=":
						# item.impact = True
			if item.shellActive:
				if item.shellRect.colliderect(block.rect):
					item.shellFalling = False
			if not item.shellActive:
				if not item in deleteBulletsList:
					deleteBulletsList.append(item)
					
		#check if any pellet collides with any ped
		for item in pelletsList:
			for i in range(8):
				if item.pxs[i] < user.x + 1100*scalar and item.pxs[i] > user.x - 300 * scalar:
					if item.px > user.x+ 1100*scalar and item.px < user.x - 300 * scalar:
						item.pelletActives[i] = False
					if item.pelletsActive[i]:
						for p in peds:
							if p.x < user.x + 1100*scalar and p.x > user.x - 300 * scalar:
								if p.headAt < p.headLen-1:
									if item.pelletRects[i].colliderect(p.headRect):
										sounds.play('EnemyHit',volume)
										p.headAt+=s.pelletDmgToPedsHead
										item.impacts[i] = True
								if p.chestAt < p.chestLen-1:
									if item.pelletRects[i].colliderect(p.chestRect):
										sounds.play('EnemyHit',volume)
										p.chestAt+=s.pelletDmgToPedsChest
										item.impacts[i] = True
								if p.feetAt < p.feetLen-1:
									if item.pelletRects[i].colliderect(p.feetRect):
										sounds.play('EnemyHit',volume)
										p.feetAt+=s.pelletDmgToPedsFeet
										item.impacts[i] = True
				if item.shellActive:
					if item.shellRect.colliderect(block.rect):
						item.shellFalling = False
				if not item.shellActive:
					if not item in deletePelletsList:
						deletePelletsList.append(item)
		
		

		##portal
		#if the user collides with the portal
		#then bring him into the next map
		if (portal.x < user.x + 100*scalar and portal.x > user.x - 100 * scalar) or skipLevel:
			if user.headRect.colliderect(portal.rect) or user.chestRect.colliderect(portal.rect) or user.feetRect.colliderect(portal.rect) or skipLevel:
				level += 1
				if level == len(maps):
					screen.blit(font.render("You have won!", 1, (0,200,0)), (340*scalar,50*scalar))
					pygame.display.flip()
					pygame.time.wait(10000)
					sys.exit()
				else:
					pedCount,pedWeapons = levelGen(blocks,peds,maps[level])
					continue
		
		##object erasing
		for block in deleteList:
			blocks.remove(block)
			deleteList.remove(block)
			
		for item in deleteBulletsList:
			bullets.remove(item)
			deleteBulletsList.remove(item)
			
		for item in deletePedBulletsList:
			pedBullets.remove(item)
			deletePedBulletsList.remove(item)
			
		for item in deletePelletsList:
			pelletsList.remove(item)
			deletePelletsList.remove(item)
			
		for item in deletePedPelletsList:
			pedPelletsList.remove(item)
			deletePedPelletsList.remove(item)
		
		##update and draw portal
		if portal.x < user.x + 1100*scalar and portal.x > user.x - 300 * scalar:
			portal.update(scalar,pDamage,pCollisions)
			portal.draw(world)
		
		##update the user
		if ridingHor:
			user.teleport(user.x+s.horizontalPlatformSpeed*scalar*ridingHorDirection,user.y)
		if ridingVer:
			user.teleport(user.x,user.y+s.verticalPlatformSpeed*scalar*ridingVerDirection)
		user.update(jump,left,right,headCollisions,topCollisions,chestCollisions,feetCollisions)
		
		##ped AI and updating
		pNum = -1
		for p in peds:
			pNum+=1
			if (p.x < user.x + 1100*scalar and p.x > user.x -300 * scalar) and (p.y < user.y + 580*scalar and p.y > user.y - 580 * scalar):
				left,right = False,False
				#determine how they move based on their weapon type
				if pedWeapons[pNum].type == "sword":
					if user.x + s.swordPedsMinRangeFromUser*scalar < p.x:
						left = True
					if user.x + s.swordPedsMaxRangeFromUser*scalar > p.x:
						right = True
					if pedChestCollisions[pNum] > 0:
						p.jump = True
						p.jumpDuration = 5
				elif pedWeapons[pNum].type == "spear":
					if user.x + s.spearPedsMinRangeFromUser*scalar < p.x:
						left = True
					if user.x + s.spearPedsMaxRangeFromUser*scalar > p.x:
						right = True
					if pedChestCollisions[pNum] > 0:
						p.jump = True
						p.jumpDuration = 5
				elif pedWeapons[pNum].type == "sg":
					if user.x +s.shotgunPedsMinRangeFromUser*scalar < p.x:
						left = True
					if user.x + s.shotgunPedsMaxRangeFromUser*scalar > p.x:
						right = True
					if pedChestCollisions[pNum] > 0:
						p.jump = True
						p.jumpDuration = 5
				elif pedWeapons[pNum].type == "ak":
					if user.x + s.akRiflePedsMinRangeFromUser*scalar < p.x or user.x + 300*scalar < p.x:
						left = True
					if user.x + s.akRiflePedsMaxRangeFromUser*scalar > p.x or user.x + 300*scalar > p.x:
						right = True
					if pedChestCollisions[pNum] > 0:
						p.jump = True
						p.jumpDuration = s.howLongPedsKeepJumpingToTryToGetOverBlocks
				p.update(p.jump,left,right,pedHeadCollisions[pNum],pedTopCollisions[pNum],pedChestCollisions[pNum],pedFeetCollisions[pNum])
				pedWeapons[pNum].update(p.x,p.y,user.chestX,user.chestY,True,False,False)
				#fire the proper projectile(s) based on the weapon type
				if pedWeapons[pNum].currentFrame == 1 and not pedWeapons[pNum].retracting and pedWeapons[pNum].type == "ak":
					pedBullets.append(bullet.Bullet(rifleBulletFrames,pedWeapons[pNum].muzzelx,pedWeapons[pNum].muzzely,pedWeapons[pNum].flipped,pedWeapons[pNum].angle))
				if pedWeapons[pNum].currentFrame == 1 and not pedWeapons[pNum].retracting and pedWeapons[pNum].type == "sg":
					pedPelletsList.append(pellets.Pellets(pelletFrames,pelletShellImage,pedWeapons[pNum].muzzelx,pedWeapons[pNum].muzzely,pedWeapons[pNum].flipped,pedWeapons[pNum].angle))
				#erase the ped if he died or falls off the map
				if p.y > world_height or p.dead:
					peds.remove(p)
					deathSound = random.randrange(3) #play a random noise when they die
					if deathSound == 0:
						sounds.play('InsectScreech',volume)
					elif deathSound == 1:
						sounds.play('MonsterScreech',volume)
					else:
						sounds.play('AlienScream',volume)
					del pedWeapons[pNum]
		
		##update and draw projectiles
		for item in pedBullets:
			item.update(scalar)
			item.draw(world)
		for item in pedPelletsList:
			item.update(scalar)
			item.draw(world)
		
		##check if any ped projectiles shot the user
		for item in pedBullets:
			if item.bulletActive:
				if item.bx > user.x+ 1100*scalar or item.bx < user.x - 300 * scalar:
					item.bulletActive = False
				if item.bx < user.x + 50*scalar and item.bx > user.x - 50 * scalar:
					if user.headAt < user.headLen-1:
						if item.bulletRect.colliderect(user.headRect):
							sounds.play('PlayerHit',volume)
							user.headAt+=s.pedsBulletDmgToUsersHead
							item.impact = True
					if user.chestAt < user.chestLen-1:
						if item.bulletRect.colliderect(user.chestRect):
							sounds.play('PlayerHit',volume)
							user.chestAt+=s.pedsBulletDmgToUsersChest
							item.impact = True
					if user.feetAt < user.feetLen-1:
						if item.bulletRect.colliderect(user.feetRect):
							sounds.play('PlayerHit',volume)
							user.feetAt+=s.pedsBulletDmgToUsersFeet
							item.impact = True
					# for block in blocks:
						# if block.x < user.x + 1100*scalar and block.x > user.x - 300 * scalar:
							# if item.bulletRect.colliderect(block.rect):
								# item.bulletActive = False
			if not item.shellActive:
				if not item in deletePedBulletsList:
					deletePedBulletsList.append(item)
					
		for item in pedPelletsList:
			for i in range(8):
				if item.pxs[i] < user.x + 1100*scalar or item.pxs[i] > user.x - 300 * scalar:
					if item.px > user.x+ 1100*scalar and item.px < user.x - 300 * scalar:
						item.pelletActives[i] = False
					if item.pelletsActive[i]:
						if user.x < user.x + 1100*scalar and user.x > user.x - 300 * scalar:
							if user.headAt < user.headLen-1:
								if item.pelletRects[i].colliderect(user.headRect):
									sounds.play('PlayerHit',volume)
									user.headAt+=s.pedsPelletDmgToUsersHead
									item.impacts[i] = True
							if user.chestAt < user.chestLen-1:
								if item.pelletRects[i].colliderect(user.chestRect):
									sounds.play('PlayerHit',volume)
									user.chestAt+=s.pedsPelletDmgToUsersChest
									item.impacts[i] = True
							if user.feetAt < user.feetLen-1:
								if item.pelletRects[i].colliderect(user.feetRect):
									sounds.play('PlayerHit',volume)
									user.feetAt+=s.pedsPelletDmgToUsersFeet
									item.impacts[i] = True
				if not item.shellActive:
					if not item in deletePedPelletsList:
						deletePedPelletsList.append(item)
		
		##check if any ped weapons hit the user (non-projectile)
		pNum = -1
		for p in peds:
			pNum+=1
			if p.x < user.x + 100*scalar and p.x > user.x - 100 * scalar:
				if pedWeapons[pNum].attacking:
					if user.headAt < user.headLen-1:
						if pedWeapons[pNum].rect.colliderect(user.headRect):
							sounds.play('PlayerHit',volume)
							user.headAt+=s.pedsMeleeDmgToUsersHead
					if user.chestAt < user.chestLen-1:
						if pedWeapons[pNum].rect.colliderect(user.chestRect):
							sounds.play('PlayerHit',volume)
							user.chestAt+=s.pedsMeleeDmgToUsersChest
					if user.feetAt < user.feetLen-1:
						if pedWeapons[pNum].rect.colliderect(user.feetRect):
							sounds.play('PlayerHit',volume)
							user.feetAt+=s.pedsMeleeDmgToUsersFeet
		
		if user.y > world_height or user.dead:
			sounds.play('PlayerDeath',volume)
			screen.blit(font.render("Wait To Respawn!", 1, (200,0,0)), (340*scalar,50*scalar))
			pygame.display.flip()
			pygame.time.wait(5000)
			pedCount,pedWeapons = levelGen(blocks,peds,maps[level])
			user.update(False,False,False,0,0,0,1)
			user.dead = False
			continue
		
		##show hitboxes
		#doesn't show ped hitboxes yet
		if pressed[K_h]:
			pygame.draw.rect(world,(255,0,0),portal.rect)
			pygame.draw.rect(world,(255,0,0),shotGun.iconRect)
			pygame.draw.rect(world,(255,0,0),shotGun.rect)
			pygame.draw.rect(world,(255,0,0),akRifle.iconRect)
			pygame.draw.rect(world,(255,0,0),akRifle.rect)
			pygame.draw.rect(world,(255,0,0),goldSword.iconRect)
			pygame.draw.rect(world,(255,0,0),goldSword.rect)
			pygame.draw.rect(world,(255,0,0),longSpear.iconRect)
			pygame.draw.rect(world,(255,0,0),longSpear.rect)
			pygame.draw.rect(world,(255,0,0),fist.rect)
			pygame.draw.rect(world,(255,0,0),testBox.rect)
			pygame.draw.rect(world,(150,0,0),user.headRect.inflate(user.headSize,0))
			pygame.draw.rect(world,(255,0,0),user.headRect)
			pygame.draw.rect(world,(255,0,0),user.chestRect)
			pygame.draw.rect(world,(255,0,0),user.feetRect)
			#pygame.draw.rect(world,(255,0,0),block1.rect)
			for block in blocks:
				pygame.draw.rect(world,(255,0,0),block.rect)
			
			for item in bullets:
				pygame.draw.rect(world,(255,0,0),item.bulletRect)
				pygame.draw.rect(world,(255,0,0),item.shellRect)
				
			for item in pelletsList:
				for i in range(8):
					pygame.draw.rect(world,(255,0,0),item.pelletRects[i])
				pygame.draw.rect(world,(255,0,0),item.shellRect)
		
		##draw the mouse box
		testBox.draw(world)
		
		##draw the world to screen
		screen.blit(world, (world_x, world_y, width, height))
		
		##onscreen debugging
		label2 = font.render(str(int(clock.get_fps())), 1, (255,255,255))
		screen.blit(label2, (30*scalar,30*scalar))
		
		##display a message on the screen
		if not message is None:
			screen.blit(message, (340*scalar,50*scalar))
		pygame.display.flip()
		if not message is None: #dat grammar :D
			pygame.time.wait(6000)
Esempio n. 37
0
 def affect(self, player):
     sounds.play('explosion')
     player.die()
Esempio n. 38
0
 def act(self, ball):
     ball.pos = random.choice(self.other_portals)
     sounds.play('portal.wav')
Esempio n. 39
0
 def on_use(self):
     sounds.play('mine')
Esempio n. 40
0
 def jump_up(self):
     jump_to_y = self.grid_y_to_y(self.char_jump_block() - 2)
     self.jump_to(jump_to_y)
     self.facing = "down"
     sounds.play("sfx/jump.wav")