Esempio n. 1
0
import PAdLib.occluder as occluder
import PAdLib.particles as particles

pygame.display.init()
pygame.font.init()

screen_size = [800, 600]
icon = pygame.Surface((1, 1))
icon.set_alpha(0)
pygame.display.set_icon(icon)
pygame.display.set_caption("Particles Demo with PAdLib - Ian Mallett - 2013")
surface = pygame.display.set_mode(screen_size)

#Make a particle emitter
emitter1 = particles.Emitter()
#   number of new particles added each second, on average
emitter1.set_density(300)
#   New particles will travel in the direction -135 degrees, distributed around
#   that by +/- 2.5 degrees.  Note PyGame's inverted y axis.
emitter1.set_angle(-135.0, 5.0)
#   The range of initial speeds the particles will have, in pixels per second.
#   Each new particle's initial speed is chosen randomly from this range.
emitter1.set_speed([150.0, 350.0])
#   New particles will last for a given amount of time, chosen randomly from
#   1.0 seconds to 2.0 seconds.
emitter1.set_life([1.0, 2.0])
#   This specifies a list of colors each particle will have over its lifetime.
#   Particles' colors are defined continuously; smoothly blending between values
#   in this list as they get older.
emitter1.set_colors([(255, 0, 0), (255, 255, 0), (0, 255, 0), (0, 255, 255),
Esempio n. 2
0
num_bees = 1

font1 = pygame.font.Font("assets/FrederickatheGreat-Regular.ttf", 16)
font2 = pygame.font.Font("assets/FrederickatheGreat-Regular.ttf", 32)

# fonts = {
#     16 : pygame.font.SysFont("Times New Roman",16,True),
#     32 : pygame.font.SysFont("Times New Roman",32,True)
# }

colors = [(220, 246, 172), (211, 254, 255), (255, 232, 211), (220, 246, 172), (202, 255, 231), (210, 223, 255), (249, 225, 238)]
color = colors[random.randint(0, len(colors)-1)]

fire_colors = [(255,0,0),(255,255,0),(255,200,0),(255,128,0),(128,0,0),(0,0,0)]

emitter_rocket = particles.Emitter()
emitter_rocket.set_particle_emit_density(0)
emitter_rocket.set_particle_emit_speed([350.0,550.0])
emitter_rocket.set_particle_emit_life([1.0,2.0])
emitter_rocket.set_particle_emit_colors(fire_colors)

emitter_turn1 = particles.Emitter()
emitter_turn1.set_particle_emit_density(0)
emitter_turn1.set_particle_emit_speed([50.0,250.0])
emitter_turn1.set_particle_emit_life([0.05,0.05])
emitter_turn1.set_particle_emit_colors(fire_colors)

emitter_turn2 = particles.Emitter()
emitter_turn2.set_particle_emit_density(0)
emitter_turn2.set_particle_emit_speed([50.0,250.0])
emitter_turn2.set_particle_emit_life([0.05,0.05])
icon = pygame.Surface((1, 1))
icon.set_alpha(0)
pygame.display.set_icon(icon)
pygame.display.set_caption(
    "Shadows/Particles Demo with PAdLib - Ian Mallett - 2013")
surface = pygame.display.set_mode(screen_size)

surf_lighting = pygame.Surface(screen_size)

shad = shadow.Shadow()
shad.set_radius(100.0)
shad.set_light_position([screen_size[0] / 2, screen_size[1] / 2])

surf_falloff = pygame.image.load("light_falloff100.png").convert()

emitter = particles.Emitter()
emitter.set_density(200)
emitter.set_angle(90.0, 360.0)
emitter.set_speed([50.0, 50.0])
emitter.set_life([1.0, 1.0])
emitter.set_colors([(255, 0, 0), (255, 255, 0), (255, 128, 0), (0, 0, 0)])

particle_system = particles.ParticleSystem()
particle_system.add_emitter(emitter)


def get_input():
    mouse_position = pygame.mouse.get_pos()
    for event in pygame.event.get():
        if event.type == QUIT: return False
        elif event.type == KEYDOWN:
Esempio n. 4
0
pygame.display.set_icon(icon)
pygame.display.set_caption(
    "Asteroids II - The Vector - v.4.0.0 - Ian Mallett - 2013")
surface = pygame.display.set_mode(screen_size)

fonts = {
    16: pygame.font.SysFont("Times New Roman", 16, True),
    32: pygame.font.SysFont("Times New Roman", 32, True)
}

fire_colors = [(255, 0, 0), (255, 255, 0), (255, 200, 0), (255, 128, 0),
               (128, 0, 0), (0, 0, 0)]

###############
# shock : if asteroid.health == 0:
emitter_shock = particles.Emitter()
emitter_shock.set_particle_emit_density(0)
emitter_shock.set_particle_emit_angle(0.0, 360.0)
emitter_shock.set_particle_emit_speed([50.0, 400.0])
emitter_shock.set_particle_emit_life([0.5, 1.0])
emitter_shock.set_particle_emit_colors([(255, 255, 255), (0, 0, 0)])

emitter_hit = particles.Emitter()
emitter_hit.set_particle_emit_density(0)
emitter_hit.set_particle_emit_angle(0.0, 360.0)
emitter_hit.set_particle_emit_speed([100.0, 100.0])
emitter_hit.set_particle_emit_life([0.5, 1.0])
emitter_hit.set_particle_emit_colors([(255, 255, 255), (255, 255, 0),
                                      (0, 0, 255), (0, 0, 0)])

emitter_die = particles.Emitter()