1) No, collectible blocks are good for Manic Miner type games, where you have to get all the collectibles before progressing. If your game is more 'open' allowing the player to go from screen to screen then you can use Objects, the downside to this is you have to create a separate object for each one, so lets say your game is over 20 screens and there are 10 coins to find, you would have to make 10 coin objects then use REMOVEOBJ xx when the play collects one (where xx is the number of the objec so for example:
DETECTOBJ ;is playertouching an object IF OBJ <> 255 GET OBJ ;get the object IF OBJ = 1 ; is it object #1 REMOVEOBJ 1 ; if so remove object number on
2) Yes, just use multiple SPRITELEFT for example 3) Sorry no idea.
Thank you waveleys, I have not used objects for my collectibles because the sprites size is 16x16 and my collectibles are very small and the collisions are strange.
I will to try multiple SPRITELEFT. Can you tell me for example how i would do it with this code to get more speed?:
IF DIRECTION = LEFT IF CANGOLEFT SPRITELEFT SUBTRACT 16 FROM X IF CANGODOWN LET DIRECTION = RIGHT ENDIF ADD 16 TO X ELSE LET DIRECTION = RIGHT ENDIF ELSE IF CANGORIGHT SPRITERIGHT ADD 16 TO X IF CANGODOWN LET DIRECTION = LEFT ENDIF SUBTRACT 16 FROM X ELSE LET DIRECTION = LEFT ENDIF ENDIF
Added comments to explain how that code works (or at least my interpretation of it!)
IF DIRECTION = LEFT ; direction is just a local variable IF CANGOLEFT ; can the sprite go left (i.e. is there an empty block to the left?) SPRITELEFT ; if so go left 1 pixel SPRITELEFT ; and another SUBTRACT 16 FROM X ; look 16 pixels to the left IF CANGODOWN ; would the sprite fall down if they were there? LET DIRECTION = RIGHT ; if so change direction to right - this stops the sprite falling of say a raised platform ENDIF ADD 16 TO X ; add back those 16 pixels we subtracted earlier so the sprite is still in the right place ELSE ; if the sprite cant go left LET DIRECTION = RIGHT ; send it right ENDIF ELSE IF CANGORIGHT ; if the sprite can go right SPRITERIGHT ; go right 1 pixel SPRITERIGHT ; and another ADD 16 TO X ; check 16 pixels ahead to the right IF CANGODOWN ; would it fall down? LET DIRECTION = LEFT ; if so go left ENDIF SUBTRACT 16 FROM X ; subtract the 16 pixels we added to check they werent going to fall ELSE LET DIRECTION = LEFT ; if the sprite cant go right send it left ENDIF