Created
December 27, 2024 22:38
-
-
Save cdata/9c9ba55466553c6895944a434142457c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| pico-8 cartridge // http://www.pico-8.com | |
| version 42 | |
| __lua__ | |
| x = 16 | |
| vx = 0 | |
| y = 8 | |
| vy = 0 | |
| camera_x = 0 | |
| camera_y = 0 | |
| tx = 0 | |
| ty = 0 | |
| tx_1 = 0 | |
| ty_1 = 0 | |
| tile = 0 | |
| tile_1 = 0 | |
| jumping = false | |
| falling = false | |
| fall_frames = 0 | |
| game_over = false | |
| backpack = { | |
| collected = false, | |
| carrots = 0 | |
| } | |
| is_on_mommy = false | |
| is_on_platform = false | |
| is_in_shop = false | |
| function vec2(x, y) | |
| v = {} | |
| v.x = x | |
| v.y = y | |
| return v | |
| end | |
| carrots = { | |
| [1] = vec2(2, 2), | |
| [2] = vec2(3, 1), | |
| [3] = vec2(4, 0), | |
| [4] = vec2(5, 0), | |
| [5] = vec2(6, 0), | |
| [6] = vec2(7, 0), | |
| [7] = vec2(10, 0), | |
| [8] = vec2(11, 0), | |
| [9] = vec2(4, 3), | |
| [10] = vec2(6, 2), | |
| [11] = vec2(9, 2), | |
| [12] = vec2(2, 5), | |
| [13] = vec2(3, 5), | |
| [14] = vec2(4, 5), | |
| [15] = vec2(5, 4), | |
| [16] = vec2(8, 4), | |
| [17] = vec2(9, 4), | |
| [18] = vec2(12, 4), | |
| [18] = vec2(6, 5), | |
| [18] = vec2(7, 5), | |
| } | |
| function next_tile() | |
| return mget( | |
| flr((x + vx) / 8 + 0.5), | |
| flr((y - vy) / 8) | |
| ) | |
| end | |
| function _init() | |
| end | |
| function _update() | |
| tx = flr(x / 8 + 0.5) | |
| ty = flr(y / 8 + 0.25) | |
| tx_1 = flr((x + vx) / 8 + 0.5) | |
| ty_1 = flr((y - vy) / 8) | |
| tile = mget(tx, ty) | |
| if (vy > -4) vy -= 1 | |
| tile_1 = mget(tx_1, ty_1) | |
| is_on_mommy = tile == 21 or tile == 22 | |
| is_on_platform = tile_1 == 11 or tile_1 == 2 or tile_1 == 23 or tile_1 == 51 or tile_1 == 52 | |
| is_in_shop = tile_1 == 51 or tile_1 == 52 | |
| //if (btn(➡️) and vy != 0) then | |
| // vx = 1 | |
| //end | |
| //if (btn(⬅️) and vy != 0) then | |
| // vx = -1 | |
| //end | |
| if (is_in_shop) then | |
| backpack.collected = true | |
| end | |
| if (btn(⬆️) and not jumping and vy <= 0) then | |
| jumping = true | |
| vy = 5 | |
| end | |
| if ((is_on_platform | |
| or is_on_mommy) | |
| and vy < 0) then | |
| vy = 0 | |
| vx = 0 | |
| jumping = false | |
| y = ty_1 * 8 | |
| if (btn(➡️)) then | |
| vy = 2 | |
| vx = 1 | |
| end | |
| if (btn(⬅️)) then | |
| vy = 2 | |
| vx = -1 | |
| end | |
| if (btn(⬇️)) then | |
| vy = -4 | |
| end | |
| end | |
| y -= vy | |
| x += vx | |
| if (x > 100) then | |
| camera_x = x - 100 | |
| end | |
| if y > 200 then | |
| y = -10 | |
| end | |
| camera(camera_x, camera_y) | |
| if (vy < 0) then | |
| fall_frames += 1 | |
| else | |
| fall_frames = 0 | |
| end | |
| if (fall_frames > 20) then | |
| falling = true | |
| else | |
| falling = false | |
| end | |
| if (fall_frames > 160) then | |
| game_over = true | |
| end | |
| update_particles() | |
| update_carrots() | |
| end | |
| function _draw() | |
| cls(1) | |
| draw_particles() | |
| map(0, 0, 0, 0, 30, 20) | |
| spr(3, 106, 40) | |
| spr(4, 114, 40) | |
| for i, carrot in ipairs(carrots) do | |
| //print(i .. ") x: " .. carrot.x .. ", y: " .. carrot.y, 0, i * 8) | |
| spr(7, carrot.x * 8, carrot.y * 8) | |
| end | |
| for i=1,16 do | |
| for j = 0, 2 do | |
| base = 76 | |
| if j > 0 or i > 10 then | |
| spr(17, 8 * i, 76 + 8 * j) | |
| end | |
| end | |
| end | |
| //spr(17, 8, 84) | |
| tx = flr(x / 8) | |
| ty = flr(y / 8) | |
| tile = mget(tx, ty) | |
| if (falling) then | |
| print("aaahhhhhhhh", x - 20, y + 10) | |
| end | |
| if (is_on_mommy) then | |
| print("mommy!", x - 20, y + 10) | |
| if (backpack.collected) then | |
| print("oh look! your baby", 40, 20) | |
| print("brother is in your", 40, 28) | |
| print("backpack!", 40, 36) | |
| end | |
| end | |
| // player | |
| if (backpack.collected) then | |
| spr(14, x, y - 2) | |
| end | |
| spr(1, x, y - 2) | |
| if (game_over) then | |
| print("game over", camera_x + 46, 60) | |
| end | |
| color(1) | |
| rectfill(camera_x, 0, camera_x + 200, 8) | |
| color(0) | |
| print("carrots: " .. backpack.carrots, camera_x + 1, 1) | |
| //color(2) | |
| //rectfill(camera_x, 0, camera_x + 100, 14) | |
| //color(0) | |
| //print("fall frames: " .. fall_frames, camera_x + 1, 1) | |
| //print("game over: " .. tostring(game_over), camera_x + 1, 8) | |
| //print("tile: " .. tile .. " @ (" .. tx .. ", " .. ty .. ")", 1, 1) | |
| //print("next tile: " .. tile_1 .. " @ (" .. tx_1 .. ", " .. ty_1 .. ")" , 1, 9) | |
| //print("vel: (" .. vx .. ", " .. vy .. ")") | |
| end | |
| function update_carrots() | |
| for carrot in all(carrots) do | |
| if tx_1 == carrot.x and ty_1 == carrot.y then | |
| del(carrots, carrot) | |
| backpack.carrots += 1 | |
| particle(x + 4, y + 4) | |
| end | |
| end | |
| end | |
| particles = {} | |
| function particle(x, y) | |
| //for i=0,10 do | |
| for i=1,20 do | |
| add(particles,{x=x,y=y, | |
| dx=rnd(2)-1,dy=rnd(2)-1, | |
| rad=rnd(3),act=20, | |
| clr=rnd({1,9,10})}) | |
| end | |
| //end | |
| end | |
| function update_particles() | |
| for p in all(particles) do | |
| p.x+=p.dx*0.5 | |
| p.y+=p.dy*0.5 | |
| p.act-=1 | |
| if p.act<16 then p.rad=min(p.rad, 2) end | |
| if p.act<8 then p.rad=min(p.rad, 1) end | |
| if p.act<0 then | |
| del(particles,p) | |
| end | |
| end | |
| end | |
| function draw_particles() | |
| for p in all(particles) do | |
| circfill(p.x,p.y,p.rad,p.clr) | |
| end | |
| end | |
| __gfx__ | |
| 0000000000e00e0000000000000000000000000000000000000000000000bbbb444444b400000000ffffffff0000000055555555000000000000000000000000 | |
| 0000000000e00e00000000000e00e0000000000000444444444440000000033b5444444400000000ffffffff00000000555555550000000000000e0e00000000 | |
| 0070070000eeee00000000000e00e0000000000004000000000004000000093b4444445400000000f777777f000000005566665500000000000005e500000000 | |
| 00077000001e1e00000000000e00e02220000000400000000000004000009993444b444400000000f777777f00000000556776550000000000000aaa00000000 | |
| 0007700000e8ee00070707070eeee222220000000000000000000004000994994544444400000000f766667f00000000556776550000000000000a6a00000000 | |
| 0070070000e77e007e7e7e7e00e0e222222000000000000000000004009499904444454400000000f777777fb3b3b3b3556666550000000000000aaa00000000 | |
| 0000000000e77e00e2e2e2e20eeee222222e00000000000000000004099999004b4544b400000000ffffffff4f4ff4f455555555000000000000000000000000 | |
| 0000000000e77ee02020202000000e0e0e0000000000000000000004494900004444444400000000ffffffff5566556555555555000000000000000000000000 | |
| 00000000000000000000000000000000000000000000006666600004444444440000000000000000655565650060600000000000000000000000000000000000 | |
| 000000000000000000000000000000000000000000000666666600040404040400000000000000005c565c560066600000000000000000000600006000000000 | |
| 00000000000000000000000000000000000000000000666666666774000000000000000000000000000000000065600000000000000000000055550000000000 | |
| 0000000000e00e000000000000000000000000000006666666667774000000000000000000000000000000000065600000848000000000000055550000000000 | |
| 0000000000e00e000000000000000000000000000066666666677774000000000000000000000000000000000065600008888800000000000055550000000000 | |
| 00000000005ee5000000000000000000000000000666666666777774000000000000000000000000000000000fffff0000888000000000000055550000000000 | |
| 0000000000eeee000000000000000000000000006666666667777774b44b44b4000000000000000000000000000f000000080000000000000000000000000000 | |
| 0000000000e77e00000000000000000000000000bbbbbbbbbbbbbbb444b4b44b00000000000000000000000000e0000000000000000000000000000000000000 | |
| 00000000000000000000000044444444444444440000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 | |
| 00000000000000000000000044444444444444440000000000000000000000000000000000000000000000000000000000000000000000000007770000000000 | |
| 00000000000000000000000044444444444444440000000000000000000000000000000000000000000000000000000000000000000000000007770000099000 | |
| 00000000000000000000000044444444444444440000000000000000000000000000000000000000000000000000000000000000000000000000700000999900 | |
| 000000000000000000000000400000000000a00400000000000000000000000000000000000000000000000000000000000000000000000000b0b0b000777700 | |
| 00000000000000000000000040070000000aaa04000000000000000000000000000000000000000000000000000000000000000000000000000bbb0000776600 | |
| 00000000000000000000000040767000000aaa040000000000000000000000000000000000000000000000000000000000000000000000000000b00000777700 | |
| 00000000000000000000000040767000000aaa040000000000000000000000000000000000000000000000000000000000000000000000000000000000776600 | |
| 0000000000000000000000004076700040000004000000000000000005bbb5000000000000000000000000000000000000000000000000000000400000000000 | |
| 0555500000000000000000004076700888000004000000000000000050bbb0500000000000000000000000000000000000000000000000000004440000000000 | |
| 05ff5000000000000000000045555508880000040000000000000000055555000070070000000000000000000000000000000000000000000044444000000000 | |
| 05ff5000000000000000000040050008880000040000000003333330055555000057570000000000000000000000000000000000000000000055555000000000 | |
| 0f88f000000000000000000044444444444444440000000003bbbb3005ddd5000077770000000000000000000000000000000000000000000044444000000000 | |
| 0f88f0000000000000000000444444444444444400000000035bb5300b555b000007700000000000000000000000000000000000000000000044444000000000 | |
| 00770000000000000000000044444444444444440000000003bbbb30005550000007707000000000000000000000000000000000000000000044444000000000 | |
| 00770000000000000000000044444444444444440000000003333330005550000007770000000000000000000000000000000000000000000000000000000000 | |
| __map__ | |
| 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 | |
| 0000000002020202000002020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 | |
| 0000000200000023240000000b0b0b0b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 | |
| 000002000000023334020000000000000b0b0b0b000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 | |
| 00000000020000000000000000050600000000000b0b0b000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 | |
| 000000000002000002020000021516000b00000b0000000b0b0b000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 | |
| 00000202020202020808170808080800000000000000000000000b0000000b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 | |
| 080808080808080808080817080805060000000b000b00000000000b0b000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 | |
| 08080808081717171717171717171516000b0b0b000000000b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 | |
| 08080808170808080808080808080808000b000b0b0b0b0b0b0b0b0b0b0b0b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 | |
| 17081717080808080808080a0a0a0a0a0a00000c0c0c0c0c0c0c0c0c0c0c0c00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 | |
| 000a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a00000c0c0c0c0c0c0c0c0c0c0c0c00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 | |
| 170a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a00000c0c0c0c0c0c0c0c0c0c0c0c00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 | |
| 001717171717171717171717171717170000001a1a1a1a1a1a1a1a1a1a1a1a00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment