메뉴 건너뛰기

창작에 관련된 질문이나 간단한 팁, 예제를 올리는 곳

------------------------ stairs.lua ------------------------


Stairs = {}


function Stairs:new(x, y, floor, direction, locked)

local newStairs = {x = x, y = y, floor = floor, direction = direction, locked = locked}

self.__index = self

return setmetatable(newStairs, self)

end


function Stairs:draw()

print("Stairs - X:" .. self.x .. " Y:" .. self.y .. " floor: " .. self.floor .. " direction: " .. self.direction .. " locked: " .. tostring(self.locked))

end


------------------------ main.lua ------------------------


require "stairs"


game = {}

game.stairs = {}

table.insert(game.stairs, Stairs:new(2, 6, 1, "up", false))

table.insert(game.stairs, Stairs:new(18, 9, 1, "down", false))

table.insert(game.stairs, Stairs:new(6, 2, 2, "up", false))

table.insert(game.stairs, Stairs:new(7, 12, 2, "down", false))

table.insert(game.stairs, Stairs:new(5, 5, 1, "up", true))


for a = 1, #game.stairs do

game.stairs[a]:draw() --same with game.stairs[a].draw(game.stairs[a])

end


print("Is game.stairs[1] locked? - " .. tostring(game.stairs[1].locked))


------------------------

분류 :
조회 수 :
23
등록일 :
2020.11.06
21:53:00 (*.127.102.18)
엮인글 :
게시글 주소 :
https://hondoom.com/zbxe/index.php?mid=study&document_srl=818619
List of Articles
번호 제목 글쓴이 날짜 조회 수
18 certbot을 이용한 HTTPS 인증서 발급 및 적용 노루발 2021-01-12 18
17 자동화된 Lua 스크립트의 문서화 - LDoc 노루발 2021-01-11 43224
16 리캡챠 적용 [1] 노루발 2021-01-08 11
15 Oracle cloud에 Nginx/MariaDB 설치하기 노루발 2020-12-06 93
14 Love2d로 만든 로그라이크 예제 노루발 2020-11-30 250
13 Love2d 이미지 하얗게 그리기 노루발 2020-11-23 42
12 루아 스타일 가이드 노루발 2020-11-19 33
11 턴 기반 시스템 구현에 대한 글 [4] 노루발 2020-11-14 440
10 이쁜 눈나가 유니티 개발 알려주는 재생목록 노루발 2020-11-12 37
9 love2d에서 안드로이드 터치 제스처 인식하기 노루발 2020-11-12 20
8 특정좌표를 기준으로 zoom in/zoom out하기 노루발 2020-11-11 57
» Lua 클래스 만들고 활용하기 노루발 2020-11-06 23
6 Lua 테이블 안에 함수 저장하기 노루발 2020-11-06 28
5 Lua 인수로 nil값이 들어왔을 경우 처리하기 노루발 2020-11-06 35
4 Windows To Go와 R-Studio를 이용한 손실된 데이터 복구하기 노루발 2020-01-30 88
3 Love2d DPI 이슈 해결 [3] 노루발 2019-06-29 97
2 Love2d 게임 중간에 광고 표시 [1] 노루발 2015-11-12 377
1 문D라이브 2008년 5월 19일 버전 [2] 혼돈 2008-06-02 3747