Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ' SBPE - SmileBASIC Platforming Engine
- ' ====================================
- ' Copyright © Nitai Sasson
- ' All rights reserved
- ' DO NOT UPLOAD THIS FILE
- ' OR ANY DERIVATIVES THEREOF
- ' TO SMILEBOOM SERVERS WITHOUT
- ' MY EXPLICIT PERMISSION
- GOSUB @INIT
- 'TERMINATE < just for notepad++ to not bug out
- END
- @INIT
- DIM TOINDEX%[512], TOMNG%[0], EMPTYINDEX%[0] ' Back-and-forth between internal indexing of sprites and the actual management numbers.
- FILL TOINDEX%, -1 ' Start with no sprites defined
- DIM X%[0], Y%[0], VX%[0], VY%[0], SPMODE%[0] ' vaiables for each sprite
- RETURN
- COMMON DEF SBPE_SPMODE MNGID%, TYPE%
- ' Available types:
- ' -1 = off (remove from SBPE)
- ' 0 = ghost - goes through walls
- ' 2 = sticky
- IF TYPE% == -1 THEN
- REMOVE_MNG MNGID%
- RETURN
- ENDIF
- VAR INDX% = TOINDEX%[MNGID%]
- IF INDX% == -1 THEN
- INDX% = NEWINDEX%(MNGID%)
- ENDIF
- SPMODE%[INDX%] = TYPE%
- END
- DEF REMOVE_MNG MNGID%
- VAR INDX% = TOINDEX%[MNGID%]
- IF INDX% == -1 THEN RETURN ' Already removed
- TOMNG%[INDX%] = -1 ' Remove from internal index
- SPMODE%[INDX%] = -1 ' Used in internal loop
- PUSH EMPTYINDEX%, INDX% ' Remember unused index
- TOINDEX%[MNGID%] = -1 ' Remove from management index
- END
- DEF REMOVE_INDEX INDX% ' I wonder if I'll need this
- VAR MNGID% = TOMNG%[INDX%]
- IF MNGID% == -1 THEN RETURN ' Already removed
- TOINDEX%[MNGID%] = -1 ' Remove from management index
- PUSH EMPTYINDEX%, INDX% ' Remember unused index
- TOMNG%[INDX%] = -1 ' Remove from management index
- SPMODE%[INDX%] = -1 ' Used in internal loop
- END
- DEF NEWINDEX%(MNGID%)
- VAR INDX%
- IF LEN(EMPTYINDEX%) == 0 THEN
- INDX% = LEN(TOMNG)
- PUSH TOMNG%, MNGID%
- PUSH X%, 0
- PUSH Y%, 0
- PUSH VX%, 0
- PUSH VY%, 0
- PUSH SPMODE%, 0
- ELSE
- INDX% = POP(EMPTYINDEX%)
- TOMNG%[INDX%] = MNGID%
- X%[INDX%] = 0
- Y%[INDX%] = 0
- VX%[INDX%] = 0
- VY%[INDX%] = 0
- SPMODE%[INDX%] = 0
- ENDIF
- TOINDEX%[MNGID%] = INDX%
- RETURN INDX%
- END
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement