ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • 렌파이 - 3(찾기게임)
    취미 2025. 4. 13. 20:05
    반응형
    image storage_1="storage_1.png"
    image storage_2="storage_2.png"
    image storage_3="storage_3.png"
    image storage_4="storage_4.png"
    image game_storage_point="point.png"
    image game_storage_bg="storage.png"
    
    init python:
        import pygame # 클래스로 storage만들면 편리하지만 이미지를 위해 따로만듦
    
        class StorageGame(renpy.Displayable): # 게임
            def __init__(self):
                renpy.Displayable.__init__(self) # renpy의 Displayable로 구현
                self.game_speed = 1000
                self.point_up = False
                self.point_down = False
                self.point_left = False
                self.point_right = False
                self.point_x = 628
                self.point_y = 348
                self.point_img = Transform("game_storage_point")
                self.oldst = None
    
                self.sto1 = Transform("storage_1")
                self.sto1_light=True
                self.sto1_x=0
                self.sto1_y=0
                self.sto1_find=False
                self.sto2 = Transform("storage_2")
                self.sto2_light=True
                self.sto2_x=0
                self.sto2_y=0
                self.sto2_find=False
                self.sto3 = Transform("storage_3")
                self.sto3_light=True
                self.sto3_x=0
                self.sto3_y=0
                self.sto3_find=False
                self.sto4 = Transform("storage_4")
                self.sto4_light=True
                self.sto4_x=0
                self.sto4_y=0
                self.sto4_find=False
    
            def move_point(self): # 포인터이동
                if self.point_up:
                    self.point_y-=2
                if self.point_down:
                    self.point_y+=2
                if self.point_left:
                    self.point_x-=2
                if self.point_right:
                    self.point_x+=2
            
            def move_sto1(self): # 숨겨져있는곳, 해당범위안에 들어오면 안빛남
                if 308<=self.point_x+12<=403 and 371<=self.point_y+12<=418:
                    self.sto1_light=False
                else:
                    self.sto1_light=True
                if self.sto1_light:
                    self.sto1_x=0
                    self.sto1_y=0
                else:
                    self.sto1_x=1280
                    self.sto1_y=720
            def move_sto2(self):
                if 978<=self.point_x+12<=1157 and 433<=self.point_y+12<=516:
                    self.sto2_light=False
                else:
                    self.sto2_light=True
                if self.sto2_light:
                    self.sto2_x=0
                    self.sto2_y=0
                else:
                    self.sto2_x=1280
                    self.sto2_y=720
            def move_sto3(self):
                if 595<=self.point_x+12<=853 and 497<=self.point_y+12<=557:
                    self.sto3_light=False
                else:
                    self.sto3_light=True
                if self.sto3_light:
                    self.sto3_x=0
                    self.sto3_y=0
                else:
                    self.sto3_x=1280
                    self.sto3_y=720
            def move_sto4(self):
                if 125<=self.point_x+12<=220 and 435<=self.point_y+12<=502:
                    self.sto4_light=False
                else:
                    self.sto4_light=True
                if self.sto4_light:
                    self.sto4_x=0
                    self.sto4_y=0
                else:
                    self.sto4_x=1280
                    self.sto4_y=720
    
            def visit(self): # image 반환
                return [self.point_img, self.sto1, self.sto2,self.sto3,self.sto4]
    
            def render(self,width,height,st,at): # 랜더링
                render = renpy.Render(width,height)
            
                if self.oldst is None:
                    self.oldst = st 
                
                dtime = st - self.oldst 
                self.oldst = st
                #이동
                self.move_point()
                self.move_sto1()
                self.move_sto2()
                self.move_sto3()
                self.move_sto4()
                
                #랜더
                sto1_render = renpy.render(self.sto1,width,height,st,at)
                render.blit(sto1_render,(self.sto1_x,self.sto1_y))
                sto2_render = renpy.render(self.sto2,width,height,st,at)
                render.blit(sto2_render,(self.sto2_x,self.sto2_y))
                sto3_render = renpy.render(self.sto3,width,height,st,at)
                render.blit(sto3_render,(self.sto3_x,self.sto3_y))
                sto4_render = renpy.render(self.sto4,width,height,st,at)
                render.blit(sto4_render,(self.sto4_x,self.sto4_y))
    
                point_render = renpy.render(self.point_img,width,height,st,at)
                render.blit(point_render,(self.point_x,self.point_y))
                render.blit(point_render,(self.point_x + width,self.point_y))
    
                renpy.redraw(self,0)
                
                return render
            def event(self,event,x,y,st): # 키 입력 처리
                if event.type == pygame.KEYDOWN:
                    if event.key == pygame.K_SPACE: # 구역 조사
                        if self.sto1_light==False:
                            if self.sto1_find==False:
                                self.sto1_find=True
                                renpy.call_in_new_context("find_sto1")
                            else:
                                renpy.call_in_new_context("find_already")
                        if self.sto2_light==False:
                            if self.sto2_find==False:
                                self.sto2_find=True
                                renpy.call_in_new_context("find_sto2")
                            else:
                                renpy.call_in_new_context("find_already")
                        if self.sto3_light==False:
                            if self.sto3_find==False:
                                self.sto3_find=True
                                renpy.call_in_new_context("find_sto3")
                            else:
                                renpy.call_in_new_context("find_already")
                        if self.sto4_light==False:
                            if self.sto4_find==False:
                                self.sto4_find=True
                                renpy.call_in_new_context("find_sto4")
                            else:
                                renpy.call_in_new_context("find_already")
                    if event.key == pygame.K_UP:
                        self.point_up=True
                    if event.key == pygame.K_DOWN:
                        self.point_down=True
                    if event.key == pygame.K_LEFT:
                        self.point_left=True
                    if event.key == pygame.K_RIGHT:
                        self.point_right=True
                if event.type == pygame.KEYUP:
                    self.point_up=False
                    self.point_down=False
                    self.point_left=False
                    self.point_right=False
                    if self.sto1_find and self.sto2_find and self.sto3_find and self.sto4_find:
                        renpy.jump("game_storage_end")
    
        storage_game = StorageGame()
    
    screen storage_runner_game():
        add storage_game
    
    label game_storage_start:
        $ storage_game.__init__()
        scene game_storage_bg
        call screen storage_runner_game
    
    label find_sto1:
        "아무것도 없었다"
        return
    label find_sto2:
        "아무것도 없었다"
        return
    label find_sto3:
        "철사를 찾았다"
        return
    label find_sto4:
        "마취제를 찾았다"
        return
    label find_already:
        "이미 찾아본 곳이다"
        return
    반응형

    '취미' 카테고리의 다른 글

    렌파이 - 5(잡기게임)  (0) 2025.04.13
    렌파이 - 4(총쏘기)  (0) 2025.04.13
    렌파이 - 2(좌물쇠게임)  (0) 2025.04.13
    렌파이 - 1(기본)  (0) 2025.04.13
    리소스팩  (0) 2024.09.09

    댓글

Designed by Tistory.