You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

107 lines
2.2 KiB

3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
  1. pico-8 cartridge // http://www.pico-8.com
  2. version 32
  3. __lua__
  4. -- game code
  5. function init_world()
  6. player = {}
  7. player.x = 64
  8. player.y = 16
  9. player.spr = 1
  10. drops = {}
  11. end
  12. function _init()
  13. -- button-press initial delay
  14. poke(0x5f5c, 1)
  15. -- button-press repeat
  16. poke(0x5f5d, 2)
  17. init_world()
  18. end
  19. function _update()
  20. update_player()
  21. update_drops()
  22. end
  23. function update_player()
  24. if btn(0) then
  25. player.x -= 1
  26. end
  27. if btn(1) then
  28. player.x += 1
  29. end
  30. if btn(2) then
  31. player.y -= 1
  32. end
  33. if btn(3) then
  34. player.y += 1
  35. end
  36. if (player.y < 0) player.y = 0
  37. if (player.y > 127) player.y = 127
  38. if (player.x < 0) player.x = 0
  39. if (player.x > 127) player.x = 127
  40. if btnp(🅾️) then
  41. drop = {}
  42. drop.x = player.x
  43. drop.y = player.y
  44. add(drops, drop)
  45. end
  46. end
  47. function update_drops()
  48. new_drops = {}
  49. for i=1,#drops do
  50. drop = drops[i]
  51. drop.y += 1
  52. if drop.y < 128 then
  53. add(new_drops, drop)
  54. end
  55. end
  56. drops = new_drops
  57. end
  58. function _draw()
  59. cls(blue)
  60. foreach(drops, draw_drop)
  61. spr(player.spr,player.x-1,player.y-1)
  62. print("drops: "..#drops, 1, 6, white)
  63. end
  64. function draw_drop(drop)
  65. pset(drop.x, drop.y, white)
  66. end
  67. -->8
  68. -- library
  69. black = 0
  70. dark_blue = 1
  71. dark_purple = 2
  72. dark_green = 3
  73. brown = 4
  74. dark_gray = 5
  75. light_gray = 6
  76. white = 7
  77. red = 8
  78. orange = 9
  79. yellow = 10
  80. green = 11
  81. blue = 12
  82. indigo = 13
  83. pink = 14
  84. peach = 15
  85. function print_ctr(s,y,c)
  86. print(s,64 - #s * 2,y,c)
  87. end
  88. __gfx__
  89. 000000000a0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
  90. 00000000aaa000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
  91. 007007000a0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
  92. 00077000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
  93. 00077000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
  94. 00700700000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000