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.

142 lines
7.0 KiB

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 = 60
  8. player.y = 112
  9. player.vy = 0
  10. player.flipx = false
  11. player.spr = 0
  12. player.moves = 0
  13. end
  14. function _init()
  15. -- disable btnp autorepeat
  16. poke(0x5f5c, 255)
  17. -- set peach as bg color
  18. -- instead of black
  19. palt(black, false)
  20. palt(peach, true)
  21. init_world()
  22. end
  23. function _update()
  24. update_player()
  25. end
  26. function _draw()
  27. cls(12)
  28. draw_bg()
  29. draw_player()
  30. print_ctr("b o r b",8,yellow)
  31. end
  32. function draw_bg()
  33. for i=0,15 do
  34. spr(64,i*8,120)
  35. end
  36. end
  37. function update_player()
  38. if (btn(0)) then
  39. player.x -= 1
  40. player.moves += 1
  41. player.flipx = true
  42. end
  43. if (btn(1)) then
  44. player.x += 1
  45. player.moves += 1
  46. player.flipx = false
  47. end
  48. if (btnp(🅾️)) then
  49. player.vy = -5
  50. player.jumping = true
  51. end
  52. player.y += player.vy
  53. player.vy += 0.5
  54. if (player.y > 112) then
  55. player.y = 112
  56. player.vy = 0
  57. player.jumping = false
  58. end
  59. player.spr = (player.moves / 3) % 3
  60. if (player.x < 0) player.x = 0
  61. if (player.x > 120) player.x = 120
  62. end
  63. function draw_player()
  64. spr(player.spr,player.x,player.y,1,1,player.flipx)
  65. end
  66. -->8
  67. -- library
  68. black = 0
  69. dark_blue = 1
  70. dark_purple = 2
  71. dark_green = 3
  72. brown = 4
  73. dark_gray = 5
  74. light_gray = 6
  75. white = 7
  76. red = 8
  77. orange = 9
  78. yellow = 10
  79. green = 11
  80. blue = 12
  81. indigo = 13
  82. pink = 14
  83. peach = 15
  84. function print_ctr(s,y,c)
  85. print(s,64 - #s * 2,y,c)
  86. end
  87. __gfx__
  88. ffff00ffffff00ffffff00ff00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
  89. fff0880ffff0880ffff0880f00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
  90. ffff800fffff800fffff800f00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
  91. fff0800800008008fff0800800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
  92. ff08888ff888888fff08888f00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
  93. f088888fff88888ff088888f00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
  94. 088888fffff888ff088888ff00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
  95. fff4f4fffff4f4ffff4f4fff00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
  96. 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
  97. 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
  98. 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
  99. 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
  100. 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
  101. 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
  102. 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
  103. 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
  104. 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
  105. 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
  106. 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
  107. 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
  108. 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
  109. 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
  110. 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
  111. 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
  112. 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
  113. 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
  114. 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
  115. 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
  116. 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
  117. 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
  118. 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
  119. 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
  120. 44444444000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
  121. 44444444000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
  122. 14444441000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
  123. 11144111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
  124. 11111111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
  125. 11111111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
  126. 11111111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
  127. 11111111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
  128. __gff__
  129. 0000000000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
  130. 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000