예제 #1
0
    def add_particles(self, n=1, **kargs):
        """
            Add an amount n of particles with the past kargs
        """
        margin = 10
        for i in range(n):
            repeat = True
            while repeat:
                inside = False
                radius = kargs.get('radius', random.randint(10, 15))
                pos = kargs.get('pos', (random.randint(radius+margin, self.width-radius-margin),\
                                       random.randint(radius+margin, self.height-radius-margin)))
                color = kargs.get('color', random_color_vibrant())
                speed = kargs.get('speed', random.randint(20, 100))
                vel = vector2(0, 1).rotate(random.uniform(0, 360)) * speed
                new_particle = Particle(pos, radius, color)
                new_particle.vel = vel

                if 'pos' not in kargs:
                    for particles in self.particles:
                        if particles.inside(new_particle):
                            inside = True
                            break

                if inside == False:
                    self.particles.append(new_particle)
                    repeat = False
예제 #2
0
    def __init__(self, size, num=0):
        self.width, self.height = self.size = size
        self.particles = []
        self.add_particles(num)

        self.drag = 0.001
        self.gravity = pygame.Vector2(0, 0)

        self.border_color = (10, 10, 10)
        self.border_points = [
            vector2(0, 0),
            vector2(self.width, 0),
            vector2(self.width, self.height),
            vector2(0, self.height),
            vector2(0, 0)
        ]
        self.w = 2
예제 #3
0
	def __init__(self, screen, player, image_source, powerup_img):
		self.screen = screen
		self.image = pyg.image.load(image_source)
		screendim = self.screen.get_size()
		self.location = vector2(screendim[0]/2-300, screendim[1]-200)
		self.up_cooldown = pyg.image.load("Assets/Up_text.png").convert_alpha()
		self.down_cooldown = pyg.image.load("Assets/Down_text.png").convert_alpha()
		self.middle_cooldown = pyg.image.load("Assets/Middle_text.png").convert_alpha()
		self.up_cooldown2 = pyg.image.load("Assets/Up_text2.png").convert_alpha()
		self.down_cooldown2 = pyg.image.load("Assets/Down_text2.png").convert_alpha()
		self.middle_cooldown2 = pyg.image.load("Assets/Middle_text2.png").convert_alpha()
		self.low_health = pyg.image.load("Assets/Inject/low.png").convert_alpha()
		self.boss_text = {	'boss_found':	pyg.image.load("Assets/Inject/boss_found.png").convert_alpha(),
							'survive':		pyg.image.load("Assets/Inject/survive.png").convert_alpha(),
							'go_inject':	pyg.image.load("Assets/Inject/go_inject.png").convert_alpha(),
							'inject':		pyg.image.load("Assets/Inject/inject_now.png").convert_alpha()	}
		self.found_text_timer = 4000

		self.player = player
		
		self.top_left     = (self.location.x+7, self.location.y+11)
		self.top_right    = (self.top_left[0]+126, self.top_left[1])
		self.bottom_left  = (self.top_left[0], self.location.y+21)
		self.bottom_right = (self.top_right[0], self.bottom_left[1])
		self.height       = abs(self.top_left[1] - self.bottom_left[1])
		self.width        = abs(self.top_left[0] - self.top_right[0])
		self.color        = (0, 255, 0)

		self.font = pyg.font.SysFont("monospace", 15)

		#killcount display
		self.box = pyg.Rect(25, 25, self.width*4/5, self.height*2)
		#deathcount display
		self.box2 = pyg.Rect(self.box.left, self.box.top+self.box.height+1, self.width*4/5, self.height*2)
		#powerups display
		self.shieldpos = (self.top_left[0], self.bottom_left[1]+1+self.box.height)
		self.healpos = (self.shieldpos[0], self.shieldpos[1]+35)
		self.shield = power_up(self.shieldpos, 2, powerup_img)
		self.heals = power_up(self.healpos, 1, powerup_img)
		#display text center
		text_pos = (screendim[0]/2, 30)
		dim1 = self.boss_text['boss_found'].get_size()
		dim2 = self.boss_text['survive'].get_size()
		dim3 = self.boss_text['inject'].get_size()
		dim4 = self.boss_text['go_inject'].get_size()
		dim5 = self.low_health.get_size()
		self.boss_text_pos = {	'boss_found':	(text_pos[0]-dim1[0]/2, text_pos[1]),
								'survive':		(text_pos[0]-dim2[0]/2, text_pos[1]),
								'go_inject':	(text_pos[0]-dim4[0]/2, text_pos[1]),
								'inject':		(text_pos[0]-dim3[0]/2, text_pos[1])	}
		self.low_health_pos = (text_pos[0]-dim5[0]/2, text_pos[1]+70)
예제 #4
0
	def display(self):
		# first draw our image.
		screendim = self.screen.get_size()
		textpos1 = (screendim[0]/2, screendim[1]-150)
		textpos2 = (textpos1[0]-100, textpos1[1])
		textpos3 = (textpos1[0]+90, textpos1[1])

		self.screen.blit(self.image, (self.location.x, self.location.y))
		if self.player.top_attack.time_between_attacks<=0:
			self.screen.blit(self.up_cooldown, textpos2)
		else:
			self.screen.blit(self.up_cooldown2, textpos2)
		if self.player.middle_attack.time_between_attacks<=0:
			self.screen.blit(self.middle_cooldown, textpos1)
		else:
			self.screen.blit(self.middle_cooldown2, textpos1)
		if self.player.bottom_attack.time_between_attacks<=0:
			self.screen.blit(self.down_cooldown, textpos3)
		else:
			self.screen.blit(self.down_cooldown2, textpos3)
   
		bar = pyg.Rect(self.top_left[0], 
					   self.top_left[1], 
					   self.width * self.player.health / self.player.full_health, # now we draw it only as long as health.
					   self.height)

		#display boss text
		if self.player.found_boss:
			if self.player.boss_moving:
				if self.found_text_timer > 0:
					#draw found text
					self.screen.blit(self.boss_text['boss_found'], self.boss_text_pos['boss_found'])
				elif self.player.can_inject:
					#draw inject text
					self.screen.blit(self.boss_text['inject'], self.boss_text_pos['inject'])
				else:
					self.screen.blit(self.boss_text['go_inject'], self.boss_text_pos['go_inject'])
			else:
				#draw survive text
				self.screen.blit(self.boss_text['survive'], self.boss_text_pos['survive'])

		#display low health
		if self.player.health <= self.player.full_health * 1/3:
			self.screen.blit(self.low_health, self.low_health_pos)

		#kill count text
		killct = self.font.render("Kills: " + str(self.player.enemies_killed), 1, (255,255,255) )
		#death count text
		deathct = self.font.render("Deaths: " + str(self.player.deaths), 1, (255,255,255) )
		#powerups count text
		shieldct = self.font.render("Shields: " + str(self.player.shields), 1, (255,255,255))
		healct = self.font.render("Heals: " + str(self.player.healths), 1, (255,255,255))

		# draw our rectangle on top of the image
		# 0 width means fill rectangle.
		pyg.draw.rect(self.screen, self.color, bar, 0)
		#draw killcount
		self.screen.blit(killct, (int(self.box.left+5), int(self.box.top+2)))
		self.screen.blit(deathct, (int(self.box2.left+5), int(self.box2.top+2)))
		#draw power up displays
		self.shield.draw(self.screen, vector2(0,0))
		self.heals.draw(self.screen, vector2(0,0))
		self.screen.blit(shieldct, (int(self.shieldpos[0]+30), int(self.shieldpos[1]+15)))
		self.screen.blit(healct, (int(self.healpos[0]+30), int(self.healpos[1]+15)))
예제 #5
0
def zoom(amplituded):
    global mag, mag_vec
    mag *= amplituded
    mag_vec = (1 - mag) * vector2(*middle_size)
예제 #6
0
from Particle import Particle
from Environment import Environment
from utils import random_color, vector2, colors, get_env_pos, get_real_pos

# --------- Params of the simulation ---------
width, height = size = 800, 600
middle_size = width / 2, height / 2
fps = 60

# grid size
env_w = 2
env_h = 2

select = None
mouse_force = 800
preventMouse = [vector2(0, 0)] * 5

mag = 1
mag_vec = vector2(0, 0)

delay = 5  # frames
add = True
add_frame = 0

min_particles = 5
max_particles = 10

# --------- environments ---------
env_size = env_width, env_height = int(width / env_w), int(height / env_h)
gravity_pro = 0.2
예제 #7
0
    def display(self):
        # first draw our image.
        screendim = self.screen.get_size()
        textpos1 = (screendim[0] / 2, screendim[1] - 150)
        textpos2 = (textpos1[0] - 100, textpos1[1])
        textpos3 = (textpos1[0] + 90, textpos1[1])

        self.screen.blit(self.image, (self.location.x, self.location.y))
        if self.player.top_attack.time_between_attacks <= 0:
            self.screen.blit(self.up_cooldown, textpos2)
        else:
            self.screen.blit(self.up_cooldown2, textpos2)
        if self.player.middle_attack.time_between_attacks <= 0:
            self.screen.blit(self.middle_cooldown, textpos1)
        else:
            self.screen.blit(self.middle_cooldown2, textpos1)
        if self.player.bottom_attack.time_between_attacks <= 0:
            self.screen.blit(self.down_cooldown, textpos3)
        else:
            self.screen.blit(self.down_cooldown2, textpos3)

        bar = pyg.Rect(
            self.top_left[0],
            self.top_left[1],
            self.width * self.player.health /
            self.player.full_health,  # now we draw it only as long as health.
            self.height)

        #display boss text
        if self.player.found_boss:
            if self.player.boss_moving:
                if self.found_text_timer > 0:
                    #draw found text
                    self.screen.blit(self.boss_text['boss_found'],
                                     self.boss_text_pos['boss_found'])
                elif self.player.can_inject:
                    #draw inject text
                    self.screen.blit(self.boss_text['inject'],
                                     self.boss_text_pos['inject'])
                else:
                    self.screen.blit(self.boss_text['go_inject'],
                                     self.boss_text_pos['go_inject'])
            else:
                #draw survive text
                self.screen.blit(self.boss_text['survive'],
                                 self.boss_text_pos['survive'])

        #display low health
        if self.player.health <= self.player.full_health * 1 / 3:
            self.screen.blit(self.low_health, self.low_health_pos)

        #kill count text
        killct = self.font.render("Kills: " + str(self.player.enemies_killed),
                                  1, (255, 255, 255))
        #death count text
        deathct = self.font.render("Deaths: " + str(self.player.deaths), 1,
                                   (255, 255, 255))
        #powerups count text
        shieldct = self.font.render("Shields: " + str(self.player.shields), 1,
                                    (255, 255, 255))
        healct = self.font.render("Heals: " + str(self.player.healths), 1,
                                  (255, 255, 255))

        # draw our rectangle on top of the image
        # 0 width means fill rectangle.
        pyg.draw.rect(self.screen, self.color, bar, 0)
        #draw killcount
        self.screen.blit(killct,
                         (int(self.box.left + 5), int(self.box.top + 2)))
        self.screen.blit(deathct,
                         (int(self.box2.left + 5), int(self.box2.top + 2)))
        #draw power up displays
        self.shield.draw(self.screen, vector2(0, 0))
        self.heals.draw(self.screen, vector2(0, 0))
        self.screen.blit(
            shieldct,
            (int(self.shieldpos[0] + 30), int(self.shieldpos[1] + 15)))
        self.screen.blit(
            healct, (int(self.healpos[0] + 30), int(self.healpos[1] + 15)))
예제 #8
0
    def __init__(self, screen, player, image_source, powerup_img):
        self.screen = screen
        self.image = pyg.image.load(image_source)
        screendim = self.screen.get_size()
        self.location = vector2(screendim[0] / 2 - 300, screendim[1] - 200)
        self.up_cooldown = pyg.image.load("Assets/Up_text.png").convert_alpha()
        self.down_cooldown = pyg.image.load(
            "Assets/Down_text.png").convert_alpha()
        self.middle_cooldown = pyg.image.load(
            "Assets/Middle_text.png").convert_alpha()
        self.up_cooldown2 = pyg.image.load(
            "Assets/Up_text2.png").convert_alpha()
        self.down_cooldown2 = pyg.image.load(
            "Assets/Down_text2.png").convert_alpha()
        self.middle_cooldown2 = pyg.image.load(
            "Assets/Middle_text2.png").convert_alpha()
        self.low_health = pyg.image.load(
            "Assets/Inject/low.png").convert_alpha()
        self.boss_text = {
            'boss_found':
            pyg.image.load("Assets/Inject/boss_found.png").convert_alpha(),
            'survive':
            pyg.image.load("Assets/Inject/survive.png").convert_alpha(),
            'go_inject':
            pyg.image.load("Assets/Inject/go_inject.png").convert_alpha(),
            'inject':
            pyg.image.load("Assets/Inject/inject_now.png").convert_alpha()
        }
        self.found_text_timer = 4000

        self.player = player

        self.top_left = (self.location.x + 7, self.location.y + 11)
        self.top_right = (self.top_left[0] + 126, self.top_left[1])
        self.bottom_left = (self.top_left[0], self.location.y + 21)
        self.bottom_right = (self.top_right[0], self.bottom_left[1])
        self.height = abs(self.top_left[1] - self.bottom_left[1])
        self.width = abs(self.top_left[0] - self.top_right[0])
        self.color = (0, 255, 0)

        self.font = pyg.font.SysFont("monospace", 15)

        #killcount display
        self.box = pyg.Rect(25, 25, self.width * 4 / 5, self.height * 2)
        #deathcount display
        self.box2 = pyg.Rect(self.box.left, self.box.top + self.box.height + 1,
                             self.width * 4 / 5, self.height * 2)
        #powerups display
        self.shieldpos = (self.top_left[0],
                          self.bottom_left[1] + 1 + self.box.height)
        self.healpos = (self.shieldpos[0], self.shieldpos[1] + 35)
        self.shield = power_up(self.shieldpos, 2, powerup_img)
        self.heals = power_up(self.healpos, 1, powerup_img)
        #display text center
        text_pos = (screendim[0] / 2, 30)
        dim1 = self.boss_text['boss_found'].get_size()
        dim2 = self.boss_text['survive'].get_size()
        dim3 = self.boss_text['inject'].get_size()
        dim4 = self.boss_text['go_inject'].get_size()
        dim5 = self.low_health.get_size()
        self.boss_text_pos = {
            'boss_found': (text_pos[0] - dim1[0] / 2, text_pos[1]),
            'survive': (text_pos[0] - dim2[0] / 2, text_pos[1]),
            'go_inject': (text_pos[0] - dim4[0] / 2, text_pos[1]),
            'inject': (text_pos[0] - dim3[0] / 2, text_pos[1])
        }
        self.low_health_pos = (text_pos[0] - dim5[0] / 2, text_pos[1] + 70)