diff --git a/picogora.p8 b/picogora.p8 index 30ce8c8..1a46034 100644 --- a/picogora.p8 +++ b/picogora.p8 @@ -3,6 +3,8 @@ version 32 __lua__ -- game code +bg = 12 + function init_world() player = {} player.x = 64 @@ -10,6 +12,10 @@ function init_world() player.spr = 1 drops = {} + ramps = {} + add_ramp(50,20,15,10) + add_ramp(60,50,15,-15) + add_ramp(50,60,20,0) end function _init() @@ -25,6 +31,15 @@ function _update() update_drops() end +function add_ramp(x,y,dx,dy) + r = {} + r.x = x + r.y = y + r.dx = dx + r.dy = dy + add(ramps, r) +end + function update_player() if btn(0) then player.x -= 1 @@ -52,6 +67,7 @@ function update_player() end function update_drops() + draw_world() new_drops = {} for i=1,#drops do drop = drops[i] @@ -64,12 +80,21 @@ function update_drops() end function _draw() - cls(blue) - foreach(drops, draw_drop) + draw_world() spr(player.spr,player.x-1,player.y-1) print("drops: "..#drops, 1, 6, white) end +function draw_world() + cls(bg) + foreach(drops, draw_drop) + foreach(ramps, draw_ramp) +end + +function draw_ramp(r) + line(r.x,r.y,r.x+r.dx,r.y+r.dy,brown) +end + function draw_drop(drop) pset(drop.x, drop.y, white) end