GIANT TEXT WALL WRITTEN BY A NERD ALERT The wait block is just completely useless for really fast, repetitive actions like attacking 20 times per second. This is because the wait block doesn't take into account time that has passed and push it to a wait block that comes immediately afterward, if it exists. So if a wait block that waits 0.05 seconds (~1.333 frames), then a counter increments by 1, instead of increasing 20 times per second, instead it increases by 15. This is because Scratch discards the remaining time and doesn't apply it to the wait block that comes the next frame. It's also limited by your FPS this way. Say you set a wait block in a forever loop and after the wait block, my variable increments by 1. Instead of my variable incrementing by 100 per second, it is instead halted at 30/second, 20 if you are on Firefox like me. The wait block always waits at least 1 frame, meaning 0 second wait blocks actually do something. This code fixes both issues. You can set the attack speed to anywhere from 0 to 10^306 (about 100 times lower than scratch's number limit), and it supports the most precise numbers you desire. READ BELOW LINE IN NOTES AND CREDITS FOR EXPLANATION ON THE VARIABLES.
Credit to me for the code, and Scratch for the coding blocks and the website to host this thing on. Oh and can't forget Scratch Cat too. ---------------------------------------------------------------------------- If you're wondering why I even explained the first three, keep in mind that young children might not know immediately. Timer: Counts the time since you clicked the green flag. Attacks: How many "attacks" have happened. Attack Speed: How fast the attacks are happening. If you really want to know, the number represents the attacks per second. True Attack Speed: This one is just here for proof that the code ACTUALLY works as intended. This value is calculated from the timer and number of attacks. The number changing constantly is intended. ---------------------------------------------------------------------------- Variables for the nerds that looked inside. _delta: It's just a delta time variable. attack counter: This variable is the whole reason this code even works. I ain't explaining it right now,but if you're looking in the project anyways, I bet you can figure it out yourself.