๋‚ด ์ธ์ƒ์—์„œ ๋ฏฟ์„ ๊ฑด ์˜ค์ง ๋‚˜ ์ž์‹ ๋ฟ!

The only one you can truly trust is yourself.

๊ฒŒ์ž„ ํ”„๋กœ๊ทธ๋ž˜๋ฐ/๋ ŒํŒŒ์ด(Ren'Py)

๋ ŒํŒŒ์ด $์™€ define์˜ ์ฐจ์ด์ 

๐ŸŽฎinspirer9 2024. 11. 27. 14:59
728x90
๋ฐ˜์‘ํ˜•

1. define

  • ์‚ฌ์šฉ ์šฉ๋„: ๊ฒŒ์ž„ ์‹œ์ž‘ ์ „์— ๊ณ ์ •๊ฐ’(์ƒ์ˆ˜ ๋˜๋Š” ์ „์—ญ ๋ณ€์ˆ˜)์„ ์ •์˜ํ•  ๋•Œ ์‚ฌ์šฉ.
  • ํŠน์ง•:
    • ๋ณ€์ˆ˜๊ฐ€ ์Šคํฌ๋ฆฝํŠธ ๋กœ๋“œ ์‹œ์ ์— ์ดˆ๊ธฐํ™”๋ฉ๋‹ˆ๋‹ค.
    • ๊ฐ’์„ ๋ณ€๊ฒฝํ•˜์ง€ ์•Š๋Š” ๊ณ ์ •๊ฐ’(์ƒ์ˆ˜)์ฒ˜๋Ÿผ ์‚ฌ์šฉํ•˜๊ฑฐ๋‚˜, ๊ธ€๋กœ๋ฒŒ ๋ณ€์ˆ˜๋กœ ์‚ฌ์šฉ๋ฉ๋‹ˆ๋‹ค.
    • ๋ณ€์ˆ˜์˜ ๊ฐ’์ด ๊ฒŒ์ž„ ์ €์žฅ ์ƒํƒœ์— ํฌํ•จ๋˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค.
    • ์ฃผ๋กœ UI ์„ค์ •, ์บ๋ฆญํ„ฐ ์ •์˜, ์ƒ์ˆ˜๊ฐ’ ์„ค์ • ๋“ฑ์— ์ ํ•ฉํ•ฉ๋‹ˆ๋‹ค.
 
define player_name = "Alice"
define max_health = 100
  • ์‚ฌ์šฉ ์ƒํ™ฉ:
    • ์บ๋ฆญํ„ฐ ์ด๋ฆ„, UI ์„ค์ •๊ฐ’ ๋“ฑ ๊ฒŒ์ž„ ์‹œ์ž‘ ์‹œ ๊ณ ์ •๋˜๊ฑฐ๋‚˜ ์ž˜ ๋ณ€ํ•˜์ง€ ์•Š๋Š” ๊ฐ’.
label start:
    "Player name is [player_name]."
    return

 

2. $ (Python ๊ตฌ๋ฌธ)

  • ์‚ฌ์šฉ ์šฉ๋„: ๊ฒŒ์ž„ ์‹คํ–‰ ์ค‘์— ๊ฐ’์„ ํ• ๋‹นํ•˜๊ฑฐ๋‚˜ ์ˆ˜์ •ํ•  ๋•Œ ์‚ฌ์šฉ.
  • ํŠน์ง•:
    • ๋ณ€์ˆ˜๊ฐ€ ๊ฒŒ์ž„ ์ง„ํ–‰ ์ค‘์— ๋™์ ์œผ๋กœ ์„ค์ •๋ฉ๋‹ˆ๋‹ค.
    • ๊ฒŒ์ž„ ์ €์žฅ ์ƒํƒœ์— ํฌํ•จ๋˜๋ฉฐ, ์ดํ›„ ๋กœ๋“œ ์‹œ ๊ฐ’์„ ๋ณต์›ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
    • ๊ฒŒ์ž„ ๋‚ด์—์„œ ์ˆ˜์‹œ๋กœ ๋ณ€๊ฒฝ๋˜๋Š” ๊ฐ’์„ ์„ค์ •ํ•  ๋•Œ ์ ํ•ฉํ•ฉ๋‹ˆ๋‹ค.
$ score = 0
$ player_name = "Bob"
  • ์‚ฌ์šฉ ์ƒํ™ฉ:
    • ํ”Œ๋ ˆ์ด์–ด ์ง„ํ–‰ ์ƒํ™ฉ์„ ์ €์žฅํ•˜๊ฑฐ๋‚˜ ๋™์ ์œผ๋กœ ๋ณ€ํ•ด์•ผ ํ•˜๋Š” ๊ฐ’.
label start:
    $ score += 10 
    "Your score is [score]." 
    return

 

์ฐจ์ด๋ฅผ ์š”์•ฝํ•˜๋ฉด:

ํŠน์ง• define $
์„ค์ • ์‹œ์  ์Šคํฌ๋ฆฝํŠธ ๋กœ๋“œ ์‹œ์  (์ดˆ๊ธฐํ™” ์‹œ) ๊ฒŒ์ž„ ์‹คํ–‰ ์ค‘ (๋™์ ์œผ๋กœ ์„ค์ • ๊ฐ€๋Šฅ)
๊ฐ’์˜ ๋ณ€๊ฒฝ ๊ณ ์ •๋œ ๊ฐ’์œผ๋กœ ์ฃผ๋กœ ์‚ฌ์šฉ (๋ณ€๊ฒฝ ๋ถˆ๊ฐ€ ๊ถŒ์žฅ) ์ž์œ ๋กญ๊ฒŒ ๋ณ€๊ฒฝ ๊ฐ€๋Šฅ
์ €์žฅ ์—ฌ๋ถ€ ์ €์žฅ ์ƒํƒœ์— ํฌํ•จ๋˜์ง€ ์•Š์Œ ์ €์žฅ ์ƒํƒœ์— ํฌํ•จ๋จ
์ ํ•ฉํ•œ ์šฉ๋„ ์ƒ์ˆ˜๊ฐ’, ์บ๋ฆญํ„ฐ, UI ์ดˆ๊ธฐ๊ฐ’ ์„ค์ • ๊ฒŒ์ž„ ์ง„ํ–‰ ๋ฐ์ดํ„ฐ, ํ”Œ๋ ˆ์ด์–ด ์ ์ˆ˜ ๋“ฑ ๋™์  ๋ฐ์ดํ„ฐ

 

ํ•จ๊ป˜ ์‚ฌ์šฉํ•  ์ˆ˜๋„ ์žˆ์Œ

define์œผ๋กœ ์ดˆ๊ธฐ๊ฐ’์„ ์„ค์ •ํ•˜๊ณ , $๋ฅผ ํ†ตํ•ด ๊ฒŒ์ž„ ๋‚ด์—์„œ ๊ฐ’์„ ๋ณ€๊ฒฝํ•˜๋Š” ๋ฐฉ์‹๋„ ์ž์ฃผ ์‚ฌ์šฉ๋ฉ๋‹ˆ๋‹ค.

define player_name = "Alice"

label start:
    $ player_name = renpy.input("What is your name?")
    "Nice to meet you, [player_name]!"
    return

์ด๋ ‡๊ฒŒ ํ•˜๋ฉด, ์ดˆ๊ธฐ๊ฐ’(Alice)์€ ์œ ์ง€๋˜์ง€๋งŒ ๊ฒŒ์ž„ ์ง„ํ–‰ ์ค‘์— ํ”Œ๋ ˆ์ด์–ด๊ฐ€ ์ž…๋ ฅํ•œ ๊ฐ’์œผ๋กœ ๋ณ€๊ฒฝ๋ฉ๋‹ˆ๋‹ค.

728x90
๋ฐ˜์‘ํ˜•