- [FIX] Llevat tot el relacionat amb codi en C/C++
- [NEW] Fulla d'sprites de Batman - [NEW] Codi base de mini en Lua - [WIP] Treballant en el editor - [NEW] Fulla bàsica de tiles - [NEW] Afegida paleta actual
This commit is contained in:
BIN
data/batman.gif
Normal file
BIN
data/batman.gif
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.4 KiB |
120
data/editor.lua
Normal file
120
data/editor.lua
Normal file
@@ -0,0 +1,120 @@
|
||||
editor = {
|
||||
num = 1,
|
||||
map_surf = {nil,nil},
|
||||
current_layer = 1,
|
||||
current_tile = 1,
|
||||
ox = 0,
|
||||
oy = 0,
|
||||
|
||||
init = function(level_name)
|
||||
game_update = editor.update
|
||||
editor.new()
|
||||
--if level_name then
|
||||
-- editor.current_layer = 2
|
||||
--end
|
||||
end,
|
||||
|
||||
new = function()
|
||||
editor.num = 1
|
||||
editor.map_surf[1] = surf.new(256,256)
|
||||
editor.map_surf[2] = surf.new(256,256)
|
||||
editor.current_layer = 1
|
||||
editor.current_tile = 1
|
||||
editor.ox = 0
|
||||
editor.oy = 0
|
||||
end,
|
||||
|
||||
save = function()
|
||||
local base_name = "level" + tostring(editor.num)
|
||||
|
||||
end,
|
||||
|
||||
update = function()
|
||||
view.origin(editor.ox,editor.oy)
|
||||
surf.cls(66)
|
||||
pal.trans(0)
|
||||
surf.source(tiles)
|
||||
map.surf(editor.map_surf[1])
|
||||
map.draw()
|
||||
map.surf(editor.map_surf[2])
|
||||
map.draw()
|
||||
map.surf(editor.map_surf[editor.current_layer])
|
||||
|
||||
local mx,my = mouse.pos()
|
||||
local tx = (mx//8)*8
|
||||
local ty = (my//8)*8
|
||||
draw.rect(tx-1,ty-1,10, 10, 9)
|
||||
|
||||
if key.press(key.TAB) then
|
||||
game_update = editor.tile_picker_update
|
||||
elseif key.press(key.RIGHT) then
|
||||
editor.ox = editor.ox - 8
|
||||
elseif key.press(key.LEFT) then
|
||||
editor.ox = editor.ox + 8
|
||||
elseif key.press(key.DOWN) then
|
||||
editor.oy = editor.oy - 8
|
||||
elseif key.press(key.UP) then
|
||||
editor.oy = editor.oy + 8
|
||||
elseif key.press(key.N1) then
|
||||
editor.current_layer=1
|
||||
elseif key.press(key.N2) then
|
||||
editor.current_layer=2
|
||||
elseif key.press(key.N2) then
|
||||
editor.current_layer=2
|
||||
elseif key.press(key.F) then
|
||||
editor.fill(tx//8, ty//8, map.tile(mx/8, my/8))
|
||||
end
|
||||
|
||||
if mouse.down(mouse.LEFT) then
|
||||
map.tile(mx/8, my/8, editor.current_tile)
|
||||
elseif mouse.press(mouse.RIGHT) then
|
||||
editor.current_tile = map.tile(mx/8, my/8)
|
||||
end
|
||||
|
||||
view.origin(0,0)
|
||||
text(tostring(editor.current_layer),0,0,22,42)
|
||||
end,
|
||||
|
||||
fill = function(x, y, tile)
|
||||
local stack = {}
|
||||
table.insert(stack, {x = x, y = y})
|
||||
|
||||
while #stack > 0 do
|
||||
local mw, mh = surf.size(editor.map_surf[1])
|
||||
local pos = table.remove(stack)
|
||||
local px, py = pos.x, pos.y
|
||||
|
||||
map.tile(px, py, editor.current_tile)
|
||||
|
||||
if px<mw-1 and map.tile(px+1, py) == tile then table.insert(stack, {x = px + 1, y = py}) end
|
||||
if px>0 and map.tile(px-1, py) == tile then table.insert(stack, {x = px - 1, y = py}) end
|
||||
if py<mh-1 and map.tile(px, py+1) == tile then table.insert(stack, {x = px, y = py + 1}) end
|
||||
if py>0 and map.tile(px, py-1) == tile then table.insert(stack, {x = px, y = py - 1}) end
|
||||
|
||||
end
|
||||
end,
|
||||
|
||||
tile_picker_update = function()
|
||||
view.origin(0,0)
|
||||
surf.cls(66)
|
||||
pal.trans(255)
|
||||
surf.source(tiles)
|
||||
local sw,sh = surf.size(tiles)
|
||||
draw.surf(0,0,sw,sh,0,0)
|
||||
|
||||
if key.press(key.ESCAPE) then
|
||||
game_update = editor.update
|
||||
end
|
||||
|
||||
local mx,my = mouse.pos()
|
||||
local tx = (mx//8)*8
|
||||
local ty = (my//8)*8
|
||||
draw.rect(tx-1,ty-1,10, 10, 9)
|
||||
if mouse.press(mouse.LEFT) then
|
||||
editor.current_tile = (tx//8) + (ty//8) * (sw//8)
|
||||
game_update = editor.update
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
}
|
||||
5
data/game.ini
Normal file
5
data/game.ini
Normal file
@@ -0,0 +1,5 @@
|
||||
title=Tramussos
|
||||
config=tramussos
|
||||
width=128
|
||||
height=96
|
||||
zoom=5
|
||||
44
data/main.lua
Normal file
44
data/main.lua
Normal file
@@ -0,0 +1,44 @@
|
||||
require "editor"
|
||||
|
||||
function mini.init()
|
||||
sprites=surf.load("batman.gif")
|
||||
|
||||
tiles=surf.load("tiles01.gif")
|
||||
surf.source(tiles)
|
||||
|
||||
local paleta=pal.load("tiles01.gif")
|
||||
pal.set(paleta)
|
||||
|
||||
editor.init(1);
|
||||
end
|
||||
|
||||
function mini.update()
|
||||
if key.press(key.F1) then
|
||||
win.zoom(win.zoom()-1)
|
||||
elseif key.press(key.F2) then
|
||||
win.zoom(win.zoom()+1)
|
||||
elseif key.press(key.F3) then
|
||||
local fs = win.fullscreen()
|
||||
win.fullscreen(not fs)
|
||||
win.cursor(fs)
|
||||
end
|
||||
|
||||
if (game_update) then game_update() end
|
||||
--text(tostring(sys.fps()),0,0,22,42)
|
||||
end
|
||||
|
||||
function text(str,x,y,col,col2)
|
||||
draw.text(str,x-1,y-1,66)
|
||||
draw.text(str,x,y-1,66)
|
||||
draw.text(str,x+1,y-1,66)
|
||||
draw.text(str,x-1,y,66)
|
||||
draw.text(str,x+1,y,66)
|
||||
draw.text(str,x-1,y+1,66)
|
||||
draw.text(str,x+1,y+1,66)
|
||||
draw.text(str,x-1,y+2,66)
|
||||
draw.text(str,x,y+2,66)
|
||||
draw.text(str,x+1,y+2,66)
|
||||
|
||||
draw.text(str,x,y+1,col2)
|
||||
draw.text(str,x,y,col)
|
||||
end
|
||||
BIN
data/tiles01.gif
BIN
data/tiles01.gif
Binary file not shown.
|
Before Width: | Height: | Size: 526 B After Width: | Height: | Size: 884 B |
70
data/tramussos.pal
Normal file
70
data/tramussos.pal
Normal file
@@ -0,0 +1,70 @@
|
||||
JASC-PAL
|
||||
0100
|
||||
67
|
||||
255 6 255
|
||||
20 16 19
|
||||
59 23 37
|
||||
115 23 45
|
||||
180 32 42
|
||||
223 62 35
|
||||
250 106 10
|
||||
249 163 27
|
||||
255 213 65
|
||||
255 252 64
|
||||
214 242 100
|
||||
156 219 67
|
||||
89 193 53
|
||||
20 160 46
|
||||
26 122 62
|
||||
36 82 59
|
||||
18 32 32
|
||||
20 52 100
|
||||
40 92 196
|
||||
36 159 222
|
||||
32 214 199
|
||||
166 252 219
|
||||
255 255 255
|
||||
254 243 192
|
||||
250 214 184
|
||||
245 160 151
|
||||
232 106 115
|
||||
188 74 155
|
||||
121 58 128
|
||||
64 51 83
|
||||
36 34 52
|
||||
34 28 26
|
||||
50 43 40
|
||||
113 65 59
|
||||
187 117 71
|
||||
219 164 99
|
||||
244 210 156
|
||||
218 224 234
|
||||
179 185 209
|
||||
139 147 175
|
||||
109 117 141
|
||||
74 84 98
|
||||
51 57 65
|
||||
66 36 51
|
||||
91 49 56
|
||||
142 82 82
|
||||
186 117 106
|
||||
233 181 163
|
||||
227 230 255
|
||||
185 191 251
|
||||
132 155 228
|
||||
88 141 190
|
||||
71 125 133
|
||||
35 103 78
|
||||
50 132 100
|
||||
93 175 141
|
||||
146 220 186
|
||||
205 247 226
|
||||
228 210 170
|
||||
199 176 139
|
||||
160 134 98
|
||||
121 103 85
|
||||
90 78 68
|
||||
66 57 52
|
||||
10 25 48
|
||||
6 10 10
|
||||
0 0 0
|
||||
Reference in New Issue
Block a user