Esempio n. 1
0
 def __init__(self, position, create_bullet_callback):
     self.create_bullet_callback = create_bullet_callback
     self.laser_sound = load_sound('laser')
     self.explosion_sound = load_sound("crush")
     self.direction = Vector2(UP)
     super().__init__(position, rotozoom(load_sprite("spaceship"), 0, 0.5),
                      Vector2(0))
Esempio n. 2
0
 def observe(self, pobs):
     if self.design.files:
         _, self.design.s1 = util.load_sound(self.design.fn1, fs_expected=self.fs)
         if self.design.s1.ndim > 1:
             self.design.s1 = self.design.s1[:, 0]
     else:
         self.design.s1 = self.design.in1
     self.design.s1 = util.center_and_segment(self.design.s1, int(self.mix_dur*self.fs))
     self.mix = self.design.s1
     self.refs = self.design.s1[:, numpy.newaxis]
     if defaults.DO_NOISE:
         noise_var = numpy.var(self.mix)*10**(-defaults.NOISING_SNR/10)
         noise = numpy.sqrt(noise_var)*numpy.random.randn(len(self.mix), )
         self.refs += noise[:, numpy.newaxis]
         self.mix += noise
     self.X, _  = util.ec_stft(x=self.mix, N=self.N, hop=self.hop)
     if pobs is None:
         self.pobs = dict()
         self.pobs['ft'] = util.normalize(numpy.abs(self.X))
     else:
         self.pobs = pobs
     if self.do_write: # write audio in
         for s in range(self.S):
             util.save_sound(sound_fn=self.info['in_dir'] + '/in' + str(s) + '.wav', sound=self.refs[:, s], fs=self.fs)
         util.save_sound(sound_fn=self.info['in_dir'] + '/mix.wav', sound=self.mix, fs=self.fs)
Esempio n. 3
0
 def observe(self, pobs):
     if self.design.files:
         _, self.design.s1 = util.load_sound(self.design.fn1,
                                             fs_expected=self.fs)
         if self.design.s1.ndim > 1:
             self.design.s1 = self.design.s1[:, 0]
     else:
         self.design.s1 = self.design.in1
     self.design.s1 = util.center_and_segment(self.design.s1,
                                              int(self.mix_dur * self.fs))
     self.mix = self.design.s1
     self.refs = self.design.s1[:, numpy.newaxis]
     if defaults.DO_NOISE:
         noise_var = numpy.var(self.mix) * 10**(-defaults.NOISING_SNR / 10)
         noise = numpy.sqrt(noise_var) * numpy.random.randn(len(self.mix), )
         self.refs += noise[:, numpy.newaxis]
         self.mix += noise
     self.X, _ = util.ec_stft(x=self.mix, N=self.N, hop=self.hop)
     if pobs is None:
         self.pobs = dict()
         self.pobs['ft'] = util.normalize(numpy.abs(self.X))
     else:
         self.pobs = pobs
     if self.do_write:  # write audio in
         for s in range(self.S):
             util.save_sound(sound_fn=self.info['in_dir'] + '/in' + str(s) +
                             '.wav',
                             sound=self.refs[:, s],
                             fs=self.fs)
         util.save_sound(sound_fn=self.info['in_dir'] + '/mix.wav',
                         sound=self.mix,
                         fs=self.fs)
Esempio n. 4
0
    def __init__(self, ship_rect, ship_angle, left = False):
        pygame.sprite.Sprite.__init__(self)

        if not Cannonball.image:
            Cannonball.image = util.load_image("kuti")
        if not Cannonball.sound:
            Cannonball.sound = util.load_sound("pam")
        screen = pygame.display.get_surface()
        self.area = screen.get_rect()

        self.image = Cannonball.image


        self.hitmask = pygame.surfarray.array_alpha(self.image)

        Cannonball.sound.play()

        #self.dy = -5
        #self.dx = 10
        # Shoot at an angle of 25 relative to the ship
        if not left:
            self.rect = pygame.Rect(ship_rect.right, ship_rect.centery, self.image.get_width(), self.image.get_height())
            self.vect = [math.cos((-ship_angle - 25.0) / 180.0 * math.pi) * 11.0,
                         math.sin((-ship_angle - 25.0) / 180.0 * math.pi) * 11.0]
        else:
            self.rect = pygame.Rect(ship_rect.left, ship_rect.centery, self.image.get_width(), self.image.get_height())
            self.vect = [math.cos((-ship_angle + 180.0 + 25.0) / 180.0 * math.pi) * 11.0,
                         math.sin((-ship_angle + 180.0 + 25.0) / 180.0 * math.pi) * 11.0]
Esempio n. 5
0
File: core.py Progetto: jggatc/nexus
 def __init__(self, matrix, x, y, identity):
     Node.__init__(self, matrix, x, y, identity)
     self.name = 'Nexus'
     self.images['operational'] = self.images['node_operational']
     self.images['damaged'] = self.images['node_damaged']
     self.images['failed'] = self.images['node_failed']
     self.image = self.images['operational']
     self.rect = self.image.get_rect(center=(int(self.x), int(self.y)))
     self.radius = (self.image.get_width() // 2)
     self.sound = {}
     self.sound['bootup'] = load_sound('powerup.wav')
     self.sound['bootup'].set_volume(0.3)
     self.matrix.node_update(self)
     self.initiation = False
     self.initiate = False
     self.init_count = 3
     self.aware = False
     self.data_type = ['noncorrupt', 'corrupt']
     self.data_process = 0
     self.data_corruption = 0
     self.data_integration = 0
     self.data_integration_top = 0
     self.integrity_high_color = engine.Color(80, 100, 220)
     self.integrity_low_color = engine.Color(180, 50, 50)
     self.integrity_loss = -0.001
     self.integrity = 1.0
     self.count = 10
Esempio n. 6
0
File: core.py Progetto: jggatc/nexus
 def __init__(self, matrix, x, y, identity):
     Node.__init__(self, matrix, x, y, identity)
     self.name = 'Nexus'
     self.images['operational'] = self.images['node_operational']
     self.images['damaged'] = self.images['node_damaged']
     self.images['failed'] = self.images['node_failed']
     self.image = self.images['operational']
     self.rect = self.image.get_rect(center=(int(self.x),int(self.y)))
     self.radius = (self.image.get_width()//2)
     self.sound = {}
     self.sound['bootup'] = load_sound('powerup.wav')
     self.sound['bootup'].set_volume(0.3)
     self.matrix.node_update(self)
     self.initiation = False
     self.initiate = False
     self.init_count = 3
     self.aware = False
     self.data_type = ['noncorrupt','corrupt']
     self.data_process = 0
     self.data_corruption = 0
     self.data_integration = 0
     self.data_integration_top = 0
     self.integrity_high_color = engine.Color(80,100,220)
     self.integrity_low_color = engine.Color(180,50,50)
     self.integrity_loss = -0.001
     self.integrity = 1.0
     self.count = 10
Esempio n. 7
0
 def observe(self, pobs=None):
     if self.design.files:
         _, self.design.s1 = util.load_sound(self.design.fn1, fs_expected=self.fs)
         if self.design.s1.ndim > 1:
             self.design.s1 = self.design.s1[:, 0]
     else:
         self.design.s1 = self.design.in1
     self.design.s1 = util.center_and_segment(self.design.s1, int(self.mix_dur*self.fs))
     self.mix = self.design.s1
     self.refs = self.design.s1[:, numpy.newaxis]
     if defaults.DO_NOISE:
         noise_var = numpy.var(self.mix)*10**(-defaults.NOISING_SNR/10)
         noise = numpy.sqrt(noise_var)*numpy.random.randn(len(self.mix), )
         self.refs += noise[:, numpy.newaxis]
         self.mix += noise
     self.X, _  = util.ec_stft(x=self.mix, N=self.N, hop=self.hop)
     if pobs is None:
         self.pobs = util.observe(x=self.mix, N=self.N, M=self.M, Q=self.Q, L=self.L, hop=self.hop, fs=self.fs, R=self.R)
     else:
         self.pobs = pobs
     self.R = self.pobs['R']  # in case R becomes odd
     if self.do_write:  # write audio in
         print('\nsaving input mixture at %s' % self.info['in_dir'])
         for s in range(self.S):
             util.save_sound(sound_fn=self.info['in_dir'] + '/in' + str(s) + '.wav', sound=self.refs[:, s], fs=self.fs)
         util.save_sound(sound_fn=self.info['in_dir'] + '/mix.wav', sound=self.mix, fs=self.fs)
Esempio n. 8
0
    def __init__(self, ship_rect, ship_angle, left=False, special=False):
        pygame.sprite.Sprite.__init__(self)

        if not Cannonball.image:
            Cannonball.image = util.load_image("kuti")
        if not Cannonball.spec_image:
            Cannonball.spec_image = pygame.transform.flip(
                util.load_image("lokki2"), 1, 0)

        if not Cannonball.sound:
            Cannonball.sound = util.load_sound("pam")
        screen = pygame.display.get_surface()
        self.area = screen.get_rect()

        if special:
            self.image = Cannonball.spec_image
        else:
            self.image = Cannonball.image
        self.special = special
        self.underwater = 0

        #self.hitmask = pygame.surfarray.array_alpha(self.image)
        if (Variables.sound):
            Cannonball.sound.play()
        #self.dy = -5
        #self.dx = 10
        # Shoot at an angle of 25 relative to the ship

        self.angle = 0

        if not left:
            if special:
                velocity = 14.0
                self.rect = pygame.Rect(ship_rect.right, ship_rect.top,
                                        self.image.get_width(),
                                        self.image.get_height())
                self.vect = [
                    math.cos(
                        (-ship_angle - 15.0) / 180.0 * math.pi) * velocity,
                    math.sin((-ship_angle - 15.0) / 180.0 * math.pi) * velocity
                ]
            else:
                velocity = 11.0
                self.rect = pygame.Rect(ship_rect.right, ship_rect.centery,
                                        self.image.get_width(),
                                        self.image.get_height())
            self.vect = [
                math.cos((-ship_angle - 25.0) / 180.0 * math.pi) * velocity,
                math.sin((-ship_angle - 25.0) / 180.0 * math.pi) * velocity
            ]
        else:
            self.rect = pygame.Rect(ship_rect.left, ship_rect.centery,
                                    self.image.get_width(),
                                    self.image.get_height())
            self.vect = [
                math.cos(
                    (-ship_angle + 180.0 + 25.0) / 180.0 * math.pi) * 11.0,
                math.sin((-ship_angle + 180.0 + 25.0) / 180.0 * math.pi) * 11.0
            ]
Esempio n. 9
0
 def __init__(self):
     self.score = 0
     self._init_pygame()
     self.screen = pygame.display.set_mode((self.WIDTH, self.HEIGHT))
     self.background = load_sprite("space1", False)
     self.background_game_music = load_sound("game_play_music")
     self.game_over_music = load_sound("game_over_music")
     self.clock = pygame.time.Clock()
     self.font = pygame.font.Font(None, 64)
     self.message = ""
     self.meteroids = []
     self.bullets = []
     self.spaceship = Spaceship((400, 300), self.bullets.append)
     
     for _ in range(4):
         while True:
             pos = get_random_position(self.screen)
             if pos.distance_to(self.spaceship.position) > self.MIN_METEROID_DIS:
                 break
         self.meteroids.append(Meteroid(pos, self.meteroids.append))
Esempio n. 10
0
    def __init__(self, position, create_meteroid_callback, size=3):
        self.size = size
        self.create_meteroid_callback = create_meteroid_callback
        self.explosion_sound = load_sound("meteriod_explo")
        self.explosion_sound.set_volume(100)

        size_to_scale = {3: .66, 2: 0.44, 1: 0.25}
        scale = size_to_scale[size]
        sprite = rotozoom(load_sprite("meteroid"), 0, scale)

        super().__init__(position, sprite, get_random_velocity(1, 2))
Esempio n. 11
0
 def __init__(self, matrix, x, y, dtype):
     engine.sprite.Sprite.__init__(self)
     self.matrix = matrix
     self.x = float(x)
     self.y = float(y)
     self.dtype = dtype
     if not self.images:
         self.images = {}
         image = engine.Surface((11, 11), engine.SRCALPHA)
         color1 = (0, 200, 0)
         color2 = (0, 150, 0)
         color3 = (200, 0, 0)
         points = [(5, 0), (10, 2), (10, 8), (5, 10), (0, 8), (0, 2)]
         engine.draw.polygon(image, color1, points, 0)
         engine.draw.polygon(image, color1, points, 1)
         self.images['hibit'] = image
         image = engine.Surface((11, 11), engine.SRCALPHA)
         points = [(5, 1), (9, 3), (9, 7), (5, 9), (0, 7), (0, 3)]
         engine.draw.polygon(image, color2, points, 0)
         engine.draw.polygon(image, color2, points, 1)
         self.images['lobit'] = image
         image = engine.Surface((11, 11), engine.SRCALPHA)
         points = [(5, 1), (9, 3), (9, 7), (5, 9), (0, 7), (0, 3)]
         engine.draw.polygon(image, color3, points, 0)
         engine.draw.polygon(image, color3, points, 1)
         self.images['lobit_corrupt'] = image
         self.masks = {}
         self.masks['hibit'] = engine.mask.from_surface(
             self.images['hibit'])
         self.masks['lobit'] = engine.mask.from_surface(
             self.images['lobit'])
         self.masks['lobit_corrupt'] = engine.mask.from_surface(
             self.images['lobit_corrupt'])
         self.radius = (image.get_width() // 2)
         self.sound = {}
         self.sound['blip'] = load_sound('blip.wav')
         self.sound['blip'].set_volume(0.5)
     self.image = self.images['hibit']
     self.mask = self.masks['hibit']
     self.current_image = 'hibit'
     self.rect = engine.Rect(0, 0, 11, 11)
     self.rect.x = int(self.x) - (self.image.get_width() // 2)
     self.rect.y = int(self.y) - (self.image.get_height() // 2)
     if not self.matrix.adjust:
         self.vel = 5
     else:
         self.vel = 10
     self.state_changed = False
     self.direction = 'd'
     self.node_previous = None
Esempio n. 12
0
 def __init__(self, matrix, x, y, time):
     engine.sprite.Sprite.__init__(self)
     self.matrix = matrix
     self.x = int(x)
     self.y = int(y)
     if not self.images:
         self.images = {}
         color1 = (100, 0, 0)
         color2 = (200, 0, 0)
         color3 = (50, 50, 50)
         image = engine.Surface((22, 22), engine.SRCALPHA)
         points = [(p[0] * 2, p[1] * 2)
                   for p in [(5, 0), (10, 2), (10,
                                               8), (5, 10), (0, 8), (0, 2)]]
         engine.draw.polygon(image, color1, points, 0)
         engine.draw.polygon(image, color1, points, 1)
         self.images['normal'] = image
         image = engine.Surface((22, 22), engine.SRCALPHA)
         points = [(p[0] * 2, p[1] * 2)
                   for p in [(5, 1), (9, 3), (9, 7), (5, 9), (0, 7), (0, 3)]
                   ]
         engine.draw.polygon(image, color2, points, 0)
         engine.draw.polygon(image, color2, points, 1)
         pts = [points[i] for i in range(0, len(points), 2)]
         engine.draw.polygon(image, color3, pts, 1)
         pts = [points[i] for i in range(1, len(points), 2)]
         engine.draw.polygon(image, color3, pts, 1)
         engine.draw.line(image, color3, points[0], points[3], 1)
         engine.draw.line(image, color3, (18, 10), (0, 10), 1)
         self.images['blink'] = image
         self.radius = (image.get_width() // 2)
         self.sound = {}
         self.sound['explode'] = load_sound('explode.wav')
         self.sound['explode'].set_volume(0.15)
     self.image = self.images['normal']
     self.current_image = 'normal'
     self.rect = self.image.get_rect(center=(self.x, self.y))
     self.image_timer = 2
     self.timer = time
     if not self.matrix.adjust:
         self.tick_value = 1
     else:
         self.tick_value = 2
     self.node_attached = None
     self.level = 1.0
Esempio n. 13
0
 def _welcome_screen(self):
     welcome_message = """ PIZZA DOG """
     intro_music = load_sound("welcome_screen_music")
     intro_music.play()
     self.screen.blit(self.background, (0, 0))
     draw_text(self.screen, welcome_message, self.font,  self.WIDTH/2, self.HEIGHT/3)
     draw_text(self.screen, "Press [ENTER] To Begin", self.font,  self.WIDTH/2, (self.HEIGHT/2)+40)
         
     intro = True
     while intro:
         
         for event in pygame.event.get():
             if event.type == pygame.QUIT:
                 quit()
             elif event.type == pygame.KEYDOWN and event.key == pygame.K_RETURN:
                 intro_music.stop()
                 intro = False
         pygame.display.flip()
Esempio n. 14
0
    def __init__(self, ship_rect, ship_angle, left = False, special = False):
        pygame.sprite.Sprite.__init__(self)

        if not Cannonball.image:
            Cannonball.image = util.load_image("kuti")
        if not Cannonball.spec_image:
            Cannonball.spec_image = pygame.transform.flip(util.load_image("lokki2"),1,0)
            
        if not Cannonball.sound:
            Cannonball.sound = util.load_sound("pam")
        screen = pygame.display.get_surface()
        self.area = screen.get_rect()

        if special:
            self.image= Cannonball.spec_image
        else:
            self.image = Cannonball.image
        self.special=special
        self.underwater=0
        
        #self.hitmask = pygame.surfarray.array_alpha(self.image)
        if (Variables.sound):
            Cannonball.sound.play()
        #self.dy = -5
        #self.dx = 10
        # Shoot at an angle of 25 relative to the ship

        self.angle=0
        
        if not left:
            if special:
                velocity = 14.0
                self.rect = pygame.Rect(ship_rect.right, ship_rect.top, self.image.get_width(), self.image.get_height())
                self.vect = [math.cos((-ship_angle - 15.0) / 180.0 * math.pi) * velocity,
                         math.sin((-ship_angle - 15.0) / 180.0 * math.pi) * velocity]
            else:
                velocity = 11.0
                self.rect = pygame.Rect(ship_rect.right, ship_rect.centery, self.image.get_width(), self.image.get_height())
            self.vect = [math.cos((-ship_angle - 25.0) / 180.0 * math.pi) * velocity,
                         math.sin((-ship_angle - 25.0) / 180.0 * math.pi) * velocity]
        else:
            self.rect = pygame.Rect(ship_rect.left, ship_rect.centery, self.image.get_width(), self.image.get_height())
            self.vect = [math.cos((-ship_angle + 180.0 + 25.0) / 180.0 * math.pi) * 11.0,
                         math.sin((-ship_angle + 180.0 + 25.0) / 180.0 * math.pi) * 11.0]
Esempio n. 15
0
 def __init__(self, matrix, x, y, time):
     engine.sprite.Sprite.__init__(self)
     self.matrix = matrix
     self.x = int(x)
     self.y = int(y)
     if not self.images:
         self.images = {}
         color1 = (100,0,0)
         color2 = (200,0,0)
         color3 = (50,50,50)
         image = engine.Surface((22,22), engine.SRCALPHA)
         points = [(p[0]*2,p[1]*2) for p in [(5,0),(10,2),(10,8),(5,10),(0,8),(0,2)]]
         engine.draw.polygon(image, color1, points, 0)
         engine.draw.polygon(image, color1, points, 1)
         self.images['normal'] = image
         image = engine.Surface((22,22), engine.SRCALPHA)
         points = [(p[0]*2,p[1]*2) for p in [(5,1),(9,3),(9,7),(5,9),(0,7),(0,3)]]
         engine.draw.polygon(image, color2, points, 0)
         engine.draw.polygon(image, color2, points, 1)
         pts = [points[i] for i in range(0,len(points),2)]
         engine.draw.polygon(image, color3, pts, 1)
         pts = [points[i] for i in range(1,len(points),2)]
         engine.draw.polygon(image, color3, pts, 1)
         engine.draw.line(image, color3, points[0], points[3],1)
         engine.draw.line(image, color3, (18,10), (0,10),1)
         self.images['blink'] = image
         self.radius = (image.get_width()//2)
         self.sound = {}
         self.sound['explode'] = load_sound('explode.wav')
         self.sound['explode'].set_volume(0.15)
     self.image = self.images['normal']
     self.current_image = 'normal'
     self.rect = self.image.get_rect(center=(self.x,self.y))
     self.image_timer = 2
     self.timer = time
     if not self.matrix.adjust:
         self.tick_value = 1
     else:
         self.tick_value = 2
     self.node_attached = None
     self.level = 1.0
Esempio n. 16
0
 def observe(self, pobs=None):
     if self.design.files:
         _, self.design.s1 = util.load_sound(self.design.fn1,
                                             fs_expected=self.fs)
         if self.design.s1.ndim > 1:
             self.design.s1 = self.design.s1[:, 0]
     else:
         self.design.s1 = self.design.in1
     self.design.s1 = util.center_and_segment(self.design.s1,
                                              int(self.mix_dur * self.fs))
     self.mix = self.design.s1
     self.refs = self.design.s1[:, numpy.newaxis]
     if defaults.DO_NOISE:
         noise_var = numpy.var(self.mix) * 10**(-defaults.NOISING_SNR / 10)
         noise = numpy.sqrt(noise_var) * numpy.random.randn(len(self.mix), )
         self.refs += noise[:, numpy.newaxis]
         self.mix += noise
     self.X, _ = util.ec_stft(x=self.mix, N=self.N, hop=self.hop)
     if pobs is None:
         self.pobs = util.observe(x=self.mix,
                                  N=self.N,
                                  M=self.M,
                                  Q=self.Q,
                                  L=self.L,
                                  hop=self.hop,
                                  fs=self.fs,
                                  R=self.R)
     else:
         self.pobs = pobs
     self.R = self.pobs['R']  # in case R becomes odd
     if self.do_write:  # write audio in
         print('\nsaving input mixture at %s' % self.info['in_dir'])
         for s in range(self.S):
             util.save_sound(sound_fn=self.info['in_dir'] + '/in' + str(s) +
                             '.wav',
                             sound=self.refs[:, s],
                             fs=self.fs)
         util.save_sound(sound_fn=self.info['in_dir'] + '/mix.wav',
                         sound=self.mix,
                         fs=self.fs)
Esempio n. 17
0
def init():
    Steamboat.image = util.load_image("laiva")
    Steamboat.death_sound = util.load_sound("blub")
Esempio n. 18
0
def init():
    Pirateboat.image = util.load_image("merkkari")
    Pirateboat.death_sound = util.load_sound("blub")
Esempio n. 19
0
def init():
    Mine.image = util.load_image("miina")
    Mine.sound = util.load_sound("poks")
Esempio n. 20
0
def init():
    Seagull.animation = []
    Seagull.animation.append(util.load_image("lokki1"))
    Seagull.animation.append(util.load_image("lokki2"))
    Seagull.animation.append(util.load_image("lokki3"))
    Seagull.death_sound = util.load_sound("kraah")
Esempio n. 21
0
    def __init__(self, size, scale):
        pygame.init()
        self.scale = scale
        self.size = size
        if scale:
            self.window = pygame.display.set_mode((size[0]*2, size[1]*2))
        else:
            self.window = pygame.display.set_mode(size)

        self.screen = pygame.Surface(size)
        self.screen.set_colorkey((0,0,0))
        self.actual_screen = pygame.display.get_surface()
        self.camera = camera.Camera(util.vec2(30,25),size)

        pygame.mouse.set_visible(0)
        self.clock = pygame.time.Clock()
        self.is_running = True

        self.restart_level_counter = -1
        self.current_stage_id = stage.STAGE_INTRO
        self.remove_player = False

        # physics
        #init_physics()


        # music:
        self.bg_music = util.load_sound("data/channel_panic!-theme.ogg")
        #self.bg_music.play(-1)
        #self.bg_music_playing = True
        self.bg_music_playing = False
        # billboards
        self.billboards = []
        self.billboards.append(billboard.Billboard("data/background_stars.png",util.vec2(0,0),10,True))
        self.billboards.append(billboard.Billboard("data/background_city.png",util.vec2(0,210),40,True,False,False))
        self.billboards.append(billboard.Billboard("data/background_city2.png",util.vec2(0,190),30,True,False,True))

        #timer
        self.map_timer = billboard.GuiTimerBar(util.vec2(240,0),15)

        # misc
        names = util.name_sequence("data/entity_door","png",4)
        # lol hack
        frames = util.get_sequence(names,[0,1,2,3,4,4,4,4,4,4,4,4,4,4])
        self.door_anim = animation.Animation(frames,8)
        self.animate_door = False

        self.fade_in_out = False
        self.fade_in_out_time = 0

        self.playing_intro = True

        # key gui thingy
        self.gui_key = billboard.GuiKeys(util.vec2(0,0),16)

        # game settings
        #self.player = player.Player(util.vec2(100,20), self.space)
        #print(self.player.object_type)
        #self.camera = camera.Camera(util.vec2(30,25),size)
        #self.current_stage = None
        # set color key to black
        #self.screen.set_colorkey(pygame.Color(0,0,0))
        pygame.key.set_repeat(1, 20)
Esempio n. 22
0
def init():
    Shark.image = util.load_image("hai")
    Shark.death_sound = util.load_sound("kraah")
Esempio n. 23
0
def init_game():
    pygame.init()
    # Fonts laden
    start_menu_fonts = []
    start_menu_fonts.append(pygame.font.SysFont('SPACEBOY', 56, False, False))
    start_menu_fonts.append(
        pygame.font.SysFont('Space Cruiser', 56, False, True))
    start_menu_fonts.append(pygame.font.SysFont('SPACEBOY', 28, False, False))
    start_menu_fonts.append(pygame.font.SysFont('SPACEBOY', 20, False, False))

    game_fonts = []
    game_fonts.append(start_menu_fonts[0])
    game_fonts.append(start_menu_fonts[2])

    score_window_fonts = []
    score_window_fonts.append(start_menu_fonts[0])

    instruction_window_fonts = score_window_fonts

    # images laden
    screen_size = (800, 600)
    start_menu_images = []
    start_menu_images.append(util.load_image("GameScreen.jpg",
                                             screen_size))  # Hintergrund
    start_menu_images.append(util.load_image("GameScreen.jpg", (60, 60)))
    start_menu_images.append(util.load_image("GameScreen.jpg", (90, 90)))
    start_menu_images.append(util.load_image('GameScreen_2.jpg', (60, 60)))
    start_menu_images.append(util.load_image('GameScreen_2.jpg', (90, 90)))
    start_menu_images.append(util.load_image('5x5.png', (60, 60)))
    start_menu_images.append(util.load_image('5x5.png', (90, 90)))
    start_menu_images.append(util.load_image('6x6.png', (60, 60)))
    start_menu_images.append(util.load_image('6x6.png', (90, 90)))
    start_menu_images.append(util.load_image('7x7.png', (60, 60)))
    start_menu_images.append(util.load_image('7x7.png', (90, 90)))
    start_menu_images.append(util.load_image('button_the_bests.png', (80, 20)))
    start_menu_images.append(util.load_image('button_the_bests.png',
                                             (120, 30)))
    start_menu_images.append(util.load_image('button_quit.png', (40, 20)))
    start_menu_images.append(util.load_image('button_quit.png', (60, 30)))
    start_menu_images.append(
        util.load_image('button_instruction.png', (66, 22)))
    start_menu_images.append(
        util.load_image('button_instruction.png', (96, 32)))

    game_images = []
    game_images.append(util.load_image("GameScreen.jpg",
                                       screen_size))  # Hintergrund
    game_images.append(util.load_image("EndScreen.jpeg",
                                       screen_size))  # Hintergrund
    game_images.append(util.load_image('YouWon.png', (75, 100)))
    game_images.append(util.load_image('GameScreen_2.jpg', screen_size))
    game_images.append(util.load_image('bullet.png', (10, 10)))
    game_images.append(util.load_image('button_back.png', (60, 20)))
    game_images.append(util.load_image('button_back.png', (90, 30)))

    score_window_images = []
    score_window_images.append(game_images[3])
    score_window_images.append(game_images[5])
    score_window_images.append(game_images[6])

    instruction_window_images = score_window_images

    Canon.image = util.load_image('player.png', (50, 50))

    Bullet.image = game_images[4]

    img = util.load_image('Asteroid.png', (25, 25))
    Asteroid.image = img

    img = util.load_image('bullet.png', (20, 20))
    Bomb.image = img

    img = util.load_image('bomb.png', (10, 10))
    AlienBullet.image = img

    img = util.load_image('blackHole.png', (50, 50))
    BlackHole.image = img

    img = util.load_image('alien.png', (50, 50))
    Alien.image = img

    img = util.load_image('wall.jpg', (10, 10))
    Wall.image = img

    img = util.load_image('space_ship.png', (77, 55))
    SpaceShip.image = img

    img = util.load_image('Railgun.png', (10, 50))
    Decastling.image = img

    img = util.load_image('fire.png', (50, 50))
    Fire.images = [img, pygame.transform.flip(img, 1, 1)]
    Fire.image = Fire.images[0]

    # sounds laden
    game_sounds = []
    game_sounds.append(util.load_sound('bullet.wav'))
    game_sounds.append(util.load_sound('destruction.wav'))
    game_sounds.append(util.load_sound('Railgun.wav'))
    game_sounds.append(util.load_sound('blackHole.wav'))
    game_sounds.append(util.load_sound('alarm.wav'))
    game_sounds.append(util.load_sound('asteroid.wav'))

    spoken_words = {
        1: util.load_sound('round_1.wav'),
        2: util.load_sound('round_2.wav'),
        3: util.load_sound('round_3.wav'),
        "mission_completed": util.load_sound('mission_completed.wav'),
        "winner": util.load_sound('winner.wav'),
        "game_over": util.load_sound('game_over.wav'),
    }

    app = Control(screen_size)
    state_dict = {
        'start_menu':
        StartMenu(start_menu_images, start_menu_fonts),
        'game':
        Game(game_images, game_sounds, game_fonts, spoken_words),
        'score_window':
        ScoreWindow(score_window_images, score_window_fonts),
        'instruction_window':
        InstructionWindow(instruction_window_images, instruction_window_fonts)
    }

    app.setup_states(state_dict, 'start_menu')
    app.main_game_loop()
    pygame.quit()
Esempio n. 24
0
def init():
    Shark.image = util.load_image("hai")
    Shark.death_sound = util.load_sound("kraah")
Esempio n. 25
0
 def __init__(self, matrix, x=None, y=None):
     engine.sprite.Sprite.__init__(self)
     self.matrix = matrix
     self.x = float(x)
     self.y = float(y)
     if not self.images:
         self.images = {}
         image = engine.Surface((50, 50), engine.SRCALPHA)
         color1 = (80, 100, 120)
         color2 = (80, 100, 200)
         color3 = (50, 50, 200)
         points = [
             (p[0] * 2, p[1] * 2)
             for p in [(12,
                        0), (16,
                             10), (24,
                                   13), (16,
                                         18), (12,
                                               24), (8, 18), (0, 13), (8,
                                                                       10)]
         ]
         engine.draw.polygon(image, color1, points, 0)
         points = [(p[0] * 2, p[1] * 2)
                   for p in [(16, 11), (23, 13), (16, 17)]]
         engine.draw.polygon(image, color2, points, 0)
         points = [(p[0] * 2, p[1] * 2)
                   for p in [(8, 11), (1, 13), (8, 17)]]
         engine.draw.polygon(image, color2, points, 0)
         points = [
             (p[0] * 2, p[1] * 2)
             for p in [(12, 8), (15, 11), (15, 17), (12, 20), (9,
                                                               17), (9, 11)]
         ]
         engine.draw.polygon(image, color3, points, 0)
         self.images['normal'] = image
         self.mask = engine.mask.from_surface(self.images['normal'])
         self.sound = {}
         self.sound['pulse'] = load_sound('pulse.wav')
         self.sound['pulse'].set_volume(0.1)
         self.sound['surge'] = load_sound('pulse.wav')
         self.sound['surge'].set_volume(0.2)
         self.sound['spike'] = load_sound('explode.wav')
         self.sound['spike'].set_volume(0.2)
         self.sound['shot'] = load_sound('explode.wav')
         self.sound['shot'].set_volume(0.05)
         self.sound['explode'] = load_sound('explode.wav')
         self.sound['explode'].set_volume(0.1)
         self.sound['repair'] = load_sound('repair.wav')
         self.sound['repair'].set_volume(0.2)
     self.image = self.images['normal']
     self.rect = self.image.get_rect(center=(int(self.x), int(self.y)))
     self.rect_center = self.rect.inflate(-40, -40)
     self.width = self.image.get_width()
     self.height = self.image.get_height()
     self.radius = self.image.get_width() // 2
     self.channel = engine.mixer.Channel(0)
     if not self.matrix.adjust:
         self.velocity = 5
         self.vel = self.velocity
         self.vel_max = 10
     else:
         self.velocity = 10
         self.vel = self.velocity
         self.vel_max = 25
     self.node_position = [int(self.x), int(self.y)]
     self.motion = {'u': False, 'd': False, 'l': False, 'r': False}
     self.moving = False
     self.dir = 'v'
     self.dirs = {'u': -1, 'd': 1, 'l': -1, 'r': 1}
     self.dir_offset = {
         'u': (0, -1),
         'd': (0, 1),
         'l': (-1, 0),
         'r': (1, 0)
     }
     self.orient = {'u': 'v', 'd': 'v', 'l': 'h', 'r': 'h'}
     self.field = {'u': 50, 'd': 450, 'l': 50, 'r': 450}
     self.control = {'z': False, 'x': False}
     self.active = False
     self.pulse_charge = 1.0
     self.pulse_aim = 'u'
     self.power = 1.0
     self.targets = [self.matrix.bots]
     self.identity = 'Avatar'
     self.controls = {
         'u': False,
         'd': False,
         'l': False,
         'r': False,
         'z': False,
         'x': False
     }
Esempio n. 26
0
def init():
    Titanic.image = util.load_image("titanic")
    Titanic.death_sound = util.load_sound("blub")
Esempio n. 27
0
 def __init__(self, matrix, x=None, y=None):
     engine.sprite.Sprite.__init__(self)
     self.matrix = matrix
     self.x = float(x)
     self.y = float(y)
     if not self.images:
         self.images = {}
         image = engine.Surface((50,50), engine.SRCALPHA)
         color1 = (80,100,120)
         color2 = (80,100,200)
         color3 = (50,50,200)
         points = [(p[0]*2,p[1]*2) for p in [(12,0),(16,10),(24,13),(16,18),(12,24),(8,18),(0,13),(8,10)]]
         engine.draw.polygon(image, color1, points, 0)
         points = [(p[0]*2,p[1]*2) for p in [(16,11),(23,13),(16,17)]]
         engine.draw.polygon(image, color2, points, 0)
         points = [(p[0]*2,p[1]*2) for p in [(8,11),(1,13),(8,17)]]
         engine.draw.polygon(image, color2, points, 0)
         points = [(p[0]*2,p[1]*2) for p in [(12,8),(15,11),(15,17),(12,20),(9,17),(9,11)]]
         engine.draw.polygon(image, color3, points, 0)
         self.images['normal'] = image
         self.mask = engine.mask.from_surface(self.images['normal'])
         self.sound = {}
         self.sound['pulse'] = load_sound('pulse.wav')
         self.sound['pulse'].set_volume(0.1)
         self.sound['surge'] = load_sound('pulse.wav')
         self.sound['surge'].set_volume(0.2)
         self.sound['spike'] = load_sound('explode.wav')
         self.sound['spike'].set_volume(0.2)
         self.sound['shot'] = load_sound('explode.wav')
         self.sound['shot'].set_volume(0.05)
         self.sound['explode'] = load_sound('explode.wav')
         self.sound['explode'].set_volume(0.1)
         self.sound['repair'] = load_sound('repair.wav')
         self.sound['repair'].set_volume(0.2)
     self.image = self.images['normal']
     self.rect = self.image.get_rect(center=(int(self.x),int(self.y)))
     self.rect_center = self.rect.inflate(-40,-40)
     self.width = self.image.get_width()
     self.height = self.image.get_height()
     self.radius = self.image.get_width()//2
     self.channel = engine.mixer.Channel(0)
     if not self.matrix.adjust:
         self.velocity = 5
         self.vel = self.velocity
         self.vel_max = 10
     else:
         self.velocity = 10
         self.vel = self.velocity
         self.vel_max = 25
     self.node_position = [int(self.x), int(self.y)]
     self.motion = {'u':False,'d':False,'l':False,'r':False}
     self.moving = False
     self.dir = 'v'
     self.dirs = {'u':-1,'d':1,'l':-1,'r':1}
     self.dir_offset = {'u':(0,-1),'d':(0,1),'l':(-1,0),'r':(1,0)}
     self.orient = {'u':'v','d':'v','l':'h','r':'h'}
     self.field = {'u':50,'d':450,'l':50,'r':450}
     self.control = {'z':False,'x':False}
     self.active = False
     self.pulse_charge = 1.0
     self.pulse_aim = 'u'
     self.power = 1.0
     self.targets = [self.matrix.bots]
     self.identity = 'Avatar'
     self.controls = {'u':False,'d':False,'l':False,'r':False,'z':False,'x':False}
Esempio n. 28
0
def init():
    Pirateboat.image = util.load_image("merkkari")
    Pirateboat.death_sound = util.load_sound("blub")
Esempio n. 29
0
def init():
    Mine.image = util.load_image("miina")
    Mine.sound = util.load_sound("poks")
Esempio n. 30
0
def init():
    Seagull.animation = []
    Seagull.animation.append(util.load_image("lokki1"))
    Seagull.animation.append(util.load_image("lokki2"))
    Seagull.animation.append(util.load_image("lokki3"))
    Seagull.death_sound = util.load_sound("kraah")
Esempio n. 31
0
def init():
    Titanic.image = util.load_image("titanic")
    Titanic.death_sound = util.load_sound("blub")