Added demos and tools (WIP)
This commit is contained in:
94
demos/breakout.lua
Normal file
94
demos/breakout.lua
Normal file
@@ -0,0 +1,94 @@
|
|||||||
|
function init()
|
||||||
|
setmode(1)
|
||||||
|
reset()
|
||||||
|
end
|
||||||
|
|
||||||
|
function reset()
|
||||||
|
bx,by=20,28
|
||||||
|
dx,dy=-1+rnd(1)*2,-1
|
||||||
|
px=18
|
||||||
|
wait=1
|
||||||
|
speed=6
|
||||||
|
bricks = {}
|
||||||
|
for i=0,35 do bricks[i]=COLOR_RED end
|
||||||
|
for i=36,71 do bricks[i]=COLOR_BROWN end
|
||||||
|
for i=72,107 do bricks[i]=COLOR_GREEN end
|
||||||
|
for i=108,143 do bricks[i]=COLOR_YELLOW end
|
||||||
|
end
|
||||||
|
|
||||||
|
function update()
|
||||||
|
-- move ball
|
||||||
|
wait=wait-1
|
||||||
|
if wait==0 then
|
||||||
|
wait=speed
|
||||||
|
bx=bx+dx
|
||||||
|
by=by+dy
|
||||||
|
if speed<6 then
|
||||||
|
if bx==2 or bx==37 then dx=-dx play("o3l0c") end
|
||||||
|
if by<9 then
|
||||||
|
local index=flr(bx/2)-1+(by-1)*18
|
||||||
|
if bricks[index]~=COLOR_BLACK then
|
||||||
|
play("o5l0c")
|
||||||
|
bricks[index]=COLOR_BLACK
|
||||||
|
dy=-dy
|
||||||
|
else
|
||||||
|
if by==1 then dy=-dy play("o3l0c") end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if by==28 and bx>=px and bx<=px+4 then
|
||||||
|
play("o4l0c")
|
||||||
|
dy=-dy
|
||||||
|
end
|
||||||
|
if by==29 then
|
||||||
|
play("l0o3bagfedc")
|
||||||
|
reset()
|
||||||
|
end
|
||||||
|
else
|
||||||
|
if bx==2 or bx==37 then dx=-dx end
|
||||||
|
if by==9 or by==29 then dy=-dy end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- move paddle
|
||||||
|
if btn(KEY_LEFT) and px>2 then px=px-1 end
|
||||||
|
if btn(KEY_RIGHT) and px<34 then px=px+1 end
|
||||||
|
|
||||||
|
-- clear screen
|
||||||
|
paper(COLOR_BLACK)
|
||||||
|
cls()
|
||||||
|
|
||||||
|
-- draw white border
|
||||||
|
ink(COLOR_WHITE)
|
||||||
|
print("\150\154\154\154\154\154\154\154\154\154\154\154\154\154\154\154\154\154\154\154\154\154\154\154\154\154\154\154\154\154\154\154\154\154\154\154\154\156",1,0)
|
||||||
|
for i=1,29 do
|
||||||
|
print("\149",1,i)
|
||||||
|
print("\149",38,i)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- draw bricks
|
||||||
|
for i=0,143 do
|
||||||
|
color(0,bricks[i])
|
||||||
|
print("\095\003",2+2*(i%18),1+flr(i/18))
|
||||||
|
end
|
||||||
|
|
||||||
|
--draw ball
|
||||||
|
color(COLOR_WHITE,COLOR_BLACK)
|
||||||
|
print("\233",bx,by)
|
||||||
|
|
||||||
|
-- draw paddle
|
||||||
|
ink(COLOR_LIGHT_BLUE)
|
||||||
|
for i=0,3 do print("\131",px+i,29) end
|
||||||
|
|
||||||
|
if speed==6 then
|
||||||
|
ink(rnd(16))
|
||||||
|
print("BREAKOUT",16,13)
|
||||||
|
ink(COLOR_WHITE)
|
||||||
|
print("Press '1' to play EASY",9,18)
|
||||||
|
print("Press '2' to play NORMAL",8,20)
|
||||||
|
print("Press '3' to play HARD",9,22)
|
||||||
|
|
||||||
|
if btn(KEY_1) then reset() speed=4 end
|
||||||
|
if btn(KEY_2) then reset() speed=3 end
|
||||||
|
if btn(KEY_3) then reset() speed=2 end
|
||||||
|
end
|
||||||
|
end
|
||||||
140
demos/pong.lua
Normal file
140
demos/pong.lua
Normal file
@@ -0,0 +1,140 @@
|
|||||||
|
function init()
|
||||||
|
setmode(1)
|
||||||
|
setchar(94, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00)
|
||||||
|
piano = { "_____", "\143\143\143\154\154", " ", "\143\143\143\154\154", "^^^^^", "_____",
|
||||||
|
"\143\143\143\154\154", " ", "\143\143\143\154\154", " ", "\143\143\143\154\154", "^^^^^" }
|
||||||
|
notes = {"C ", "C#", "D ", "D#", "E ", "F ", "F#", "G ", "G#", "A ", "A#", "B "}
|
||||||
|
pnotes = {"c", "c#", "d", "d#", "e", "f", "f#", "g", "g#", "a", "a#", "b"}
|
||||||
|
|
||||||
|
piano_pos=18
|
||||||
|
mousewait=0
|
||||||
|
compas = 0
|
||||||
|
compasos = {}
|
||||||
|
for i=0,31 do compasos[i] = 108 end
|
||||||
|
compasos[0] = 49
|
||||||
|
compasos[1] = 49
|
||||||
|
compasos[2] = 49
|
||||||
|
compasos[7] = 50
|
||||||
|
compasos[8] = 50
|
||||||
|
compasos[9] = 50
|
||||||
|
compasos[10] = 50
|
||||||
|
|
||||||
|
old_mouse_x,old_mouse_y = 0,0
|
||||||
|
end
|
||||||
|
|
||||||
|
function update()
|
||||||
|
color(COLOR_WHITE, COLOR_BLACK)
|
||||||
|
cls()
|
||||||
|
for i=0,11 do
|
||||||
|
local k = 11-i
|
||||||
|
local pos = ((piano_pos+i)%12)+1
|
||||||
|
local oct = flr((piano_pos+i)/12)+1
|
||||||
|
color(COLOR_WHITE, COLOR_BLACK)
|
||||||
|
print(notes[pos], 1, 10+k)
|
||||||
|
color(COLOR_BLACK, COLOR_WHITE)
|
||||||
|
print(piano[pos], 3, 10+k)
|
||||||
|
color(COLOR_BLACK, COLOR_LIGHT_GRAY+flr(oct%2))
|
||||||
|
print("_______\003_______\003_______\003_______\003", 8, 10+k)
|
||||||
|
color(COLOR_BLACK, oct)
|
||||||
|
if pos==6 then
|
||||||
|
print(tostr(oct), 0, 10+k)
|
||||||
|
else
|
||||||
|
print(" ", 0, 10+k)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
piano_pos = mid(0, piano_pos+mousewheel(), 96)
|
||||||
|
|
||||||
|
if mousewait>0 then mousewait=mousewait-1 end
|
||||||
|
if mousebutton(1) and mousewait==0 then
|
||||||
|
if mousex()<8 and mousey()>=10 and mousey()<=21 then
|
||||||
|
local note = piano_pos+(11-(mousey()-10))
|
||||||
|
play("l4o"..tostr(note/12)..pnotes[(note%12)+1])
|
||||||
|
mousewait=10
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
for i=0,31 do
|
||||||
|
local n = compasos[i]
|
||||||
|
if n>=piano_pos and n<=piano_pos+11 then
|
||||||
|
if i>0 and n~=compasos[i-1] then
|
||||||
|
local oct = flr(n/12)+1
|
||||||
|
color(COLOR_BLACK, COLOR_LIGHT_GRAY+flr(oct%2))
|
||||||
|
print("\003",7+i,10+11-(n-piano_pos))
|
||||||
|
end
|
||||||
|
color(COLOR_BLACK,COLOR_LIGHT_RED)
|
||||||
|
if i==31 or compasos[i+1]~=n then
|
||||||
|
print("\003",8+i,10+11-(n-piano_pos))
|
||||||
|
else
|
||||||
|
print("_",8+i,10+11-(n-piano_pos))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if mousex()>=8 and mousey()>=10 and mousey()<=21 then
|
||||||
|
if mousebutton(1) then
|
||||||
|
compasos[mousex()-8] = piano_pos+11-(mousey()-10)
|
||||||
|
if old_mouse_x ~= mousex() or old_mouse_y ~= mousey() then
|
||||||
|
local note = piano_pos+11-(mousey()-10)
|
||||||
|
play("l4o"..tostr(note/12)..pnotes[(note%12)+1])
|
||||||
|
end
|
||||||
|
old_mouse_x,old_mouse_y = mousex(),mousey()
|
||||||
|
else
|
||||||
|
old_mouse_x,old_mouse_y = 0,0
|
||||||
|
if mousebutton(3) then
|
||||||
|
compasos[mousex()-8] = 108
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if btnp(KEY_RETURN) then play_song() end
|
||||||
|
|
||||||
|
color(15,0)print("\143",0,0)
|
||||||
|
color(14,0)print("\143",1,0)
|
||||||
|
color(12,0)print("\143",2,0)
|
||||||
|
color(6,0)print("\143",3,0)
|
||||||
|
color(4,0)print("\143",4,0)
|
||||||
|
color(5,4)print("\143",5,0)
|
||||||
|
color(9,0)print("\143",6,0)
|
||||||
|
color(1,0)print("\143",7,0)
|
||||||
|
color(0,0)print("\143",8,0)
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
function play_song()
|
||||||
|
local note_size = {1,2,3,4,6,8,12,16,24,32}
|
||||||
|
local note_names = {"c","c#","d", "d#","e","f","f#","g","g#","a","a#","b"}
|
||||||
|
local song = ""
|
||||||
|
|
||||||
|
local current_note = 255
|
||||||
|
local current_octave = 4
|
||||||
|
local p=0
|
||||||
|
while p<32 do
|
||||||
|
current_note = compasos[p]
|
||||||
|
local d=0
|
||||||
|
while current_note == compasos[p] do d=d+1 p=p+1 end
|
||||||
|
local o = flr(current_note/12)
|
||||||
|
if o<9 and current_octave~=o then
|
||||||
|
current_octave=o
|
||||||
|
song=song.."o"..tostr(o)
|
||||||
|
end
|
||||||
|
local n = current_note%12
|
||||||
|
local note = note_names[n+1]
|
||||||
|
while d>0 do
|
||||||
|
local i=1
|
||||||
|
while d>note_size[i] do i=i+1 end
|
||||||
|
if note_size[i]>d then i=i-1 end
|
||||||
|
d=d-note_size[i]
|
||||||
|
if current_length~=i-1 then
|
||||||
|
current_length = i-1
|
||||||
|
song=song.."l"..tostr(i-1)
|
||||||
|
end
|
||||||
|
if o<9 then
|
||||||
|
song=song..note
|
||||||
|
else
|
||||||
|
song=song.."r"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
play(song)
|
||||||
|
end
|
||||||
91
tools/mapedit.lua
Normal file
91
tools/mapedit.lua
Normal file
@@ -0,0 +1,91 @@
|
|||||||
|
ind = 22
|
||||||
|
function init()
|
||||||
|
setmode(2)
|
||||||
|
map = {}
|
||||||
|
col = {}
|
||||||
|
for i=0,299 do
|
||||||
|
map[i] = 32
|
||||||
|
col[i] = 0x0f
|
||||||
|
end
|
||||||
|
map[ind] = 65
|
||||||
|
sel_col = 0x0f
|
||||||
|
sel_chr = 65
|
||||||
|
end
|
||||||
|
|
||||||
|
blink=30
|
||||||
|
|
||||||
|
function update()
|
||||||
|
if btn(KEY_TAB) then
|
||||||
|
draw_picker()
|
||||||
|
update_picker()
|
||||||
|
else
|
||||||
|
draw_map()
|
||||||
|
--update_map()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function draw_picker()
|
||||||
|
for i=0,255 do
|
||||||
|
poke(i, i)
|
||||||
|
poke(300+i, sel_col)
|
||||||
|
end
|
||||||
|
for i=0,15 do
|
||||||
|
poke(580+i, i<<4)
|
||||||
|
poke(560+i, i<<4)
|
||||||
|
poke(280+i, 32)
|
||||||
|
poke(260+i, 32)
|
||||||
|
end
|
||||||
|
poke(580, 15) poke(560, 15)
|
||||||
|
poke(260+(sel_col&0xf), 203)
|
||||||
|
poke(280+(sel_col>>4), 203)
|
||||||
|
local mx, my = mousex(), mousey()
|
||||||
|
|
||||||
|
if my<13 then
|
||||||
|
poke(300+(mx+my*20), 0x4e)
|
||||||
|
print(mx+my*20, 16, 13)
|
||||||
|
elseif my>=13 then
|
||||||
|
poke(mx+my*20, 144)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function update_picker()
|
||||||
|
local mx, my = mousex(), mousey()
|
||||||
|
if mousebutton(1) then
|
||||||
|
if my<13 then
|
||||||
|
sel_chr = mx+my*20
|
||||||
|
else
|
||||||
|
if mx < 16 then
|
||||||
|
if my == 13 then
|
||||||
|
sel_col = (sel_col & 0xf0) + mx
|
||||||
|
else
|
||||||
|
sel_col = (sel_col & 0x0f) + (mx << 4)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function draw_map()
|
||||||
|
for i=0,299 do
|
||||||
|
poke(i, map[i])
|
||||||
|
poke(300+i, col[i])
|
||||||
|
end
|
||||||
|
|
||||||
|
local mx, my = mousex(), mousey()
|
||||||
|
if mousebutton(1) then
|
||||||
|
map[mx+my*20] = sel_chr
|
||||||
|
col[mx+my*20] = sel_col
|
||||||
|
end
|
||||||
|
if btn(KEY_SPACE) then
|
||||||
|
sel_chr = peek(mx+my*20)
|
||||||
|
sel_col = peek(300+mx+my*20)
|
||||||
|
end
|
||||||
|
|
||||||
|
blink = blink - 1
|
||||||
|
if blink < 30 then
|
||||||
|
if blink==0 then blink = 60 end
|
||||||
|
local mx, my = mousex(), mousey()
|
||||||
|
local c = peek(300+(mx+my*20))
|
||||||
|
poke(300+(mx+my*20), c~0xff)
|
||||||
|
end
|
||||||
|
end
|
||||||
140
tools/music.lua
Normal file
140
tools/music.lua
Normal file
@@ -0,0 +1,140 @@
|
|||||||
|
function init()
|
||||||
|
setmode(1)
|
||||||
|
setchar(94, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00)
|
||||||
|
piano = { "_____", "\143\143\143\154\154", " ", "\143\143\143\154\154", "^^^^^", "_____",
|
||||||
|
"\143\143\143\154\154", " ", "\143\143\143\154\154", " ", "\143\143\143\154\154", "^^^^^" }
|
||||||
|
notes = {"C ", "C#", "D ", "D#", "E ", "F ", "F#", "G ", "G#", "A ", "A#", "B "}
|
||||||
|
pnotes = {"c", "c#", "d", "d#", "e", "f", "f#", "g", "g#", "a", "a#", "b"}
|
||||||
|
|
||||||
|
piano_pos=18
|
||||||
|
mousewait=0
|
||||||
|
compas = 0
|
||||||
|
compasos = {}
|
||||||
|
for i=0,31 do compasos[i] = 108 end
|
||||||
|
compasos[0] = 49
|
||||||
|
compasos[1] = 49
|
||||||
|
compasos[2] = 49
|
||||||
|
compasos[7] = 50
|
||||||
|
compasos[8] = 50
|
||||||
|
compasos[9] = 50
|
||||||
|
compasos[10] = 50
|
||||||
|
|
||||||
|
old_mouse_x,old_mouse_y = 0,0
|
||||||
|
end
|
||||||
|
|
||||||
|
function update()
|
||||||
|
color(COLOR_WHITE, COLOR_BLACK)
|
||||||
|
cls()
|
||||||
|
for i=0,11 do
|
||||||
|
local k = 11-i
|
||||||
|
local pos = ((piano_pos+i)%12)+1
|
||||||
|
local oct = flr((piano_pos+i)/12)+1
|
||||||
|
color(COLOR_WHITE, COLOR_BLACK)
|
||||||
|
print(notes[pos], 1, 10+k)
|
||||||
|
color(COLOR_BLACK, COLOR_WHITE)
|
||||||
|
print(piano[pos], 3, 10+k)
|
||||||
|
color(COLOR_BLACK, COLOR_LIGHT_GRAY+flr(oct%2))
|
||||||
|
print("_______\003_______\003_______\003_______\003", 8, 10+k)
|
||||||
|
color(COLOR_BLACK, oct)
|
||||||
|
if pos==6 then
|
||||||
|
print(tostr(oct), 0, 10+k)
|
||||||
|
else
|
||||||
|
print(" ", 0, 10+k)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
piano_pos = mid(0, piano_pos+mousewheel(), 96)
|
||||||
|
|
||||||
|
if mousewait>0 then mousewait=mousewait-1 end
|
||||||
|
if mousebutton(1) and mousewait==0 then
|
||||||
|
if mousex()<8 and mousey()>=10 and mousey()<=21 then
|
||||||
|
local note = piano_pos+(11-(mousey()-10))
|
||||||
|
play("l4o"..tostr(note/12)..pnotes[(note%12)+1])
|
||||||
|
mousewait=10
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
for i=0,31 do
|
||||||
|
local n = compasos[i]
|
||||||
|
if n>=piano_pos and n<=piano_pos+11 then
|
||||||
|
if i>0 and n~=compasos[i-1] then
|
||||||
|
local oct = flr(n/12)+1
|
||||||
|
color(COLOR_BLACK, COLOR_LIGHT_GRAY+flr(oct%2))
|
||||||
|
print("\003",7+i,10+11-(n-piano_pos))
|
||||||
|
end
|
||||||
|
color(COLOR_BLACK,COLOR_LIGHT_RED)
|
||||||
|
if i==31 or compasos[i+1]~=n then
|
||||||
|
print("\003",8+i,10+11-(n-piano_pos))
|
||||||
|
else
|
||||||
|
print("_",8+i,10+11-(n-piano_pos))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if mousex()>=8 and mousey()>=10 and mousey()<=21 then
|
||||||
|
if mousebutton(1) then
|
||||||
|
compasos[mousex()-8] = piano_pos+11-(mousey()-10)
|
||||||
|
if old_mouse_x ~= mousex() or old_mouse_y ~= mousey() then
|
||||||
|
local note = piano_pos+11-(mousey()-10)
|
||||||
|
play("l4o"..tostr(note/12)..pnotes[(note%12)+1])
|
||||||
|
end
|
||||||
|
old_mouse_x,old_mouse_y = mousex(),mousey()
|
||||||
|
else
|
||||||
|
old_mouse_x,old_mouse_y = 0,0
|
||||||
|
if mousebutton(3) then
|
||||||
|
compasos[mousex()-8] = 108
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if btnp(KEY_RETURN) then play_song() end
|
||||||
|
|
||||||
|
color(15,0)print("\143",0,0)
|
||||||
|
color(14,0)print("\143",1,0)
|
||||||
|
color(12,0)print("\143",2,0)
|
||||||
|
color(6,0)print("\143",3,0)
|
||||||
|
color(4,0)print("\143",4,0)
|
||||||
|
color(5,4)print("\143",5,0)
|
||||||
|
color(9,0)print("\143",6,0)
|
||||||
|
color(1,0)print("\143",7,0)
|
||||||
|
color(0,0)print("\143",8,0)
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
function play_song()
|
||||||
|
local note_size = {1,2,3,4,6,8,12,16,24,32}
|
||||||
|
local note_names = {"c","c#","d", "d#","e","f","f#","g","g#","a","a#","b"}
|
||||||
|
local song = ""
|
||||||
|
|
||||||
|
local current_note = 255
|
||||||
|
local current_octave = 4
|
||||||
|
local p=0
|
||||||
|
while p<32 do
|
||||||
|
current_note = compasos[p]
|
||||||
|
local d=0
|
||||||
|
while current_note == compasos[p] do d=d+1 p=p+1 end
|
||||||
|
local o = flr(current_note/12)
|
||||||
|
if o<9 and current_octave~=o then
|
||||||
|
current_octave=o
|
||||||
|
song=song.."o"..tostr(o)
|
||||||
|
end
|
||||||
|
local n = current_note%12
|
||||||
|
local note = note_names[n+1]
|
||||||
|
while d>0 do
|
||||||
|
local i=1
|
||||||
|
while d>note_size[i] do i=i+1 end
|
||||||
|
if note_size[i]>d then i=i-1 end
|
||||||
|
d=d-note_size[i]
|
||||||
|
if current_length~=i-1 then
|
||||||
|
current_length = i-1
|
||||||
|
song=song.."l"..tostr(i-1)
|
||||||
|
end
|
||||||
|
if o<9 then
|
||||||
|
song=song..note
|
||||||
|
else
|
||||||
|
song=song.."r"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
play(song)
|
||||||
|
end
|
||||||
106
tools/scredit.lua
Normal file
106
tools/scredit.lua
Normal file
@@ -0,0 +1,106 @@
|
|||||||
|
ind = 22
|
||||||
|
function init()
|
||||||
|
setmode(1)
|
||||||
|
map = {}
|
||||||
|
col = {}
|
||||||
|
for i=0,1199 do
|
||||||
|
map[i] = 32
|
||||||
|
col[i] = 0x0f
|
||||||
|
end
|
||||||
|
map[ind] = 65
|
||||||
|
sel_col = 0x0f
|
||||||
|
sel_chr = 65
|
||||||
|
end
|
||||||
|
|
||||||
|
blink=30
|
||||||
|
|
||||||
|
function update()
|
||||||
|
if btn(KEY_TAB) then
|
||||||
|
draw_picker()
|
||||||
|
update_picker()
|
||||||
|
else
|
||||||
|
draw_map()
|
||||||
|
--update_map()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function draw_picker()
|
||||||
|
for y=0,15 do
|
||||||
|
for x=0,15 do
|
||||||
|
poke(x+y*40, x+y*16)
|
||||||
|
poke(1200+x+y*40, sel_col)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
for i=0,15 do
|
||||||
|
poke(1840+i, i<<4)
|
||||||
|
poke(1880+i, i<<4)
|
||||||
|
poke(640+i, 32)
|
||||||
|
poke(680+i, 32)
|
||||||
|
end
|
||||||
|
poke(1840, 15) poke(1880, 15)
|
||||||
|
poke(640+(sel_col&0xf), 203)
|
||||||
|
poke(680+(sel_col>>4), 203)
|
||||||
|
local mx, my = mousex(), mousey()
|
||||||
|
|
||||||
|
if mx<16 then
|
||||||
|
if my<16 then
|
||||||
|
poke(1200+(mx+my*40), 0x4e)
|
||||||
|
print(mx+my*40, 16, 13)
|
||||||
|
elseif my>=16 then
|
||||||
|
poke(mx+my*40, 144)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function update_picker()
|
||||||
|
local mx, my = mousex(), mousey()
|
||||||
|
if mousebutton(1) then
|
||||||
|
if mx<16 then
|
||||||
|
if my<16 then
|
||||||
|
sel_chr = mx+my*16
|
||||||
|
else
|
||||||
|
if my == 16 then
|
||||||
|
sel_col = (sel_col & 0xf0) + mx
|
||||||
|
elseif my == 17 then
|
||||||
|
sel_col = (sel_col & 0x0f) + (mx << 4)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function draw_map()
|
||||||
|
for i=0,1199 do
|
||||||
|
poke(i, map[i])
|
||||||
|
poke(1200+i, col[i])
|
||||||
|
end
|
||||||
|
|
||||||
|
local mx, my = mousex(), mousey()
|
||||||
|
if mousebutton(1) then
|
||||||
|
map[mx+my*40] = sel_chr
|
||||||
|
col[mx+my*40] = sel_col
|
||||||
|
end
|
||||||
|
if btn(KEY_SPACE) then
|
||||||
|
sel_chr = peek(mx+my*40)
|
||||||
|
sel_col = peek(1200+mx+my*40)
|
||||||
|
end
|
||||||
|
|
||||||
|
blink = blink - 1
|
||||||
|
if blink < 30 then
|
||||||
|
if blink==0 then blink = 60 end
|
||||||
|
local mx, my = mousex(), mousey()
|
||||||
|
local c = peek(1200+(mx+my*40))
|
||||||
|
poke(1200+(mx+my*40), c~0xff)
|
||||||
|
end
|
||||||
|
|
||||||
|
if btn(KEY_S) then
|
||||||
|
fileout("scr.bin", 0, 2400);
|
||||||
|
elseif btn(KEY_L) then
|
||||||
|
filein("scr.bin", 0, 2400);
|
||||||
|
for i=0,1199 do
|
||||||
|
map[i] = peek(i)
|
||||||
|
col[i] = peek(1200+i)
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
||||||
Reference in New Issue
Block a user