mutiple ramdom sprites and collision
Root / Programming Questions / [.]
PedoSaCreated:
So you want to create random sprites and detect collision? Collision is as simple as using SPCOL sprite#,true/false and checking SPHITSP for each sprite.
i need help to make multiple sprites with ramdom behaviors that are all the same some trees that get to a ramdom x,y value and some collision sprite which makes them dissapear it would look like this but just the treesCould you clarify what you mean in this message? The fact that there isn’t any punctuation is making it very hard to figure out what you’re saying.
Could you clarify what you mean in this message? The fact that there isn’t any punctuation is making it very hard to figure out what you’re saying.Here is a grammar corrected version for your viewing pleasure: I need help to make multiple sprites with random behaviors that are all the same. some trees that get to a random x and y value and some collision sprite which makes them disappear. it would look like this, but just the trees
In that case for the sprites doing random things I suggest an array. When a sprite is created assign random values to the array including its coordinates. You might want to use multiple 1d arrays to make removal of each tree object easier (just remove the element(s) for that tree).Could you clarify what you mean in this message? The fact that there isn’t any punctuation is making it very hard to figure out what you’re saying.Here is a grammar corrected version for your viewing pleasure: I need help to make multiple sprites with random behaviors that are all the same. some trees that get to a random x and y value and some collision sprite which makes them disappear. it would look like this, but just the trees
ACLS rndmX = RND(100) 'the 100 in parentheses is the maximum value the random variable can have. You should change this to your needs. rndmY = RND(100) FOR I=0 TO numSprites 'put the number of sprites you want to create in place of numSprites SPSET I , treeSprite SPOFS I , rndmX, rndmY SPCOL I NEXTThis should work for randomly placing multiple sprites across the screen. I’m still not sure what you mean by “and some collision Sprite that makes them disappear”. Perhaps you mean the player sprite? If that’s the case, then it’s simple enough to add collision to that.
oops i mean the random spritesACLS rndmX = RND(100) 'the 100 in parentheses is the maximum value the random variable can have. You should change this to your needs. rndmY = RND(100) FOR I=0 TO numSprites 'put the number of sprites you want to create in place of numSprites SPSET I , treeSprite SPOFS I , rndmX, rndmY SPCOL I NEXTThis should work for randomly placing multiple sprites across the screen. I’m still not sure what you mean by “and some collision Sprite that makes them disappear”. Perhaps you mean the player sprite? If that’s the case, then it’s simple enough to add collision to that.
SPSET RND#
RANDOM_NUMBER=RND(128) SPSET 0,1 SPSET 1,RANDOM_NUMBER IF SPHITSP(0,1) THEN SPCLR 1Use loops and the concept of reusing sprites (arrays work well for this) with this and you might get the desired effect. Sprite 0 is the player sprite.
OK, that’s easy to do.no when the Player colides they disapearoops i mean the random spritesYou want the Randomly placed sprites to disappear when they collide with each other? I’m sorry, it’s just not making very much sense.
ACLS SPSET 0, 'player sprite SPCOL 0 rndmX = RND(100) 'the 100 in parentheses is the maximum value the random variable can have. You should change this to your needs. rndmY = RND(100) FOR I=1 TO numSprites 'put the number of sprites you want to create in place of numSprites SPSET I , treeSprite SPOFS I , rndmX, rndmY SPCOL I NEXT FOR I=1 TO numSprites IF SPHITSP(0,I) THEN SPCLR I NEXTI haven’t tested this, but it should work. You’ll still have to add your own things like player movement and such, but this should cover random placement and collision.
what do you mean by "PLR sprite" the code or name?OK, that’s easy to do.no when the Player colides they disapearoops i mean the random spritesYou want the Randomly placed sprites to disappear when they collide with each other? I’m sorry, it’s just not making very much sense.ACLS SPSET 0, 'player sprite SPCOL 0 rndmX = RND(100) 'the 100 in parentheses is the maximum value the random variable can have. You should change this to your needs. rndmY = RND(100) FOR I=1 TO numSprites 'put the number of sprites you want to create in place of numSprites SPSET I , treeSprite SPOFS I , rndmX, rndmY SPCOL I NEXT FOR I=1 TO numSprites IF SPHITSP(0,I) THEN SPCLR I NEXTI haven’t tested this, but it should work. You’ll still have to add your own things like player movement and such, but this should cover random placement and collision.