Beispiel #1
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
Beispiel #2
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
Beispiel #3
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
Beispiel #4
0
 def check_collision(self, pos):
     if gobj.pt_in_rect(pos, self.get_bb()):
         self.success_tile = True
         self.image = gfw.image.load(gobj.res('빈타일.png'))
         Tile.SCORE += 1
Beispiel #5
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