728x90
반응형
SMALL
마이크로 스크립트(microscript) 기본 코드
init = function()
end
update = function()
end
draw = function()
end
추가 적용된 microscript 기본 코드 문법 규칙
init = function()
position = 0
example_man2_y = 0
example_man2_vy = 0
end
update = function()
position = position + 2
example_man2_y = max(0, example_man2+example_man2_vy)
example_man2_vy = example_man2_vy = -0.3
end
draw = function()
screen.drawSprite("example man", -80, -50, 20) // if microscript type case
end
====================
캐릭터와 배경을 적용한 microscript 코드
init = function()
example_man2 = object end
example_man2.x = 0
example_man2.speed = 2
end
update = function()
if keyboard.UP then
example_man2.y += example_man2.speed
end
if keyboard.DOWN then
example_man2.y -= example_man2.speed
end
if keyboard.RIGHT then
example_man2.y += example_man2.speed
end
if keyboard.LEFT then
example_man2.y -= example_man2.speed
end
example_man2.x = clamp(example_man2.x, 60, 60)
example_man2.y = clamp(example_man2.y, 20, 20)
end
draw = function()
// set up the Background
screen.sleep()
screen.drawSprite("sky1000" 0 , 0, 300, 200)
// draw the example Man
screen.drawSprite("example_man2", example_man2.x, example_man2.y, 32, 32)
end
캐릭터를 그리고 사이즈 정합니다.
// draw the example Man
screen.drawSprite("example_man2", example_man2.x, example_man2.y, 32, 32)
=========================
실행결과
Maps 구성
--------------------------------
microStudio에서 지원되는 루아(Lua) 형식 기본 코드 (기본 코드 구조는 똑같음)
microScript와 Lua 코드 차이로서 한 가지 예는 "screen.drawSprite (microScript) / screen:drawSprite (Lua)"
"."으로 붙이냐 ":"붙이냐 차이
screen.drawSprite("example man", -80, -50, 20) // microScript style
screen:drawSprite("example man", -80, -50, 20) // Lua style
init = function()
end
update = function()
end
draw = function()
end
추가 적용된 Lua 코드 문법 규칙
init = function()
position = 0
example_man2_y = 0
example_man2_vy = 0
end
update = function()
position = position + 2
example_man2_y = max(0, example_man2+example_man2_vy)
example_man2_vy = example_man2_vy = -0.3
end
draw = function()
-- lua script uses ":"
screen:drawSprite("example man", -80, -50, 20)
end
캐릭터와 배경을 적용한 Lua 코드
init = function()
position = 0
example_man2_y = 0
example_man2_vy = 0
end
update = function()
position = position + 2
example_man2_y = max(0, example_man2+example_man2_vy)
example_man2_vy = example_man2_vy = -0.3
if touch.touching and example_man2_y == 0 then
example_man2_vy = 7
end
end
draw = function()
-- lua script uses ":"
screen:filRect(0,0, screen.width, screen.height, "rgb(57,0,57)")
screen:drawSprite("example man", -80, -50, 20)
for i=-12,12 do
screen:drawSprite("soil_32", i*50-position%50,-75,50)
end
-- screen.drawSprite("example man", -80, -50, 20) // if microscript type case
end
=====================
실행화면 (코드 한 줄이 Error가 떠서 찾는 중이라서 없어요.)
----------------------------------------
타일셋 / 캐릭터 배치 관련 Lua코드
init = function()
end
update = function()
end
draw = function()
screen:fillRect(0,0,screen.width, screen.height, "rgb(57,0,57)")
screen:drawSprite("example_man1",0-screen.width/4,-11,46)
screen:drawSprite("example_man1_1",0-screen.width/4,-11,46)
screen:drawSprite("example_man1_2",0-screen.width/4,-11,46)
screen:drawSprite("example_man1_3",0-screen.width/4,-11,46)
for i=-6,6 do
screen:drawSprite("grass1", i*30, -70, 70)
screen:drawSprite("grass2", i*40, -80, 80)
screen:drawSprite("grass3", i*40, -90, 90)
end
end
실행화면
----------------------------------------
캐릭터 무한 점프 적용 Lua 코드
init = function()
position = 0
example_man1_y = 0
example_man1_vy = 0
blades={100,200,300}
passed={0,0,0}
end
update = function()
position = position + 2
example_man1_y = math.max(0,example_man1_y + example_man1_vy)
example_man1_vy = example_man1_vy - 0.3
if touch.touching and example_man1_y == 0 then
example_man1_vy = 7
end
for i=1, #blades do
if blades[i]<position-screen.width/2 then
blades[i] = position+screen.width/2+math.random()*200
passed[i] = 0
end
if math.abs(position-blades[i])<10 then
print(math.abs(position-blades[i]))
if example_man1_y<10 then
print("충돌")
end
end
end
end
draw = function()
screen:fillRect(0,0,screen.width, screen.height, "rgb(57,0,57)")
screen:drawSprite("example_man1",0-screen.width/4,-40+example_man1_y,46)
for i=-6,6 do
screen:drawSprite("grass1", i*30, -70, 70)
screen:drawSprite("grass2", i*40, -80, 80)
screen:drawSprite("grass3", i*40, -90, 90)
end
end
실행화면 동영상
* (주의) 여기 예제나 글들은 게임개발에 도움이 되는 정보 보다는 개인 공부을 위한 것이고 옳은 방법이 아닐 수 있으니 참고바랍니다.
728x90
LIST
'Game Development Study 게임 개발 공부' 카테고리의 다른 글
[C][Raylib] Raylib 설치 및 실행 (IDE: Notepad++ 환경 기준) (0) | 2024.01.12 |
---|---|
[P5.js][Development Study 개발 공부] 2D RPG 형식 Tile Map (0) | 2023.02.16 |
[Processing 프로세싱][Development Study 개발 공부] 2D RPG 형식 Script Tile Map (0) | 2023.02.16 |
[LWJGL3] How to setting LWJGL Libraries LWJGL 라이브러리 설정 (Eclipse 이클립스) (0) | 2023.01.21 |
[WebGL][three.js][웹 기반 3D게임 개발 연구 (사이드 프로젝트)] Skybox 만들기 예제 샘플 (0) | 2023.01.15 |
댓글