메뉴 건너뛰기

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

------------------------ 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
번호 제목 글쓴이 날짜 조회 수sort
185 자동화된 Lua 스크립트의 문서화 - LDoc 노루발 2021-01-11 43224
184 VC++ 2008 Express Edition에서 문D라이브 링크 [2] A.미스릴 2008-04-17 13090
183 cocos2d-x 터치와 업데이트 활성화 시키기 똥똥배 2011-10-27 10656
182 문D 질문 #2 [1] A.미스릴 2008-06-01 8797
181 MFC 더블 버퍼링 질문 [2] A.미스릴 2008-06-13 6602
180 문D라이브로 만드는 더블드래곤.. 질문입니다 [4] 하와이안 2009-01-15 5550
179 임의의 점이 다각형 내부에 있는지 검사하는 함수 똥똥배 2008-04-14 5358
178 문D라이브로 더블드래곤을 만들자(11) file 똥똥배 2008-05-17 4647
177 문D라이브로 더블드래곤을 만들자(1) [2] file 똥똥배 2008-04-16 4479
176 씨언어 질문 (내일 시험 ㄷㄷ) [1] 쿠로쇼우 2008-06-17 4331
175 문D라이브도 더블버퍼링이 필요한가요? [3] A.미스릴 2008-06-28 4223
174 문D라이브로 더블드래곤을 만들자(10) file 똥똥배 2008-05-17 4065
173 #define에 대해 [1] A.미스릴 2008-05-19 4061
172 클레스들을 담은 헤더들의 혼란 [4] A.미스릴 2008-06-21 3892
171 srand에 관해서 [4] A.미스릴 2008-07-15 3867
170 문D 질문 [5] A.미스릴 2008-05-26 3847
169 흥크립트에 궁금한점 [4] 상상악수 2008-08-21 3835
168 C++ 질문 [1] A.미스릴 2008-12-21 3818
167 TinyXML의 한계 [2] 똥똥배 2011-12-11 3751
166 문D라이브 2008년 5월 19일 버전 [2] 혼돈 2008-06-02 3747