Using CALL SPRITE over 1000 times faster than FOR loops (Page 1) ● SmileBASIC Source Forums

Register
Space-Restriction Challenge QSP Phase Ends on March 26!

# Using CALL SPRITE over 1000 times faster than FOR loops

• #1 ✎ 171 DFrost Expert Programmer Programming no longer gives me any trouble. Come to me for help, if you like! Programming Strength a while ago I just thought 'huh, why is the raycaster calc84 so fast?' Since I am no computer science genius, I decided to test it using the scientific method, using code similiar to this: ``` DEF WP SP,X,Y,Z'weak perspective(basically perspective minus camera rotation) VAR X%,Y% IF Z == 0 THEN X% = 200:Y% = 120:SCL = 1 ELSE SCL = 1/Z X% = (X/Z) + 200 Y% = 120 - (Y/Z) SPSCALE SP,SCL,SCL SPOFS SP,X%,Y% END DEF WP2 VAR X%,Y% IF SPVAR(CALLIDX,2) == 0 THEN X% = 200:Y% = 120:SCL = 1 ELSE SCL = 1/Z X% = (SPVAR(CALLIDX,0)/SPVAR(CALLIDX,2)) + 200 Y% = 120 - (SPVAR(CALLIDX,1)/SPVAR(CALLIDX,2)) SPSCALE CALLIDX,SCL,SCL SPOFS CALLIDX,X%,Y% END '----initialize---- VAR X = RND(100),Y=RND(100),Z=RND(10) FOR I = 0 TO 511 SPSET I,0 SPVAR I,0,X SPVAR I,1,Y SPVAR I,2,Z SPFUNC I,WP2 NEXT 'now the testing begins: M% = MILLISEC FOR I = 0 TO 511 WP I,X,Y,Z NEXT FORTIME% = MILLISEC-M% M% = MILLISEC CALL SPRITE CALLSPTIME% = MILLISEC - M% ``` Posted Edited by DFrost
• #2 ✎ 609 IAmRalsei Forum Leader Hidden Achievements First Year My account is over 1 year old Website Expert Programmer Programming no longer gives me any trouble. Come to me for help, if you like! Programming Strength okay Posted
• #3 ✎ 974 Yttria Head Admin this is the part where the teacher hands your assignment back with question marks and "incomplete? see me after class" written on it Posted
• #4 ✎ 233 AnswerXOX Great Page Hidden Achievements RNG Hidden Easter Eggs Third Year My account is over 3 years old Website results? Posted
• #5 ✎ 459 auceps osu! Is Awesome! I love osu! Express Yourself Third Year My account is over 3 years old Website Avatar Taboo I didn't change my avatar for 180 days Website i demand evidence Posted
• #6 ✎ 171 DFrost Expert Programmer Programming no longer gives me any trouble. Come to me for help, if you like! Programming Strength I will post them @fter school. I can be on my computer rn, but not my 3DS.(results will be on N3DS XL) Posted
• #7 ✎ 433 MasterR3C0RD Helper Received for being very helpful around SmileBASIC Source Achievements Third Year My account is over 3 years old Website osu! Is Awesome! I love osu! Express Yourself I didn't know the school days in the US mean 3 days :P Jokes aside, I'm interested in proof of this. Posted
• #8 ✎ 974 Yttria Head Admin you can prove it by independent verification, but that assumes that the procedure is correct Posted
• #9 ✎ 171 DFrost Expert Programmer Programming no longer gives me any trouble. Come to me for help, if you like! Programming Strength i forgot. Posted
• #10 ✎ 233 AnswerXOX Great Page Hidden Achievements RNG Hidden Easter Eggs Third Year My account is over 3 years old Website it will be forgotten forever Posted
• #11 ✎ 609 IAmRalsei Forum Leader Hidden Achievements First Year My account is over 1 year old Website Expert Programmer Programming no longer gives me any trouble. Come to me for help, if you like! Programming Strength It will be remembered at 10:0shovel. Posted
• #12 ✎ 171 DFrost Expert Programmer Programming no longer gives me any trouble. Come to me for help, if you like! Programming Strength Now I look STUPID because it is actually slower lol Posted
• #13 ✎ 171 DFrost Expert Programmer Programming no longer gives me any trouble. Come to me for help, if you like! Programming Strength I don't know HOW i got 1000 times faster. For some reason, when I put SPSET SP,0 in WP, WP2 is a LOT faster. I think it's because it resets the SPVARS on the sprites... Posted
• #14 ✎ 609 IAmRalsei Forum Leader Hidden Achievements First Year My account is over 1 year old Website Expert Programmer Programming no longer gives me any trouble. Come to me for help, if you like! Programming Strength that makes sense lol Posted
• #15 ✎ 171 DFrost Expert Programmer Programming no longer gives me any trouble. Come to me for help, if you like! Programming Strength
this is the part where the teacher hands your assignment back with question marks and "incomplete? see me after class" written on it
lol ikr
Posted Edited by DFrost