After the collision, the basketball speed is hardly changed, but the golf ball reverses at speed (almost) 3v. The golf ball and basketball approach, each at speed v, before the collision. 3: Basketball and golf ball collision from the point of view of the ground. This is the first time I have ever enjoyed watching a presentation on Excel. Hopefully I can dissect those equations and replicate it. Thanks, Paul, for providing us with a way to do great “real” gravity without having to do a bit of math…on the CoCo. It looks like using Paul’s technique to pre-calculate all the gravity values, and then reading them dynamically from DATA statements in the demo, should give us a great speed boost even over my simple attempt to do things like “Y=Y+.25”. I’ll also replace the -1 with some HEX value we won’t be using. In part 6 of my BASIC series, I looked at using READ on integers, hex, and strings. It seems just checking for -1 is the faster way. It seems incrementing a variable, comparing it, then resetting it adds a lot of overhead. Yipes! The one slows down to 14.15 seconds. Is it faster to do that, rather than looking for -1? 0 REM RESTIDX.BASģ0 READ Z:X=X+&H1:IFX>&H14 THENRESTORE:X=&H0:GOTO30 In the array version, there is an index value (needed for the array) that can be checked. In the READ/RESTORE example, I have to keep checking for -1. This produces 10.51 seconds! A bit faster. ![]() ![]() Next I removed the array and just do a READ each time, looking for a -1 which indicates we need to RESTORE back to the start of the data. Running this in the Xroar emulator gives 12.65 seconds. In his example, he places a -1 at the end of the DATA statement, and uses that as a dynamic way to indicate the end of the data. He then has all his Y positions available just by using an index counter (he re-purposes my YM Y-movement variable) that loops through them. Paul’s recalculated data is stored in DATA statements, such as: DATA 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,-1ĭuring the initialization code, he loads the data up in an array, such as: FOR I=0 TO 20:READ Y(I):NEXT ![]() Your demo sent me back to my benchmarking to find out which was faster: Array or DATA? Screen shot from Paul Viscarellis’ YouTube video showing turning Excel spreadsheet data into BASIC DATA statements. He then uses some fancy Excel formulas to make it generate all the data together as numbers separated by commas, ready to be copy-and-pasted into an editor with the rest of the BASIC program. That’s something my brute-force simulated gravity attempt did not do. Impressive! His video explains how the formulas work, and then he uses an Excel spreadsheet to do all the math, and then fills it up with locations representing each Y position of the ball, all designed to perfectly fit the 32 column screen. But, the math still has to be done somewhere to generate the values for those DATA statements.Īnd, he does it with style, using real equations that calculate an object in free-fall. In part 3 of my bouncing ball series, I discussed the idea of using DATA for the positions rather than doing math simply because it would be faster. He suggests pre-calculating the positions so nothing has to be calculated at run-time. It comes from a video response from Paul Fiscarelli that demonstrates his solution for adding gravity to the bouncing ball demo. “Let’s build a worksheet to calculate these values.”
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |