Ejemplo n.º 1
0
    def handle_event(self, e):
        pair = (e.type, e.key)
        if pair in Player.KEY_MAP:
            if self.target is not None:
                self.target = None
                self.delta = 0, 0
            pdx = self.delta[0]
            self.delta = gobj.point_add(self.delta, Player.KEY_MAP[pair])
            dx = self.delta[0]
            self.action = \
                0 if dx < 0 else \
                1 if dx > 0 else \
                2 if pdx < 0 else 3
        elif pair == Player.KEYDOWN_LSHIFT:
            self.mag *= 2
        elif pair == Player.KEYUP_LSHIFT:
            self.mag //= 2

        if e.type == SDL_MOUSEBUTTONDOWN:
            target = self.bg.translate(gobj.mouse_xy(e))
            self.set_target(target)
        elif e.type == SDL_MOUSEMOTION:
            if self.target is not None:
                target = self.bg.translate(gobj.mouse_xy(e))
                self.set_target(target)
Ejemplo n.º 2
0
def handle_mouse(e):
    global main_sound, capture, title
    if e.type == SDL_MOUSEMOTION:
        pos = gobj.mouse_xy(e)
        if not capture:
            if pos[1] <= canvas_height * 0.87 + 50 and pos[
                    1] >= canvas_height * 0.87 - 50:
                main_sound.play()
                for obj in gfw.world.objects_at(gfw.layer.title):
                    obj.image = gfw.image.load(gobj.res('음악선택이미지클릭.png'))
                capture = True
                return False
        if capture:
            if pos[1] > canvas_height * 0.87 + 50 or pos[
                    1] < canvas_height * 0.87 - 50:
                main_sound.stop()
                for obj in gfw.world.objects_at(gfw.layer.title):
                    obj.image = gfw.image.load(gobj.res('음악선택이미지.png'))
                capture = False
                return False
    if e.type == SDL_MOUSEBUTTONDOWN and e.button == SDL_BUTTON_LEFT:
        pos = gobj.mouse_xy(e)
        if pos[1] <= canvas_height * 0.87 and pos[
                1] >= canvas_height * 0.87 - 50 and pos[
                    0] > canvas_width // 2 and pos[0] < canvas_width * 0.9:
            main_sound.stop()
            del main_sound
            return gfw.push(main_state)
    return False
Ejemplo n.º 3
0
 def handle_event(self, e):
     if e.type == SDL_MOUSEBUTTONDOWN and e.button == SDL_BUTTON_LEFT:
         pos = gobj.mouse_xy(e)
         if gobj.pt_in_rect(pos, self.get_bb()):
             self.toggle()
             return True
     return False
Ejemplo n.º 4
0
def handle_event(e):
    global sound, check_start, score, END, PAUSE_TILE, collision_count, sound2, sound3
    if e.type == SDL_MOUSEBUTTONDOWN and e.button == SDL_BUTTON_LEFT:
        pos = gobj.mouse_xy(e)

    if e.type == SDL_QUIT:
        return gfw.quit()
    elif e.type == SDL_KEYDOWN:
        if e.key == SDLK_RETURN:
            return gfw.change(result)
        elif e.key == SDLK_p:
            PAUSE_TILE = True
            sound.pause()
        elif e.key == SDLK_s:
            PAUSE_TILE = False
            sound.resume()

    for obj in gfw.world.objects_at(gfw.layer.tile):
        obj.handle_event(e)

        if obj.success_tile:
            if check_start:
                if stage_gen.get_map_index() > 0:
                    sound.resume()
                elif stage_gen.get_map_index() > 193:
                    sound2.resume()
                elif stage_gen.get_map_index() > 370:
                    sound3.resume()
                continue
            elif check_start == False:
                Tile.start = True
        obj.sound_time = 0
Ejemplo n.º 5
0
def handle_event(e):
    global sound, check_start, score, END, PAUSE_TILE, collision_count
    if e.type == SDL_MOUSEBUTTONDOWN and e.button == SDL_BUTTON_LEFT:
        pos = gobj.mouse_xy(e)
        handle_mouse_click(pos)

    if e.type == SDL_QUIT:
        return gfw.quit()
    elif e.type == SDL_KEYDOWN:
        if e.key == SDLK_ESCAPE:
            return gfw.change(result)
        elif e.key == SDLK_p:
            PAUSE_TILE = not PAUSE_TILE
        elif e.key == SDLK_TAB:
            change_key_configs()
        elif e.key in KEYS:
            process_input(KEYS.index(e.key))

    if e.type == SDL_MOUSEBUTTONDOWN and e.button == SDL_BUTTON_LEFT:
        pos = gobj.mouse_xy(e)
Ejemplo n.º 6
0
 def handle_event(self, e):
     if self.state != STATE_ON or sun.sun_score < self.score:
         return
     if e.type == SDL_MOUSEBUTTONDOWN and e.button == SDL_BUTTON_LEFT:
         pos = gobj.mouse_xy(e)
         if gobj.pt_in_rect(pos, self.get_bb()):
             # 식물 추가하기
             m = Plant((e.x, get_canvas_height() - e.y), self.name)
             gfw.world.add(gfw.layer.plant, m)
             sun.sun_score -= self.score
             return True
     return False
Ejemplo n.º 7
0
def handle_mouse(e):
    global capture1, capture2
    if e.type == SDL_MOUSEBUTTONDOWN and e.button == SDL_BUTTON_LEFT:
        pos = gobj.mouse_xy(e)
        if not capture1:
            if pos[1] <= 170 and pos[1] >= 120 and pos[0] >= 100 and pos[
                    0] <= 290:
                capture1 = True
        if not capture2:
            if pos[1] <= 170 and pos[1] >= 120 and pos[0] >= 10 and pos[
                    0] <= 90:
                capture2 = True
    if e.type == SDL_MOUSEBUTTONUP and e.button == SDL_BUTTON_LEFT:
        pos = gobj.mouse_xy(e)
        if capture1:
            if pos[1] <= 170 and pos[1] >= 120 and pos[0] >= 100 and pos[
                    0] <= 290:
                return gfw.pop()
        if capture2:
            if pos[1] <= 170 and pos[1] >= 120 and pos[0] >= 10 and pos[
                    0] <= 90:
                return gfw.quit()
Ejemplo n.º 8
0
    def handle_event(self, e):
        global sun_score
        if self.state != STATE_ARRIVED:
            return
        if e.type == SDL_MOUSEBUTTONDOWN and e.button == SDL_BUTTON_LEFT:
            pos = gobj.mouse_xy(e)
            if gobj.pt_in_rect(pos, self.get_bb()):
                self.state = STATE_SCORED

                # 이동할 햇살 위치
                x, y = self.pos
                targetY = get_canvas_height() - TARGET_Y
                self.dir = TARGET_X - x, targetY - y
                return True
        return False
Ejemplo n.º 9
0
        def handle_event(self, e):
            global active,list,skildmg,skil

            if e.type == SDL_MOUSEBUTTONDOWN and e.button == SDL_BUTTON_LEFT:
                pos = gobj.mouse_xy(e)
                x, y = self.bg.pos
                print(x, y)
                hw = Pattern.WIDTH // 6
                hh = Pattern.HEIGHT // 6





                if gobj.pt_in_rect(pos, self.get_bb()):
                    self.toggle()
                    if 370 - hw < x < 370 + hw and 300-hh<y<300+hh:
                        if self.image==self.fg:
                            list[0] = 1
                        else:
                            list[0] =0
                    elif 480 - hw < x < 480 + hw and 300-hh<y<300+hh:
                        if self.image == self.fg:
                            list[1] = 1
                        else:
                            list[1] = 0
                    elif 590 - hw < x < 590 + hw and 300-hh<y<300+hh:
                        if self.image == self.fg:
                            list[2] = 1
                        else:
                            list[2] = 0
                    elif 370 - hw < x < 370 + hw and 190-hh<y<190+hh:
                        if self.image == self.fg:
                            list[3] = 1
                        else:
                            list[3] = 0
                    elif 480 - hw < x < 480 + hw and 190-hh<y<190+hh:
                        if self.image == self.fg:
                            list[4] = 1
                        else:
                            list[4] = 0
                    elif 590 - hw < x < 590 + hw and 190-hh<y<190+hh:
                        if self.image == self.fg:
                            list[5] = 1
                        else:
                            list[5] = 0
                    elif 370 - hw < x < 370 + hw and 80-hh<y<80+hh:
                        if self.image == self.fg:
                            list[6] = 1
                        else:
                            list[6] = 0
                    elif 480 - hw < x < 480 + hw and 80-hh<y<80+hh:
                        if self.image == self.fg:
                            list[7] = 1
                        else:
                            list[7] = 0
                    elif 590 - hw < x < 590 + hw and 80-hh<y<80+hh:
                        if self.image == self.fg:
                            list[8] = 1
                        else:
                            list[8] = 0




                    print(list)

                    if list == [1, 1, 1, 1, 1, 1, 1, 1, 1]:
                        active = True
                        skil=9
                        skildmg = 300
                        list = [0, 0, 0, 0, 0, 0, 0, 0, 0]



                    elif list == [1, 1, 1, 0, 0, 1, 0, 0, 1]:
                        active = True
                        skildmg = 100
                        skil = 5
                        list = [0, 0, 0, 0, 0, 0, 0, 0, 0]

                    elif list == [1, 1, 1, 0, 0, 0, 0, 0, 0]:
                        active = True
                        skildmg = 50
                        skil = 2
                        list = [0, 0, 0, 0, 0, 0, 0, 0, 0]


                    elif list == [1, 0, 0, 0, 1, 0, 0, 0, 1]:
                        active = True
                        skildmg=50
                        skil=3
                        list=[0,0,0,0,0,0,0,0,0]





                    return True


            return False
Ejemplo n.º 10
0
 def handle_event(self, e):
     if e.type == SDL_MOUSEBUTTONDOWN and e.button == SDL_BUTTON_LEFT:
         pos = gobj.mouse_xy(e)
         self.check_collision(pos[0], pos[1])