quickplat.lua 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. -- title: quickplat
  2. -- author: game developer
  3. -- desc: quick platforming tests
  4. -- script: lua
  5. t=0
  6. x=96
  7. y=24
  8. local airAccel = 0
  9. local airControl = 0
  10. local airBrake = 0
  11. local runAccel = 0.2
  12. local runTurnSpeed = 0
  13. local runDecel = 0.2
  14. local runMaxSpeed = 1
  15. local cameraDampX = 0
  16. local cameraDampY = 0
  17. local cameraLookAhead = 0
  18. local jumpBufferTime = 0
  19. local jumpMaxFallSpeed = 5
  20. local jumpCoyoteTime = 0
  21. local jumpMaxHeight = 20
  22. local jumpVariableHeight = true
  23. local jumpGravity = 0.7
  24. local player = {
  25. x = 10, y = 80,
  26. vx = 0, vy = 0,
  27. jump = 2.3,
  28. }
  29. local gravity = -0.07
  30. function TIC()
  31. movePlayer()
  32. cls(0)
  33. drawPlayer()
  34. t=t+1
  35. end
  36. function movePlayer()
  37. -- if btn(0) then player.y=player.y-1 end
  38. -- if btn(1) then player.y=player.y+1 end
  39. if btn(2) then
  40. player.vx = math.min(-runMaxSpeed, player.vx - runAccel)
  41. end
  42. if btn(3) then
  43. player.vx = math.max(runMaxSpeed, player.vx + runAccel)
  44. end
  45. if player.vy == 0 and btnp(4) then
  46. player.vy = -player.jump
  47. end
  48. -- friction and gravity
  49. player.x = player.x + player.vx
  50. player.vx = player.vx * runDecel
  51. player.vy = player.vy - gravity
  52. player.y = player.y + player.vy
  53. if player.y > 130 then
  54. player.y = 130
  55. player.vy = 0
  56. end
  57. end
  58. function drawPlayer()
  59. rect(player.x, player.y, 8, 8, 7)
  60. end
  61. -- <TILES>
  62. -- 001:5555555566666666222222222222222222222222222222222222222222222222
  63. -- 002:5555555066666665222222262222222022222220222222202222222022222220
  64. -- </TILES>
  65. -- <MAP>
  66. -- 015:101010101010101010101010101010101010101010101010101010101010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
  67. -- </MAP>
  68. -- <WAVES>
  69. -- 000:00000000ffffffff00000000ffffffff
  70. -- 001:0123456789abcdeffedcba9876543210
  71. -- 002:0123456789abcdef0123456789abcdef
  72. -- </WAVES>
  73. -- <SFX>
  74. -- 000:000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000304000000000
  75. -- </SFX>
  76. -- <FLAGS>
  77. -- 000:00202000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
  78. -- </FLAGS>
  79. -- <PALETTE>
  80. -- 000:1a1c2c5d275db13e53ef7d57ffcd75a7f07038b76425717929366f3b5dc941a6f673eff7f4f4f494b0c2566c86333c57
  81. -- </PALETTE>