Exemplo n.º 1
0
    def loop(self, screen):
        img_manager.draw_rect(screen, Vector2(), Rect(Vector2(0, 0), engine.get_screen_size()), (255, 255, 255))
        self.cat.loop(screen)
        self.ferret.loop(screen)

        if not self.dialog:
            img_manager.show_image(self.img,screen,Vector2(0,-48))


            if (self.time % 20) > 10:
                img_manager.buffer.draw(self.text)

            self.time += 1
        if not self.dialog and (input_manager.get_button("A") or input_manager.get_button("B")):
            snd_manager.set_playlist(["data/music/intro_BOSS1_gbjam.ogg","data/music/BOSS1_gbjam.ogg"])
            self.dialog = 1
            engine.show_dialog = True
            engine.textbox.set_text("Fury", "General Meow, you are still alive")
        if self.dialog == 1 and engine.textbox.finished:
            if input_manager.get_button('A') or input_manager.get_button('B'):
                self.dialog = 2
                engine.textbox.set_text("General Meow", "I'm not easy to kill. Don't forget it")
        if self.dialog == 2 and engine.textbox.finished:
            if input_manager.get_button('A') or input_manager.get_button('B'):
                self.dialog = 3
                engine.textbox.set_text("Fury","I won't miss you next time")
        if self.dialog == 3 and engine.textbox.finished:
            if input_manager.get_button('A') or input_manager.get_button('B'):
                engine.show_dialog = False
                from engine.level_manager import switch_level
                switch_level(GameState(CONST.startup))
        snd_manager.update_music_status()
Exemplo n.º 2
0
    def loop(self, screen):
        Image.loop(self, screen)

        if self.anim.boum:
            self.anim.explosion.update_animation(state="boum")
            explosion_pos = Vector2()
            if self.anim.player.anim.direction:
                explosion_pos = (
                    self.anim.player.pos
                    + engine.screen_size * self.anim.player.screen_relative_pos
                    + Vector2(self.anim.player.size.x, 0)
                )
            else:
                explosion_pos = (
                    self.anim.player.pos
                    + engine.screen_size * self.anim.player.screen_relative_pos
                    - Vector2(self.anim.player.size.x, 0)
                )
            img_manager.show_image(
                self.anim.explosion.img,
                engine.screen,
                pos=explosion_pos - level_manager.level.screen_pos,
                new_size=Vector2(36, 36),
            )
            if self.anim.explosion.index == 6:
                self.anim.boum = False
Exemplo n.º 3
0
 def loop(self,screen,screen_pos= Vector2()):
     if self.text_surface:
         if self.time < self.gradient:
             self.time += 1
             self.change_text(self.text[0:int(self.time/self.gradient*len(self.text))])
         pos = self.pos
         if not self.screen_relative:
             pos = pos-screen_pos
         if self.center and self.size:
             pos = pos - Vector2(self.size.x/2.0, 0.0)
         img_manager.show_image(self.text_surface, screen, pos, self.angle, self.center, new_size=self.size)
Exemplo n.º 4
0
    def loop(self, screen):
        if self.anim:
            self.anim.update_animation()
            self.img = self.anim.img
            try:
                self.show = (self.anim.invincibility % (self.anim.show_frequency * 2)) < self.anim.show_frequency
            except AttributeError:
                pass
        pos = Vector2()
        if self.pos:
            pos = self.pos

        if self.screen_relative_pos is not None:
            pos = pos + self.screen_relative_pos * engine.get_screen_size()

        if self.screen_relative:
            pos = self.pos
        else:
            from engine import level_manager

            pos -= level_manager.level.screen_pos * Vector2(self.parallax_factor, 1.0)
            if pos.x > 160 or pos.x + self.size.x < 0:
                return

        center_image = False
        try:
            center_image = self.center_image
        except AttributeError:
            pass

        if self.show:
            img_manager.show_image(
                self.img, screen, pos, new_size=self.size, center_image=center_image, angle=self.angle, flip=self.flip
            )

        try:
            img_manager.show_image(
                self.anim.deal_with_it,
                screen,
                pos + self.anim.deal_pos + self.anim.deal_delta,
                new_size=Vector2(32, 32),
            )
        except AttributeError:
            pass
        GameObject.loop(self, screen)
Exemplo n.º 5
0
    def loop(self,screen):
        pos = self.pos-level_manager.level.screen_pos

        img_manager.show_image(self.top,screen,pos+Vector2(7,0),new_size=Vector2(31,4))
        img_manager.show_image(self.base,screen,pos+Vector2(0,4+self.nmb_size*14),new_size=Vector2(49,12))
        for j in range(self.nmb_size):
            img_manager.show_image(self.fill,screen,pos+Vector2(7,4+14*j),new_size=Vector2(31,14))
Exemplo n.º 6
0
    def loop(self,screen):
        pos = self.pos-level_manager.level.screen_pos

        img_manager.show_image(self.left,screen,pos,new_size=Vector2(12,36))
        img_manager.show_image(self.right,screen,pos+Vector2(12+self.nmb_size*16,0),new_size=Vector2(12,36))
        for i in range(self.nmb_size):
            img_manager.show_image(self.fill,screen,pos+Vector2(12+i*16,0),new_size=Vector2(16,36))
Exemplo n.º 7
0
    def update_state(self):
        lock = level_manager.level.lock
        RIGHT = input_manager.get_button('RIGHT')
        LEFT = input_manager.get_button('LEFT')
        UP = input_manager.get_button('UP')
        DOWN = input_manager.get_button('DOWN')
        A_BUTTON = input_manager.get_button('A')
        B_BUTTON = input_manager.get_button('B')
        if lock or self.life == 0:
            RIGHT = False
            LEFT = False
            UP = False
            DOWN = False
            A_BUTTON = False
            B_BUTTON = False


        
        horizontal = RIGHT-LEFT
        vertical = UP-DOWN
        
        physics_events = get_physics_event()
        
        for event in physics_events:
            #log("Physics collision: "+str(event.a.userData)+" "+str(event.b.userData)+" "+str(event.begin) +" "+str(physics_manager.get_body_position(self.obj.body).get_tuple()))
            if (event.a.userData == 2 and 15 >= event.b.userData >= 11 ) or \
                    ( event.b.userData == 2 and 15 >= event.a.userData >= 11):
                if event.begin:
                    self.foot += 1
                else:
                    self.foot -= 1
            elif (event.a.userData == 3 and event.b.userData == 11 ) or \
                    ( event.b.userData == 3  and event.a.userData == 11):
                if event.begin:
                    self.wall = 1
                else:
                    self.wall = 0

            elif (event.a.userData == 4 and event.b.userData == 11 ) or \
                    ( event.b.userData == 4  and event.a.userData == 11):
                if event.begin:
                    self.wall = 2
                else:
                    self.wall = 0
            elif (event.a.userData == 3 and event.b.userData == 12 ) or \
                    ( event.b.userData == 3  and 15 >= event.a.userData == 12):
                log("Physics: "+str(event.a.userData)+" "+str(event.b.userData))
                if event.begin:
                    self.not_sliding_wall = 1
                else:
                    self.not_sliding_wall = 0

            elif (event.a.userData == 4 and event.b.userData == 12 ) or \
                    ( event.b.userData == 4  and event.a.userData == 12):
                log("Physics: "+str(event.a.userData)+" "+str(event.b.userData))
                if event.begin:
                    self.not_sliding_wall = 2
                else:
                    self.not_sliding_wall = 0
            elif (event.a.userData == 1 and event.b.userData >= 20 and event.b.userData % 10 == 0) or \
                    ( event.b.userData == 1 and event.a.userData >= 20 and event.a.userData % 10 == 0):
                log("Touched by cat")
                if event.begin:
                    self.touched = True
                    self.cat_touched = True
                else:
                    self.touched = False
            elif (event.a.userData == 1 and event.b.userData >= 20 and event.b.userData %10 != 0) or \
                    ( event.b.userData == 1 and event.a.userData >= 20 and event.a.userData %10 != 0):
                log("Touched by bullet")
                if event.begin:
                    self.touched = True
                else:
                    self.touched = False
            if (event.a.userData == 1 and event.b.userData == 13 ) or \
                    ( event.b.userData == 1 and event.a.userData == 13):
                log("Touched by spike")
                if event.begin:
                    self.touched = True
                else:
                    self.touched = False





        if self.invincibility:
            self.invincibility -= 1

        if A_BUTTON and ((self.foot and self.jump_step) or (not self.foot and self.jump_step and self.wall)):
            if self.wall == 1:
                #going RIGHT because LEFT wall
                physics_manager.move(self.player.body, vx=self.speed)
                self.wall_jump_step = CONST.wall_jump

            elif self.wall == 2:
                physics_manager.move(self.player.body, vx=-self.speed)
                self.wall_jump_step = CONST.wall_jump
            physics_manager.jump(self.player.body)
            snd_manager.play_sound(self.jump_sound)
            self.jump_step -= 1
        elif not self.foot and not self.wall :
            self.jump_step = 0
        elif (self.foot or (not self.foot and self.wall)) and not A_BUTTON:
            self.jump_step = CONST.jump_step



        if horizontal == -1:
            #LEFT
            self.direction = False
            if self.foot:
                self.state = 'move'
            self.player.flip = True

            move_condition = self.wall != 1 and self.wall_jump_step == 0 and self.not_sliding_wall != 1
            if get_value('boss_limit') is not None:
                move_condition = move_condition and (self.player.pos + \
                                                    self.player.screen_relative_pos * \
                                                    engine.screen_size).x > get_value('boss_limit')[0]
            if move_condition:
                physics_manager.move(self.player.body, -self.speed)
        elif horizontal == 1:
            #RIGHT
            self.direction = True
            if self.foot:
                self.state = 'move'
            self.player.flip = False

            move_condition = self.wall != 2 and self.wall_jump_step == 0 and self.not_sliding_wall != 2
            if get_value('boss_limit') is not None:
                move_condition = move_condition and (self.player.pos + \
                                                    self.player.screen_relative_pos * \
                                                    engine.screen_size ).x < get_value('boss_limit')[1]
            if move_condition:
                physics_manager.move(self.player.body, self.speed)
        else:
            if self.foot:
                if self.direction:
                    self.state = 'still'
                    self.player.flip = False
                else:
                    self.state = 'still'
                    self.player.flip = True
            if self.wall_jump_step == 0:
                physics_manager.move(self.player.body, 0)

        if not self.foot:
            if self.direction:
                self.state = 'jump'
                self.player.flip = False
            else:
                self.state = 'jump'
                self.player.flip = True



        #"gravity" effect like nes game
        velocity = physics_manager.get_body_velocity(self.player.body)
        delta = self.gravity
        if self.wall and self.wall_jump_step == 0:
            velocity.y = self.wall_speed
            self.state = 'slide'
            if self.direction:
                self.player.flip = False
            else:
                self.player.flip = True
        elif self.foot:
            pass
        else:
            velocity.y += delta
        physics_manager.set_body_velocity(self.player.body, velocity)

        physics_pos = physics_manager.get_body_position(self.player.body)
        
        if physics_pos:
            pos = physics_pos-self.player.size/2
        else:
            pos = self.player.pos
        if self.player.screen_relative_pos:
            pos = pos-self.player.screen_relative_pos*engine.get_screen_size()
        self.player.pos = pos

        self.set_screen_pos()

        if self.wall_jump_step != 0:
            self.wall_jump_step -= 1

        for i in range(self.life):
            img_manager.show_image(self.heart,img_manager.buffer,pos=Vector2(i*18,0),new_size=Vector2(16,16))

        if self.move_deal:
            if self.deal_delta.y < 0:
                self.deal_delta = Vector2(0,self.deal_delta.y+1)
            elif self.dialog == 0:
                self.deal_delta = Vector2()
                if engine.textbox.finished:
                    if input_manager.get_button('A') or input_manager.get_button('B'):
                        snd_manager.set_playlist(["data/music/menu_gbjam.ogg"])
                        self.dialog = -1
                        engine.textbox.set_text("Furbrawl", "A game by Team KwaKwa")

            if not self.direction:
                self.deal_delta = Vector2(-20,self.deal_delta.y)
            else:
                self.deal_delta = Vector2(0, self.deal_delta.y)

        if self.dialog == -1 and engine.textbox.finished:
            if input_manager.get_button('A') or input_manager.get_button('B'):
                self.dialog = 1
                engine.textbox.set_text("Lead designer", "Elias Farhan")
        if self.dialog == 1 and engine.textbox.finished:
            if input_manager.get_button('A') or input_manager.get_button('B'):
                self.dialog = 2
                engine.textbox.set_text("Programmer", """Hamza "Tenchi" Haiken""")
        if self.dialog == 2 and engine.textbox.finished:
            if input_manager.get_button('A') or input_manager.get_button('B'):
                self.dialog = 3
                engine.textbox.set_text("Artist", """Josh Grilli""")
        if self.dialog == 3 and engine.textbox.finished:
            if input_manager.get_button('A') or input_manager.get_button('B'):
                self.dialog = 4
                engine.textbox.set_text("Artist", """Austin Lewis""")
        if self.dialog == 4 and engine.textbox.finished:
            if input_manager.get_button('A') or input_manager.get_button('B'):
                self.dialog = 5
                engine.textbox.set_text("Music", """Dorian SRed""")
        if self.dialog == 5 and engine.textbox.finished:
            if input_manager.get_button('A') or input_manager.get_button('B'):
                self.dialog = 6
                engine.textbox.set_text("THANKS", """For playing the game""")
        if self.dialog == 6 and engine.textbox.finished:
            if input_manager.get_button('A') or input_manager.get_button('B'):
                engine.show_dialog = False
                from levels.logo_kwakwa import Kwakwa
                level_manager.switch_level(Kwakwa())
        if self.touched and not self.invincibility and self.life > 0:
            self.life -= 1
            self.invincibility = CONST.invincibility
            self.anim_counter = self.anim_freq-1

            if self.life == 0:
                level_manager.level.game_over = True
                self.invincibility = 1000
            if self.cat_touched:
                self.touched = False
                self.cat_touched = False
        if self.invincibility > CONST.invincibility - 20 or level_manager.level.game_over:
            self.state = 'hit'

        if self.invincibility %20 > 10:
            self.player.show = False
        else:
            self.player.show = True

        if B_BUTTON and self.attacking == 0:
            self.state = 'attack'
            self.attacking = self.attack_time
        if self.attacking > 1:
            self.state = 'attack'
            self.attacking -= 1
            self.slash.update_animation(state='slash')
            slash_pos = Vector2()
            if self.direction:
                slash_pos = self.player.pos + engine.screen_size * self.player.screen_relative_pos + Vector2(self.player.size.x/1.5,0)
            else:
                slash_pos = self.player.pos + engine.screen_size * self.player.screen_relative_pos - Vector2(self.player.size.x/1.5,0)
            img_manager.show_image(self.slash.img, engine.screen, pos=slash_pos-level_manager.level.screen_pos,new_size=Vector2(36,36),flip=not self.direction)
        elif not B_BUTTON:
            self.attacking = 0
        if ( self.player.pos + engine.screen_size * self.player.screen_relative_pos ).x > 2500:
            from levels.dialog import Dialog
            boss_level = Dialog()
            boss_level.last_checkpoint = level_manager.level.last_checkpoint
            level_manager.switch_level(boss_level)
Exemplo n.º 8
0
    def update_state(self):
        player_pos = self.player.pos + self.player.screen_relative_pos * engine.screen_size

        if player_pos.x > 250 and not self.dialog:
            snd_manager.set_playlist(["data/music/intro_BOSS1_gbjam.ogg","data/music/BOSS1_gbjam.ogg"])
            self.dialog = 1
            engine.show_dialog = 1
            engine.textbox.set_text("General Meow", "We meet again, Fury")
            level_manager.level.lock = True
        if self.dialog == 1 and engine.textbox.finished:
            if input_manager.get_button('A') or input_manager.get_button('B'):
                engine.textbox.set_text("Fury", "This time you will lose more than one eye")
                self.dialog = 2
        if self.dialog == 2 and engine.textbox.finished:
            if input_manager.get_button('A') or input_manager.get_button('B'):
                engine.textbox.set_text("General Meow", "I won't, I have a panzer now")
                self.dialog = 3
        if not self.boss_fight and self.dialog == 3 and engine.textbox.finished:
            if input_manager.get_button('A') or input_manager.get_button('B'):
                self.boss_fight = True
                self.direction = 1
                engine.show_dialog = False
                level_manager.level.lock = False
                self.player.screen_relative_pos = Vector2(0.35, self.player.screen_relative_pos.y)
                self.player.pos = player_pos-self.player.screen_relative_pos*engine.screen_size
        if self.boss_fight:
            self.state = 'backward'

            set_value("boss_limit", [50,595])

        if self.state == 'idle' or self.state == 'forward' or self.state == 'backward':
            if self.index == 0 or self.index == 4 or self.index == 5:
                self.animation_delta = Vector2(0,0)
            elif self.index == 2 or self.index == 3:
                self.animation_delta = Vector2(0,2)
            elif self.index == 1:
                self.animation_delta = Vector2(0,1)

        if self.life != 0:
            self.obj.pos = physics_manager.get_body_position(self.obj.body)-self.obj.size/2
        if self.obj.show:
            img_manager.show_image(self.boss_img, engine.screen, self.obj.pos-level_manager.level.screen_pos+self.boss_delta+self.animation_delta)

        if self.state == 'backward' or self.state == 'forward':
            physics_manager.move(self.obj.body,vx=self.direction*2.5)

        if self.boss_fight:
            life_bar = sfml.RectangleShape()
            life_bar.position = (165-self.life*4,0)
            life_bar.size = (self.life*4, 10)
            life_bar.fill_color = sfml.Color.BLACK
            img_manager.buffer.draw(life_bar)
            if self.direction == -1 and (self.obj.pos+self.obj.size).x<get_value('boss_limit')[0]:
                self.state = 'backward'
                self.direction = 1
            elif self.direction == 1 and self.obj.pos.x > get_value('boss_limit')[1]:
                self.state = 'forward'
                self.direction = -1

        for event in physics_events:
            if ((event.a.userData == 5 and event.b.userData == 16) or
                    (event.b.userData == 5 and event.a.userData == 16)):

                self.in_area_left = event.begin
            elif ((event.b.userData == 6 and event.a.userData == 16) or
                    (event.a.userData == 6 and event.b.userData == 16)):
                self.in_area_right = event.begin

        if self.in_area_left:
            if not self.player.anim.direction and self.player.anim.attacking > 1 and not self.invincibility:
                self.touched()
                self.life -= 1
                self.invincibility = 20
        if self.in_area_right:
            if self.player.anim.direction and self.player.anim.attacking > 1 and not self.invincibility:
                self.touched()
                self.life -= 1
                self.invincibility = 20

        if self.life == 0 and self.dialog == 3:
            self.invincibility = 1000
            physics_manager.remove_body(self.obj.body)
            self.dialog = 4
            engine.show_dialog = 1
            engine.textbox.set_text("General Meow", "Nein Nein Nein Nein Nein Nein Nein Nein Nein")
            level_manager.level.lock = True

        if self.dialog == 4 and engine.textbox.finished:

            if input_manager.get_button('A') or input_manager.get_button('B'):
                self.obj.remove = True
                engine.textbox.set_text("Fury", "I can say nine nine times too")
                self.dialog = 5
                self.player.anim.move_deal = True
        if self.invincibility > 0:
            if (self.invincibility %20) > 10:
                self.obj.show = False
            else:
                self.obj.show = True
            self.invincibility -= 1
Exemplo n.º 9
0
 def loop(self,screen):
     pos = self.pos-level_manager.level.screen_pos
     if pos.x > 160 or pos.x + self.nmb_size.x*32+24 < 0:
         return
     img_manager.show_image(self.top_left,screen,pos,new_size=Vector2(12,12))
     img_manager.show_image(self.top_right,screen,pos+Vector2(12+self.nmb_size.x*32,0),new_size=Vector2(12,12))
     if self.show_bottom:
         img_manager.show_image(self.bottom_left,screen,pos+Vector2(0,12+self.nmb_size.y*12),new_size=Vector2(12,12))
         img_manager.show_image(self.bottom_right,screen,pos+Vector2(12+self.nmb_size.x*32,12+self.nmb_size.y*12),new_size=Vector2(12,12))
     for i in range(self.nmb_size.x):
         img_manager.show_image(self.top,screen,pos+Vector2(12+i*32,0),new_size=Vector2(32,12))
         if self.show_bottom:
             img_manager.show_image(self.bottom,screen,pos+Vector2(12+i*32,12+self.nmb_size.y*12),new_size=Vector2(32,12))
         for j in range(self.nmb_size.y):
             img_manager.show_image(self.ground,screen,pos+Vector2(12+i*32,12+j*12),new_size=Vector2(32,12))
     for j in range(self.nmb_size.y):
         img_manager.show_image(self.left, screen,pos+Vector2(0,12+j*12),new_size=Vector2(12,12))
         img_manager.show_image(self.right, screen,pos+Vector2(12+self.nmb_size.x*32,12+j*12),new_size=Vector2(12,12))
Exemplo n.º 10
0
 def loop(self,screen):
     pos = self.pos-level_manager.level.screen_pos
     for i in range(self.nmb_size):
         img_manager.show_image(self.img,screen,pos+Vector2(i*(47-self.diff),0),new_size=Vector2(47,27))