Compare commits
6 Commits
v0.6.0
...
ffb4875605
| Author | SHA1 | Date | |
|---|---|---|---|
| ffb4875605 | |||
| 50842cf9c9 | |||
| 61f3c385c0 | |||
| af3b04f0ab | |||
| fa85d3cb34 | |||
| 3dfa177cd2 |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -6,3 +6,4 @@ wiki/*
|
||||
scr_min.c
|
||||
tests.lua
|
||||
fake_editor.lua
|
||||
*.bin
|
||||
|
||||
4
Makefile
Normal file
4
Makefile
Normal file
@@ -0,0 +1,4 @@
|
||||
executable = ascii
|
||||
|
||||
macos:
|
||||
g++ *.cpp ./lua/*.c -lSDL2 -o $(executable)
|
||||
@@ -120,7 +120,7 @@ void reinit() {
|
||||
cursor_x = 0;
|
||||
cursor_y = 0;
|
||||
char_screen = &mem[0];
|
||||
color_screen = &mem[1200];
|
||||
color_screen = &mem[768];
|
||||
//SDL_RenderSetLogicalSize(mini_ren, 640, 480);
|
||||
mini_bak = SDL_CreateTexture(mini_ren, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_STREAMING, 256, 192);
|
||||
break;
|
||||
|
||||
BIN
chuleta_font.png
Normal file
BIN
chuleta_font.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 35 KiB |
114
demos/lorenrunner.lua
Normal file
114
demos/lorenrunner.lua
Normal file
@@ -0,0 +1,114 @@
|
||||
score=0
|
||||
lives=5
|
||||
level=1
|
||||
tresors=0
|
||||
player = {x=0,y=0,oldtile=32,falling=false}
|
||||
malos = {
|
||||
{x=0,y=0},
|
||||
{x=0,y=0},
|
||||
{x=0,y=0}
|
||||
}
|
||||
eixida={x=0,y=0}
|
||||
|
||||
function init()
|
||||
mode(2)
|
||||
setchar(33,223,223,223,0,253,253,253,0)
|
||||
setchar(34,255,255,255,255,255,255,255,0)
|
||||
setchar(35,195,255,195,195,195,255,195,195)
|
||||
setchar(36,195,243,195,195,195,207,195,195)
|
||||
setchar(37,0,255,0,0,0,0,0,0)
|
||||
setchar(38,0,0,0,126,66,66,126,0)
|
||||
|
||||
filein("level1.bin",0,600)
|
||||
|
||||
tresors=0
|
||||
player.oldtile=32
|
||||
local m=1
|
||||
for i=0,299 do
|
||||
if peek(i) == 248 then
|
||||
poke(i,32)
|
||||
player.x=i%20
|
||||
player.y=flr(i/20)
|
||||
elseif peek(i) == 249 then
|
||||
poke(i,32)
|
||||
poke(300+i, 0x0f)
|
||||
malos[m].x=i%20
|
||||
malos[m].y=flr(i/20)
|
||||
elseif peek(i) == 36 then
|
||||
poke(i,32)
|
||||
poke(300+i, 0x0f)
|
||||
eixida.x=i%20
|
||||
eixida.y=flr(i/20)
|
||||
elseif peek(i) == 38 then
|
||||
tresors=tresors+1
|
||||
end
|
||||
end
|
||||
|
||||
ink(COLOR_YELLOW) print("000000",7,14)
|
||||
|
||||
-- anem a contar els tresors que hi ha, per a saber quan es deu activar l'escala de eixida
|
||||
end
|
||||
|
||||
function update()
|
||||
if not player.falling then
|
||||
if btnp(KEY_LEFT) and player.x>0 and peek(player.x-1+player.y*20)~=33 then
|
||||
poke(player.x+player.y*20, player.oldtile)
|
||||
player.x=player.x-1
|
||||
player.oldtile = peek(player.x+player.y*20)
|
||||
check_tresors()
|
||||
elseif btnp(KEY_RIGHT) and player.x<19 and peek(player.x+1+player.y*20)~=33 then
|
||||
poke(player.x+player.y*20, player.oldtile)
|
||||
player.x=player.x+1
|
||||
player.oldtile = peek(player.x+player.y*20)
|
||||
check_tresors()
|
||||
elseif btnp(KEY_UP) and player.oldtile==35 then
|
||||
if player.y>0 then
|
||||
poke(player.x+player.y*20, player.oldtile)
|
||||
player.y=player.y-1
|
||||
player.oldtile = peek(player.x+player.y*20)
|
||||
else
|
||||
-- endgame. Ja vorem, ara que faça el init de nou i au
|
||||
init()
|
||||
end
|
||||
elseif btnp(KEY_DOWN) and (peek(player.x+(player.y+1)*20) == 35 or player.oldtile==37) then
|
||||
poke(player.x+player.y*20, player.oldtile)
|
||||
player.y=player.y+1
|
||||
player.oldtile = peek(player.x+player.y*20)
|
||||
end
|
||||
end
|
||||
|
||||
if cnt()%5 == 0 then
|
||||
if player.oldtile~=37 and (peek(player.x+(player.y+1)*20)==32 or peek(player.x+(player.y+1)*20)==38 or peek(player.x+(player.y+1)*20)==37) then
|
||||
player.falling = true
|
||||
poke(player.x+player.y*20, player.oldtile)
|
||||
player.y=player.y+1
|
||||
player.oldtile = peek(player.x+player.y*20)
|
||||
check_tresors()
|
||||
else
|
||||
player.falling=false
|
||||
end
|
||||
end
|
||||
poke(player.x+player.y*20, 248)
|
||||
|
||||
end
|
||||
|
||||
function check_tresors()
|
||||
if player.oldtile==38 then
|
||||
player.oldtile=32
|
||||
update_score(100)
|
||||
poke(300+player.x+player.y*20, 0x0f)
|
||||
tresors=tresors-1
|
||||
if tresors==0 then
|
||||
for i=eixida.y,0,-1 do
|
||||
poke(eixida.x+i*20,35)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function update_score(points)
|
||||
score=score+points
|
||||
local str= ""..score
|
||||
while #str < 6 do str = "0"..str end
|
||||
ink(COLOR_YELLOW) print(str,7,14)
|
||||
end
|
||||
161
demos/old_sokoban.lua
Normal file
161
demos/old_sokoban.lua
Normal file
@@ -0,0 +1,161 @@
|
||||
FLOOR = 0
|
||||
GOAL = 1
|
||||
BOX = 2
|
||||
PLAYER = 4
|
||||
WALL = 7
|
||||
|
||||
function init()
|
||||
mode(2)
|
||||
level=1
|
||||
player={}
|
||||
menu.init()
|
||||
end
|
||||
|
||||
-- ====================================================================================================
|
||||
-- MENU (game state)
|
||||
-- ====================================================================================================
|
||||
blink=0
|
||||
|
||||
menu={
|
||||
init = function()
|
||||
update=menu.update
|
||||
end,
|
||||
|
||||
update = function()
|
||||
color(15,0) cls()
|
||||
ink(1) print("\x20\x20\x20\x87\x81\x87\x85\x85\x85\x87\x85\x87\x85\x87\x85\x87\x84\x20\x20\x20",0,2)
|
||||
ink(9) print("\x20\x20\x20\x83\x85\x85\x85\x8D\x81\x85\x85\x87\x84\x8D\x85\x85\x85\x20\x20\x20",0,3)
|
||||
ink(11) print("\x20\x20\x20\x83\x81\x83\x81\x81\x81\x83\x81\x83\x81\x81\x81\x81\x81\x20\x20\x20",0,4)
|
||||
ink(15*flr((blink%60)/30)) print("PRESS SPACE TO PLAY",1,9)
|
||||
blink=blink+1
|
||||
|
||||
if btnp(KEY_SPACE) then
|
||||
level=1
|
||||
game.init()
|
||||
end
|
||||
end
|
||||
}
|
||||
|
||||
-- ====================================================================================================
|
||||
-- GAME (game state)
|
||||
-- ====================================================================================================
|
||||
game={
|
||||
init = function()
|
||||
update=game.update
|
||||
level.load_from_string("####|# .#|# ###|#*@ #|# $ #|# ###|####")
|
||||
end,
|
||||
|
||||
update = function()
|
||||
border(0)
|
||||
color(1,0)
|
||||
cls()
|
||||
level.draw()
|
||||
|
||||
if btnp(KEY_UP) then level.try_move(0,-1)
|
||||
elseif btnp(KEY_DOWN) then level.try_move(0,1)
|
||||
elseif btnp(KEY_LEFT) then level.try_move(-1,0)
|
||||
elseif btnp(KEY_RIGHT) then level.try_move(1,0)
|
||||
end
|
||||
end
|
||||
}
|
||||
|
||||
-- ====================================================================================================
|
||||
-- LOADING (game state)
|
||||
-- ====================================================================================================
|
||||
loading = {
|
||||
init = function()
|
||||
border(15)
|
||||
update=loading.update
|
||||
wait=120
|
||||
end
|
||||
|
||||
function inbetween_update()
|
||||
color(15,0)
|
||||
cls()
|
||||
print("LEVEL "..level,6,6)
|
||||
print("GOOD JOB!",4,8)
|
||||
wait=wait-1
|
||||
if wait==0 then
|
||||
level=level+1
|
||||
game_init()
|
||||
end
|
||||
end
|
||||
}
|
||||
|
||||
function level_load_from_string(str)
|
||||
map={}
|
||||
local pos=0
|
||||
local y,x=1,1
|
||||
local maxx=0
|
||||
map[y] = {}
|
||||
while pos<#str do
|
||||
local chr = ascii(str,pos)
|
||||
if chr == 35 then map[y][x] = WALL end
|
||||
if chr == 64 then player.x,player.y=x,y map[y][x] = FLOOR end
|
||||
if chr == 43 then player.x,player.y=x,y map[y][x] = GOAL end
|
||||
if chr == 36 then map[y][x] = BOX end
|
||||
if chr == 42 then map[y][x] = GOAL+BOX end
|
||||
if chr == 46 then map[y][x] = GOAL end
|
||||
if chr == 32 then map[y][x] = FLOOR end
|
||||
if chr == 124 then
|
||||
y=y+1
|
||||
map[y] = {}
|
||||
if maxx < x then maxx=x end
|
||||
x=0
|
||||
end
|
||||
pos=pos+1
|
||||
x=x+1
|
||||
end
|
||||
ox = flr((20-maxx)/2)
|
||||
oy = flr((15-y)/2)
|
||||
end
|
||||
|
||||
function level_draw()
|
||||
for y=1,#map do
|
||||
for x=1,#map[y] do
|
||||
if map[y][x] == WALL then color(4,15) print("\127",ox+x-1,oy+y-1)
|
||||
elseif map[y][x] == BOX then color(0,6) print("\016",ox+x-1,oy+y-1)
|
||||
elseif map[y][x] == BOX+GOAL then color(0,4) print("\016",ox+x-1,oy+y-1)
|
||||
elseif map[y][x] == GOAL then color(4,0) print("\144",ox+x-1,oy+y-1)
|
||||
end
|
||||
end
|
||||
end
|
||||
color(15,0) print("\248",ox+player.x-1,oy+player.y-1)
|
||||
end
|
||||
|
||||
function try_move(x,y)
|
||||
if is_empty(x,y) then
|
||||
move_player(x,y)
|
||||
elseif is_box(x,y) and is_empty(x*2,y*2) then
|
||||
move_box(x,y)
|
||||
end
|
||||
end
|
||||
|
||||
function is_empty(x,y)
|
||||
return map[player.y+y][player.x+x] < 2
|
||||
end
|
||||
|
||||
function is_box(x,y)
|
||||
return map[player.y+y][player.x+x] < 4
|
||||
end
|
||||
|
||||
function move_player(x,y)
|
||||
player.x=player.x+x
|
||||
player.y=player.y+y
|
||||
end
|
||||
|
||||
function move_box(x,y)
|
||||
map[player.y+y*2][player.x+x*2] = map[player.y+y*2][player.x+x*2] + BOX
|
||||
map[player.y+y][player.x+x] = map[player.y+y][player.x+x] - BOX
|
||||
move_player(x,y)
|
||||
check_finished()
|
||||
end
|
||||
|
||||
function check_finished()
|
||||
for y=1,#map do
|
||||
for x=1,#map[y] do
|
||||
if map[y][x] == GOAL then return end
|
||||
end
|
||||
end
|
||||
inbetween_init()
|
||||
end
|
||||
9
game.lua
9
game.lua
@@ -1,9 +0,0 @@
|
||||
function init()
|
||||
setmode(0)
|
||||
cls()
|
||||
play("o4v5l1crcl4dcferl1crcl4dcgfr")
|
||||
end
|
||||
|
||||
function update()
|
||||
|
||||
end
|
||||
1
game.lua
Symbolic link
1
game.lua
Symbolic link
@@ -0,0 +1 @@
|
||||
/Users/sergio/Gitea/miniascii_jaildoc/miniascii/demos/ticker.lua
|
||||
1
scr.bin
Normal file
1
scr.bin
Normal file
@@ -0,0 +1 @@
|
||||
֏<><D68F><EFBFBD><EFBFBD>֏<EFBFBD><D68F><EFBFBD><EFBFBD>֏<EFBFBD><D68F><EFBFBD><EFBFBD>֏<EFBFBD>֏<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ԏ<EFBFBD><D48F><EFBFBD><EFBFBD>ԏ<EFBFBD><D48F><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ԏ<EFBFBD>ԏ<EFBFBD><D48F> <20><>ԏ<EFBFBD><D48F> <20><>ԏ<EFBFBD><D48F><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֏<EFBFBD><D68F><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ԏ<EFBFBD>ԏ<EFBFBD><D48F><EFBFBD><EFBFBD><EFBFBD> <20><>ԏ<EFBFBD>ԏ<EFBFBD><D48F><EFBFBD><EFBFBD>ԏ<EFBFBD><D48F><EFBFBD><EFBFBD>ԏ<EFBFBD>ԏ<EFBFBD><D48F> G A M E S Y S T E M <07><07><07><01><07>x<08><><EFBFBD>xxxx<07>x<0F><><EFBFBD>xxxxxx<0F>xxx<07>x<0C> <0F>
|
||||
Reference in New Issue
Block a user