Example #1
0
	def __init__(self, game, a, b):
		self.game = game
		self.body = physics.add_body(self.game.space, None)
		if a.x > b.x:
			a, b = b, a
		self.shape = pymunk.Segment(self.body, a, b, 2)
		self.shape.collision_type = COLLISION_ONEWAY
		physics.add_shape(self.game.space, self.shape, friction=1.0)
Example #2
0
	def __init__(self, game, pos, vel, damage, creator, image=None):
		self.creator = creator
		self.damage = damage
		self.game = game
		self.body = physics.add_body(self.game.space, 10)
		self.body.bullet = self
		self.body.position = pos
		self.body.velocity = vel
		self.body.velocity_func = self.update_velocity
		physics.add_shape(self.game.space, pymunk.Circle(self.body, 10), collision_type=COLLISION_BULLET, friction=0.0)
		if not image:
			self.image = pygame.transform.rotozoom(resources.bullet, 0, .01)
Example #3
0
	def __init__(self, game, pos):
		self.orig_texture = resources.flower
		self.texture = pygame.transform.rotozoom(self.orig_texture, 0, .5)
		self.game = game
		self.body = physics.add_body(self.game.space, .1)
		self.body.position = pos
		self.stem = pos
		shape = pymunk.Circle(self.body, 10)
		shape.collision_type = COLLISION_FOOD
		physics.add_shape(self.game.space, shape, friction=0.5)
		self.body.food = self
		self.speed = 10
		self.body.velocity_func = self.update_velocity
		self.value = 10
Example #4
0
	def __init__(self, game, pos):
		self.game = game
		self.body = physics.add_body(self.game.space, 1)
		self.body.enemy = self
		self.body.position = pos
		self.body.velocity_func = self.update_velocity
		physics.add_shape(self.game.space, pymunk.Circle(self.body, 20), collision_type=COLLISION_ENEMY, friction=0.5)
		self.speed = 80
		self.maxspeed = 300
		self.range = 100
		self.canseeplayer = False
		self.state = STATE_WANDERING
		self.attack_timer = 0
		self.attack_time = 3
		self.damage = 10
		scale = .05
		self.image_body = pygame.transform.smoothscale(resources.broccoli_body, (int(resources.wasp_body.get_width()*scale), int(resources.wasp_body.get_height()*scale)))
		self.image_dead = pygame.transform.flip(self.image_body, False, True)
		self.facing = True
		self.health = 50
		self.keyboard = pymunk.Vec2d()
Example #5
0
	def __init__(self, game, pos):
		self.game = game
		self.body = physics.add_body(self.game.space, None)
		self.body.position = pos
		self.body.ground = self
		self.body.angle = random.random()*3.14

		#self.points = convexhull([(random.random()*500-200, random.random()*50-25) for x in range(10)])
		shape = GroundShapes[int(math.floor(random.uniform(0, len(GroundShapes))))]

		self.texture = shape[0]
		self.orig_tex = self.texture
		self.xx = int(self.texture.get_width()/2)
		self.yy = int(self.texture.get_height()/2)
		for x in shape[1]:
			pnts = [(x[i]-self.xx, -x[i+1]+self.yy) for i in range(len(x)) if i % 2 == 0]
			shapez = pymunk.Poly(self.body, pnts)
			shapez.collision_type = COLLISION_GROUND
			physics.add_shape(self.game.space, shapez, friction=1.0)

		self.texture = pygame.transform.rotozoom(self.orig_tex, self.body.angle/3.14*180, 1)
		self.scr_corr = (self.xx+(self.texture.get_width()-self.orig_tex.get_width())/2, self.yy+(self.texture.get_height()-self.orig_tex.get_height())/2)
Example #6
0
	def add_ball(self):
		body = physics.add_body(self.space, 1)
		physics.add_shape(body, pymunk.Circle(body, 10))
		body.position = (random.randint(120, 300), 550)
Example #7
0
	def add_floor(self):
		body = physics.add_body(self.space)
		physics.add_shape(body, pymunk.Segment(body, (0, 0), (600.0, 0.0), 5.0))
		body.position = (0, 0)
Example #8
0
	def __init__(self, game):
		self.game = game
		self.body = physics.add_body(self.game.space, 1)
		self.body.position = (0, 0)
		self.body.velocity_func = self.playerUpdateVelocity
		self.playerShape = pymunk.Circle(self.body, 30)
		physics.add_shape(self.game.space, self.playerShape, collision_type = COLLISION_PLAYER, friction=.4)
		self.keyboard = pymunk.Vec2d(0, 0)
		self.remainingBoost = 0
		self.game.space.enable_contact_graph = True
		self.lastJumpState = False
		self.body.moment = pymunk.inf
		self.fallthrough = False
		self.grounded = False
		self.menu = None

		self.speed = 100
		self.swimspeed = 50
		self.maxspeed = 300
		self.airspeed = 100

		self.hunger = 100
		self.health = 100
		self.maxhealth = 100

		self.jumpheight = 25
		self.maxjumps = 1
		self.jumps = self.maxjumps
		self.gravity = 500

		self.ranged_damage = 20
		self.melee_damage = 40

		self.minattackspeed = .2
		self.ranged_attack_speed = .5
		self.melee_attack_speed = .4
		self.ranged_attack = 0
		self.melee_attack = 0

		self.facing = True

		self.image_body_right = resources.player_body
		self.image_body_left = pygame.transform.flip(self.image_body_right, True, False)
		self.image_leg_right = resources.player_leg
		self.image_leg_left = pygame.transform.flip(self.image_leg_right, True, False)
		self.image_wing_right = resources.player_wing
		self.image_wing_left = pygame.transform.flip(self.image_wing_right, True, False)
		self.image_jaw = resources.player_jaw_upper

		self.upgrade_attack = 0
		self.upgrade_utility = 0
		self.upgrade_movement = 0

		self.distance_travelled = 0
		self.enemies_killed = 0
		self.time = 0

		self.size = 30
		self.movin = 0
		self.flap = 0
		self.chomp = 0
		self.growth = 2