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.

232 lines
14 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
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
3 years ago
  1. pico-8 cartridge // http://www.pico-8.com
  2. version 32
  3. __lua__
  4. -- game code
  5. -- player states enum
  6. walk = 0
  7. stand = 1
  8. fly = 2
  9. glide = 3
  10. function init_world()
  11. player = {
  12. x = 60,
  13. y = 112,
  14. vy = 0,
  15. flipx = false,
  16. spr = 0,
  17. state = stand,
  18. time = 0
  19. }
  20. end
  21. function _init()
  22. -- disable btnp autorepeat
  23. poke(0x5f5c, 255)
  24. -- set peach as bg color
  25. -- instead of black
  26. palt(black, false)
  27. palt(peach, true)
  28. init_world()
  29. end
  30. function _update()
  31. update_player()
  32. end
  33. function set_state(state)
  34. if (player.state == state) return
  35. player.state = state
  36. player.time = 0
  37. end
  38. function _draw()
  39. cls(12)
  40. camera_x = mid(0, 896, player.x - 64)
  41. camera(camera_x, 0)
  42. draw_bg()
  43. draw_player()
  44. camera(0, 0)
  45. print_ctr("b o r b",8,yellow)
  46. --print(player.state.." "..player.time)
  47. end
  48. function draw_bg()
  49. map(0, 0, 0, 0, 128, 16)
  50. end
  51. function update_player()
  52. if (btnp(🅾️)) then
  53. player.vy = -5
  54. set_state(fly)
  55. end
  56. dx = bool2int(btn(1)) - bool2int(btn(0))
  57. if (dx != 0) then
  58. if player.state >= fly then
  59. dx *= 2
  60. end
  61. player.x += dx
  62. player.flipx = dx < 0
  63. if player.state == stand then
  64. set_state(walk)
  65. end
  66. elseif player.state == walk then
  67. set_state(stand)
  68. end
  69. player.y += player.vy
  70. player.vy += 0.5
  71. if player.vy > 0 and btn(🅾️) and player.state >= fly then
  72. if player.state == fly then
  73. set_state(glide)
  74. end
  75. player.vy = 0.2
  76. end
  77. if (player.y > 112) then
  78. player.y = 112
  79. player.vy = 0
  80. if player.state >= fly then
  81. set_state(stand)
  82. end
  83. end
  84. terrain = mget((player.x+4)/8,(player.y+8)/8)
  85. if player.vy > 0 and fget(terrain, 0) then
  86. player.y = ((player.y + 1)\ 8) * 8
  87. player.vy = 0
  88. if player.state >= fly then
  89. set_state(stand)
  90. end
  91. end
  92. player.x = mid(0, player.x, 1016)
  93. -- update sprite
  94. if player.state == stand then
  95. player.spr = 1
  96. elseif player.state == glide then
  97. if player.time % 16 >= 14 then
  98. player.spr = 1
  99. else
  100. player.spr = 3
  101. end
  102. elseif player.state == walk then
  103. player.spr = (player.time / 2) % 2 + 1
  104. else
  105. player.spr = (player.time / 2) % 3 + 1
  106. end
  107. player.time += 1
  108. end
  109. function draw_player()
  110. spr(player.spr,player.x,player.y,1,1,player.flipx)
  111. end
  112. -->8
  113. -- library
  114. black = 0
  115. dark_blue = 1
  116. dark_purple = 2
  117. dark_green = 3
  118. brown = 4
  119. dark_gray = 5
  120. light_gray = 6
  121. white = 7
  122. red = 8
  123. orange = 9
  124. yellow = 10
  125. green = 11
  126. blue = 12
  127. indigo = 13
  128. pink = 14
  129. peach = 15
  130. function print_ctr(s,y,c)
  131. print(s,64 - #s * 2,y,c)
  132. end
  133. function bool2int(b)
  134. return b and 1 or 0
  135. end
  136. __gfx__
  137. 00000000ffff00ffffff00ffffff00ff000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
  138. 00000000fff0880ffff0880ffff0880f000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
  139. 00000000ffff800fffff800fffff800f000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
  140. 00000000fff08008fff0800800008008000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
  141. 00000000ff08888fff08888ff888888f000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
  142. 00000000f088888ff088888fff88888f000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
  143. 00000000088888ff088888fffff888ff000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
  144. 00000000fff4f4ffff4f4ffffff4f4ff000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
  145. 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
  146. 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
  147. 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
  148. 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
  149. 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
  150. 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
  151. 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
  152. 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
  153. 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
  154. 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
  155. 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
  156. 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
  157. 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
  158. 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
  159. 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
  160. 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
  161. 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
  162. 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
  163. 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
  164. 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
  165. 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
  166. 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
  167. 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
  168. 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
  169. 4444444444444444ff4444ffff4444fffffff33ff33ff33ff33fffff000000000000000000000000000000000000000000000000000000000000000000000000
  170. 4444444444444444ff4444ffff4444fffff333333333333333333fff000000000000000000000000000000000000000000000000000000000000000000000000
  171. 1444444144444411ff4444ffff4444ffff33333333333333333333ff000000000000000000000000000000000000000000000000000000000000000000000000
  172. 1114411111441111ff4444ffff4444fff3333333333333333333333f000000000000000000000000000000000000000000000000000000000000000000000000
  173. 1111111111111111ff4444ffff4444fff3333333333333333333333f000000000000000000000000000000000000000000000000000000000000000000000000
  174. 1111111111111111f444444fff4444ff333333333333333333333333000000000000000000000000000000000000000000000000000000000000000000000000
  175. 1111111111111111f444444fff4444ff333333333333333333333333000000000000000000000000000000000000000000000000000000000000000000000000
  176. 1111111111111111f444444fff4444fff3333333333333333333333f000000000000000000000000000000000000000000000000000000000000000000000000
  177. 000000000000000000000000ff4444fff3333333333333333333333f000000000000000000000000000000000000000000000000000000000000000000000000
  178. 000000000000000000000000ff4444ff333333333333333333333333000000000000000000000000000000000000000000000000000000000000000000000000
  179. 000000000000000000000000ff4444ff333333333333333333333333000000000000000000000000000000000000000000000000000000000000000000000000
  180. 000000000000000000000000ff0444fff3333333333333333333333f000000000000000000000000000000000000000000000000000000000000000000000000
  181. 000000000000000000000000ff0444fff3333333333333333333333f000000000000000000000000000000000000000000000000000000000000000000000000
  182. 000000000000000000000000ff4444ff333333333333333333333333000000000000000000000000000000000000000000000000000000000000000000000000
  183. 000000000000000000000000ff4444ff333333333333333333333333000000000000000000000000000000000000000000000000000000000000000000000000
  184. 000000000000000000000000ff4444fff3333333333333333333333f000000000000000000000000000000000000000000000000000000000000000000000000
  185. 00000000000000000000000000000000f3333333333333333333333f000000000000000000000000000000000000000000000000000000000000000000000000
  186. 00000000000000000000000000000000333333333333333333333333000000000000000000000000000000000000000000000000000000000000000000000000
  187. 00000000000000000000000000000000333333333333333333333333000000000000000000000000000000000000000000000000000000000000000000000000
  188. 00000000000000000000000000000000f3333333333333333333333f000000000000000000000000000000000000000000000000000000000000000000000000
  189. 00000000000000000000000000000000f3333333333333333333333f000000000000000000000000000000000000000000000000000000000000000000000000
  190. 00000000000000000000000000000000ff33333333333333333333ff000000000000000000000000000000000000000000000000000000000000000000000000
  191. 00000000000000000000000000000000fff333333333333333333fff000000000000000000000000000000000000000000000000000000000000000000000000
  192. 00000000000000000000000000000000fffff33ff334433ff33fffff000000000000000000000000000000000000000000000000000000000000000000000000
  193. __gff__
  194. 0000000000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000000000010101000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
  195. 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
  196. __map__
  197. 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
  198. 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
  199. 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
  200. 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
  201. 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
  202. 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
  203. 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
  204. 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
  205. 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
  206. 0000000000000000004445460000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
  207. 0000000000000000005455560000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003
  208. 0000000000000000006465660000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003
  209. 0000000000000000000043000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
  210. 0000000000000000000053000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
  211. 0000000000000000000042000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
  212. 4040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040