Advertisement
NeatNit

SBPE what I've got so far

Dec 5th, 2015
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.15 KB | None | 0 0
  1. ' SBPE - SmileBASIC Platforming Engine
  2. ' ====================================
  3.  
  4. ' Copyright © Nitai Sasson
  5. ' All rights reserved
  6.  
  7. ' DO NOT UPLOAD THIS FILE
  8. ' OR ANY DERIVATIVES THEREOF
  9. ' TO SMILEBOOM SERVERS WITHOUT
  10. ' MY EXPLICIT PERMISSION
  11.  
  12. GOSUB @INIT
  13. 'TERMINATE < just for notepad++ to not bug out
  14. END
  15.  
  16. @INIT
  17. DIM TOINDEX%[512], TOMNG%[0], EMPTYINDEX%[0] ' Back-and-forth between internal indexing of sprites and the actual management numbers.
  18. FILL TOINDEX%, -1 ' Start with no sprites defined
  19.  
  20. DIM X%[0], Y%[0], VX%[0], VY%[0], SPMODE%[0] ' vaiables for each sprite
  21. RETURN
  22.  
  23. COMMON DEF SBPE_SPMODE MNGID%, TYPE%
  24. ' Available types:
  25. ' -1 = off (remove from SBPE)
  26. ' 0 = ghost - goes through walls
  27. ' 2 = sticky
  28.  
  29. IF TYPE% == -1 THEN
  30. REMOVE_MNG MNGID%
  31. RETURN
  32. ENDIF
  33.  
  34. VAR INDX% = TOINDEX%[MNGID%]
  35. IF INDX% == -1 THEN
  36. INDX% = NEWINDEX%(MNGID%)
  37. ENDIF
  38.  
  39. SPMODE%[INDX%] = TYPE%
  40. END
  41.  
  42.  
  43. DEF REMOVE_MNG MNGID%
  44. VAR INDX% = TOINDEX%[MNGID%]
  45. IF INDX% == -1 THEN RETURN ' Already removed
  46. TOMNG%[INDX%] = -1 ' Remove from internal index
  47. SPMODE%[INDX%] = -1 ' Used in internal loop
  48. PUSH EMPTYINDEX%, INDX% ' Remember unused index
  49. TOINDEX%[MNGID%] = -1 ' Remove from management index
  50. END
  51.  
  52. DEF REMOVE_INDEX INDX% ' I wonder if I'll need this
  53. VAR MNGID% = TOMNG%[INDX%]
  54. IF MNGID% == -1 THEN RETURN ' Already removed
  55. TOINDEX%[MNGID%] = -1 ' Remove from management index
  56. PUSH EMPTYINDEX%, INDX% ' Remember unused index
  57. TOMNG%[INDX%] = -1 ' Remove from management index
  58. SPMODE%[INDX%] = -1 ' Used in internal loop
  59. END
  60.  
  61. DEF NEWINDEX%(MNGID%)
  62. VAR INDX%
  63. IF LEN(EMPTYINDEX%) == 0 THEN
  64. INDX% = LEN(TOMNG)
  65. PUSH TOMNG%, MNGID%
  66. PUSH X%, 0
  67. PUSH Y%, 0
  68. PUSH VX%, 0
  69. PUSH VY%, 0
  70. PUSH SPMODE%, 0
  71. ELSE
  72. INDX% = POP(EMPTYINDEX%)
  73. TOMNG%[INDX%] = MNGID%
  74. X%[INDX%] = 0
  75. Y%[INDX%] = 0
  76. VX%[INDX%] = 0
  77. VY%[INDX%] = 0
  78. SPMODE%[INDX%] = 0
  79. ENDIF
  80. TOINDEX%[MNGID%] = INDX%
  81. RETURN INDX%
  82. END
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement