? Raycaster glitching (Page 2) ● SmileBASIC Source Forums

Sign In

Register
*Usernames are case-sensitive
Forgot my password

Raycaster glitching

1 2
  • #21 ✎ 168 seggiepants Yes, you can use vsync just about anywhere in your code. While is just a better type of loop. Posted
  • #22 ✎ 67 Vakore Are there any speed bonuses of using a while loop? Posted
  • #23 ✎ 191 niconii Video Games I like to play video games! Hobbies Expert Programmer Programming no longer gives me any trouble. Come to me for help, if you like! Programming Strength Drawing I like to draw! Hobbies
    Can you use vsync in a while loop?
    WHILE TRUE 'code goes here WEND @LOOP 'code goes here GOTO @LOOP Both of these do exactly the same thing, so everything will still work in both of them. Pick whichever one you like better.
    Are there any speed bonuses of using a while loop?
    Nope. At least, it shouldn't be anything significant. Actually, based on my tests in SB4, a while loop seems to be the slowest way to do an infinite loop, actually. I guess it makes sense, since it has to evaluate an expression every loop iteration.
    Posted Edited by niconii
  • #24 ✎ 67 Vakore Ok, thanksniconni. I of course seggiepants is going to interject, so I'll wait for that to see his thoughts. Posted
  • #25 ✎ 41 incvoid Thanks for the spchr advice. I think labels and goto are fine if ya dont have any conditions to exit the loop. I wish there was a version of vsync that held until the next refresh..frame skipping... i think tearing still occurs if ya take too long to update... maybe im just using it wrong. I always thought to draw to offscreen, vsync, flip offscreen and onscreen, or would it be better to flip then vsync? Oh well Posted
  • #26 ✎ 168 seggiepants If you are comparing speed, then GOTO ought to be the fastest. Whether you could ever notice the speed difference in a real program is unlikely. Not using GOTO is about hygiene, structure, reusablity, and readability. Using GOTO encourages several bad habits that tend to turn your program from a concrete structure into a tangled mess. Or as it is normally known spaghetti code. Functions get local variables, goto makes you rely on largely only global variables. Local variables are better because you have less dependencies throughout your code. While, For, and Repeat loops all have a definite markings of where they begin and end. Goto can jump in the middle of a loop from anywhere. This makes things much harder to predict, read and maintain. Most of the coders here are just starting out (even if they class themselves as experts, they are largely still novices). GOTO is a really BAD habit that teaches you to code poorly. It doesn't scale to hundreds of lines of code let alone more, and can make intractable messes. Messes that make novices give up in frustration. So there is also an ounce of prevention being better than a pound of cure thing going on as well as a don't make people give up before they ever get started. Most languages don't even include it anymore since it is so easily abused. I've gone over this at length before only to be called names by admins. If you want to read more you can look at my old posts or just search the web for a neutral third party opinion. I don't really want to write a novel on it, I have already gone on too long. Posted
  • #27 ✎ 67 Vakore Ok. I'm not new to coding, so I'll stick to GOTO. About. Neatness though... if I used an actual keyboard, it would be super neat, but since I have to type with a stylus, I'm now being super neat(though I do try to organize the code) Posted
  • #28 ✎ 1803 12Me21 Syntax Highlighter Received for creating the code syntax highlighter on SBS Night Person I like the quiet night and sleep late. Express Yourself More importantly: please indent your code lol Posted
  • #29 ✎ 67 Vakore I indent where it matters. Can someone please close this thread as the issue has been solved. Posted
1 2