erste programme
This commit is contained in:
122
cards/cave.p8
Normal file
122
cards/cave.p8
Normal file
@@ -0,0 +1,122 @@
|
|||||||
|
pico-8 cartridge // http://www.pico-8.com
|
||||||
|
version 42
|
||||||
|
__lua__
|
||||||
|
function _init()
|
||||||
|
game_over=false
|
||||||
|
make_cave()
|
||||||
|
make_player()
|
||||||
|
end
|
||||||
|
|
||||||
|
function _update()
|
||||||
|
if (not game_over) then
|
||||||
|
update_cave()
|
||||||
|
move_player()
|
||||||
|
check_hit()
|
||||||
|
else
|
||||||
|
if (btnp(5)) _init()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function _draw()
|
||||||
|
cls()
|
||||||
|
draw_cave()
|
||||||
|
draw_player()
|
||||||
|
|
||||||
|
if (game_over) then
|
||||||
|
print("game over!",44,44,7)
|
||||||
|
print("your scrore:"..player.score,34,54,7)
|
||||||
|
print("press ❎ to play again!",18,72,6)
|
||||||
|
else
|
||||||
|
print("score:"..player.score,2,2,7)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-->8
|
||||||
|
function make_player()
|
||||||
|
player={}
|
||||||
|
player.x=24
|
||||||
|
player.y=60
|
||||||
|
player.dy=0
|
||||||
|
player.rise=1
|
||||||
|
player.fall=2
|
||||||
|
player.dead=3
|
||||||
|
player.speed=2
|
||||||
|
player.score=0
|
||||||
|
end
|
||||||
|
|
||||||
|
function draw_player()
|
||||||
|
sprite=1
|
||||||
|
if (game_over) then
|
||||||
|
sprite=player.dead
|
||||||
|
elseif (player.dy<0) then
|
||||||
|
sprite=player.rise
|
||||||
|
else
|
||||||
|
sprite=player.fall
|
||||||
|
end
|
||||||
|
spr(sprite,player.x,player.y)
|
||||||
|
end
|
||||||
|
|
||||||
|
function move_player()
|
||||||
|
gravity=0.2
|
||||||
|
player.dy+=gravity
|
||||||
|
if (btnp(⬆️)) then
|
||||||
|
player.dy-=3
|
||||||
|
sfx(0)
|
||||||
|
end
|
||||||
|
player.y+=player.dy
|
||||||
|
player.score+=player.speed
|
||||||
|
end
|
||||||
|
|
||||||
|
function check_hit()
|
||||||
|
for i=player.x,player.x+7 do
|
||||||
|
if (cave[i+1].top>player.y) or (cave[i+1].btm<player.y) then
|
||||||
|
game_over=true
|
||||||
|
sfx(1)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-->8
|
||||||
|
function make_cave()
|
||||||
|
cave={{["top"]=4,["btm"]=119}}
|
||||||
|
top=45
|
||||||
|
btm=85
|
||||||
|
end
|
||||||
|
|
||||||
|
function update_cave()
|
||||||
|
if(#cave>player.speed) then
|
||||||
|
for i=1,player.speed do
|
||||||
|
del(cave,cave[1])
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
while (#cave<128) do
|
||||||
|
local col={}
|
||||||
|
local up=flr(rnd(7)-3)
|
||||||
|
local down=flr(rnd(7)-3)
|
||||||
|
col.top=mid(3,cave[#cave].top+up,top)
|
||||||
|
col.btm=mid(btm,cave[#cave].btm+down,124)
|
||||||
|
add(cave,col)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function draw_cave()
|
||||||
|
top_color=5
|
||||||
|
btm_color=5
|
||||||
|
for i=1,#cave do
|
||||||
|
line(i-1,0,i-1,cave[i].top,top_color)
|
||||||
|
line(i-1,127,i-1,cave[i].btm,btm_color)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
__gfx__
|
||||||
|
0000000000aaaa0000aaaa0000888800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||||
|
000000000aaaaaa00aaaaaa008888880000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||||
|
00700700aa0aa0aaaa0aa0aa88888888000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||||
|
00077000aaaaaaaaaaaaaaaa88988988000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||||
|
00077000aaaaaaaaaaaaaaaa88888888000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||||
|
00700700aa0000aaaaa00aaa88899888000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||||
|
000000000aa00aa00aa00aa008988980000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||||
|
0000000000aaaa0000aaaa0000888800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||||
|
__sfx__
|
||||||
|
000400001105012050000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||||
|
000a00002c05000000260501e0001f050070400704008040070300803008030070300801008010070100700000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||||
63
cards/frame.p8
Normal file
63
cards/frame.p8
Normal file
@@ -0,0 +1,63 @@
|
|||||||
|
pico-8 cartridge // http://www.pico-8.com
|
||||||
|
version 43
|
||||||
|
__lua__
|
||||||
|
-- game main loop
|
||||||
|
|
||||||
|
game_state={
|
||||||
|
state = 1 -- 1: title 2: game 3: over
|
||||||
|
}
|
||||||
|
|
||||||
|
function _init()
|
||||||
|
end
|
||||||
|
|
||||||
|
function _update()
|
||||||
|
|
||||||
|
-- update game_objects
|
||||||
|
for object in all(game_objects) do
|
||||||
|
object:update()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function _draw()
|
||||||
|
|
||||||
|
-- draw game_objects
|
||||||
|
for object in all(game_objects) do
|
||||||
|
object:draw()
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
-->8
|
||||||
|
-- game objects
|
||||||
|
|
||||||
|
game_objects={}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
--[[ template:
|
||||||
|
function make_object(_x,_y)
|
||||||
|
|
||||||
|
local object={
|
||||||
|
x=_x,
|
||||||
|
y=_y
|
||||||
|
}
|
||||||
|
|
||||||
|
function object:update()
|
||||||
|
end
|
||||||
|
|
||||||
|
function object:draw()
|
||||||
|
spr(1,x,y)
|
||||||
|
end
|
||||||
|
|
||||||
|
add(game_objects, object)
|
||||||
|
return object
|
||||||
|
end
|
||||||
|
--]]
|
||||||
|
|
||||||
|
__gfx__
|
||||||
|
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||||
|
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||||
|
00700700000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||||
|
00077000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||||
|
00077000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||||
|
00700700000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||||
47
cards/test.p8
Normal file
47
cards/test.p8
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
pico-8 cartridge // http://www.pico-8.com
|
||||||
|
version 43
|
||||||
|
__lua__
|
||||||
|
-- main program block
|
||||||
|
|
||||||
|
function _init()
|
||||||
|
mode = 1
|
||||||
|
end
|
||||||
|
|
||||||
|
function _update()
|
||||||
|
if (mode == 1) then
|
||||||
|
if (btnp(5)) mode = 2
|
||||||
|
elseif (mode == 2) then
|
||||||
|
if (btnp(5)) mode = 3
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function _draw()
|
||||||
|
cls()
|
||||||
|
if (mode == 1) then
|
||||||
|
title()
|
||||||
|
elseif (mode == 2) then
|
||||||
|
print("press 'x' to win")
|
||||||
|
else
|
||||||
|
end_screen()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function title()
|
||||||
|
x=60
|
||||||
|
y=60
|
||||||
|
print("press 'x' to start game")
|
||||||
|
print("\^o8ffhello world",x,y,10)
|
||||||
|
end
|
||||||
|
|
||||||
|
function end_screen()
|
||||||
|
print("a winner is you")
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
__gfx__
|
||||||
|
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||||
|
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||||
|
00700700000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||||
|
00077000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||||
|
00077000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||||
|
00700700000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||||
Reference in New Issue
Block a user