+Sporadic #1 Posted July 31, 2015 Hi all, I've changed the way I declare my sprite constants in my code. Instead of like the examples; ' particle/text layer 0 DIM background% :background=1 DIM water% :water=2 DIM poulpe1% :poulpe1=3 DIM poulpe2% :poulpe2=4 DIM poulpe3% :poulpe3=5 DIM poulpe4% :poulpe4=6 Do this; ' particle/text layer 0 DIM background% :background=1 DIM water% :water=background+1 DIM poulpe1% :poulpe1=water+1 DIM poulpe2% :poulpe2=poulpe1+1 DIM poulpe3% :poulpe3=poulpe2+1 DIM poulpe4% :poulpe4=poulpe3+1 The outcome of doing it the second way, is if you need to add a sprite in the middle of your list, you don't have to adjust all the following variables. You just have to put your sprite declaration in the middle and +1 from the one before it. Then adjust the one after it to +1 from your new variable Once you have lots of sprites, this really helps speed things up. It's also less error prone. Example after inserting a new sprite; ' particle/text layer 0 DIM background% :background=1 DIM water% :water=background+1 DIM poulpe1% :poulpe1=water+1 DIM NEWSPRITE% : NEWSPRITE=poulpe1+1 DIM poulpe2% :poulpe2=NEWSPRITE+1 DIM poulpe3% :poulpe3=poulpe2+1 DIM poulpe4% :poulpe4=poulpe3+1 Hope this helps 4 Quote Share this post Link to post Share on other sites
sh3-rg #2 Posted July 31, 2015 (edited) Hi all, <snip> Hope this helps That is a top tip. We tried to make some sensible use of ENUM, but it never quite worked out and always seemed like a chore and not as foolproof as it might have been (thanks to Raptor's way of declaring multiple objects of same type) - your way could get around this fairly easily, good stuff. I think it's probably time to update some of the tutorials :0) (although maybe I'm a little worried that it might be confusing to an absolute beginner, hmmmm... but it's definitely worthy of mention in the "working with rB+" section!) I know I'll be doing it your way from now on at least, cheers. Edited July 31, 2015 by sh3-rg Quote Share this post Link to post Share on other sites
+Sporadic #3 Posted July 31, 2015 (edited) That is a top tip. We tried to make some sensible use of ENUM, but it never quite worked out and always seemed like a chore and not as foolproof as it might have been (thanks to Raptor's way of declaring multiple objects of same type) - your way could get around this fairly easily, good stuff. I think it's probably time to update some of the tutorials :0) It also helps if you have multiple sprites defined for 1 sprite in the object list. Then in code for the following sprite declaration you can do something like NEWSPRITE+16 and so on. Or NEWSPRITE+NUMBEROFBADDIESCONST where NUMBEROFBADDIESCONST=16 Edited July 31, 2015 by Sporadic 1 Quote Share this post Link to post Share on other sites
sh3-rg #4 Posted July 31, 2015 It also helps if you have multiple sprites defined for 1 sprite in the object list. Then in code for the following sprite declaration you can do something like NEWSPRITE+16 and so on. Or NEWSPRITE+NUMBEROFBADDIESCONST where NUMBEROFBADDIESCONST=16 Exactly, it makes more sense at that point as it's not such a special case anymore. Going to add your info as a page on the site now, thanks again. 1 Quote Share this post Link to post Share on other sites
sh3-rg #5 Posted July 31, 2015 Added. Anyone else with similarly handy TopTips should do as Sporadic did and share in the rB+ forum here on AA :0) 1 Quote Share this post Link to post Share on other sites