? Duplicating Sprites (Page 1) ● SmileBASIC Source Forums

Sign In

Register
*Usernames are case-sensitive
Forgot my password

Duplicating Sprites

  • #1 ✎ 4 bluemonkey1111 Avatar Taboo I didn't change my avatar for 180 days Website Second Year My account is over 2 years old Website Intermediate Programmer I can make programs, but I still have trouble here and there. Programming Strength How would you duplicate the same sprite to a random location. For example if I wanted 50 strawberries on the screen in a random location. Posted
  • #2 ✎ 431 ToadIsTheBest Forum Contributor Hidden Achievements Night Person I like the quiet night and sleep late. Express Yourself Expert Programmer Programming no longer gives me any trouble. Come to me for help, if you like! Programming Strength
    How would you duplicate the same sprite to a random location. For example if I wanted 50 strawberries on the screen in a random location.
    for the x and y, use RND and add new sprites then offset them to the random x and y i wonder if they're going to use this for a sonic clone or something
    Posted
  • #3 ✎ 4 bluemonkey1111 Avatar Taboo I didn't change my avatar for 180 days Website Second Year My account is over 2 years old Website Intermediate Programmer I can make programs, but I still have trouble here and there. Programming Strength What if I want there to be an infinite number of sprites, but it has a delay of 1 second. Let's say an I don't know... Agario type thing where there can be an infinite amount. (I did a crappy example). WAIT 60 Posted Edited by bluemonkey1111
  • #4 ✎ 431 ToadIsTheBest Forum Contributor Hidden Achievements Night Person I like the quiet night and sleep late. Express Yourself Expert Programmer Programming no longer gives me any trouble. Come to me for help, if you like! Programming Strength
    What if I want there to be an infinite number of sprites, but it has a delay of 1 second. Let's say an I don't know... Agario type thing where there can be an infinite amount. (I did a crappy example). WAIT 60
    Firstly, there's a limit of sprites in sb secondly, WAIT 60 is used by professionals
    Posted
  • #5 ✎ 4 bluemonkey1111 Avatar Taboo I didn't change my avatar for 180 days Website Second Year My account is over 2 years old Website Intermediate Programmer I can make programs, but I still have trouble here and there. Programming Strength Thank you for trying. Posted
  • #6 ✎ 389 SwanBot Halloween 2017 Contest Runner Up I placed 2nd in the SmileBASIC Source Halloween 2017 Contest! Programming Contest Intermediate Programmer I can make programs, but I still have trouble here and there. Programming Strength First Year My account is over 1 year old Website Alright time for some corrections here, WAIT 60 would simply stop your program fully for about one second, which if you would want an agario type of effect it would be very to say the least not playable in a game. Also there is a limit to 512 sprites to be used at once, however if it was for an agario type of game you could simply spawn more sprites as you go and delete the ones behind you, while you could not go back to see the same sprites it would auto generate them for you instead of having to wait one second for each one. Alright so how this would be done takes some effort but is worth it, lets start with the basics, the want to be able to scroll the map with sprites on it i will assume, right? Do you know how to do so or do you need me to explain how to do this? >Tbc whenever you answer Posted
  • #7 ✎ 265 spaceturtles Video Games I like to play video games! Hobbies Avatar Block I didn't change my avatar for 30 days. Website Intermediate Programmer I can make programs, but I still have trouble here and there. Programming Strength "Professional" example code: FOR I=0 TO 100 'Increase for more sprites, up to 512 (causes lag) SPSET I,0 'Set sprite to strawberry texture (unless that's the peach) SPOFS I,RND(400),RND(240) 'Set a sprite in a random location NEXT That randomly creates a bunch of sprites. This next bit of code can be put in a game but you must save some sprites for something else if you want to keep some for other sprite stuff: CHANCE=RND(50) 'Higher for a lower chance IF CHANCE==1 THEN 'Can be any number FOR I=0 TO 100 'Number of allocated sprites for use with this IF !SPUSED(I) THEN 'If sprite I is not used then execute the code SPSET I,0 SPOFS I,RND(400),RND(240) ENDIF NEXT ENDIF Don't forget to clear sprites that aren't on screen or not needed anymore so you can have "infinite" sprites. My game Space Rocks includes some functions to draw "entities" onscreen and clears their sprites when they go off screen. You can check it out if you want but the code needs to be organized and it may not be a good example. Posted Edited by spaceturtles
  • #8 ✎ 393 chicken OSP Contest 1 Contest Participant I participated in the first SmileBASIC Source OSP Contest! Second Year My account is over 2 years old Website Good Page Hidden Achievements chicken exmaple very tasty much miiverse (note: trying to make it nearly infinite (above the 512 sprite limit) would probably involve some godforsaken mixture of graphics and arrays that no one on o3DS could, would, or should play.) OCNT=MAINCNT `this maincnt var is a system variable, it increases by one each frame WHILE TRUE IF MAINCNT-OCNT >= 60 then `duplication stuff here i guess OCNT=MAINCNT `resetting the ‘timer’ ENDIF VSYNC WEND Posted
  • #9 ✎ 265 spaceturtles Video Games I like to play video games! Hobbies Avatar Block I didn't change my avatar for 30 days. Website Intermediate Programmer I can make programs, but I still have trouble here and there. Programming Strength Infinite (not really) sprites isn't actually that difficult since you can store more coordinates than sprites. Just clear sprites that aren't on screen and aren't completely covered by other sprites. Posted Edited by spaceturtles
  • #10 ✎ 393 chicken OSP Contest 1 Contest Participant I participated in the first SmileBASIC Source OSP Contest! Second Year My account is over 2 years old Website Good Page Hidden Achievements
    Infinite (not really) sprites isn't actually that difficult since you can store more coordinates than sprites. Just clear sprites that aren't on screen and aren't completely covered by other sprites.
    But you’re completely right...
    Posted