0 Members and 4 Guests are viewing this topic.
Load mapGet ListsDisplay HUDDisplay MapWhile health and character is not off limitsgetkeyUpdate TilePhysicsDisplay characterIf Key thenswordJumpmagicEndJump actionIf enemy thenenemy movementEndTile testsEnd
By the way, this is a dual-layer platformer I'm guessing? And are those screenshots with 6 MHz?
While CONDITIONCODERepeat GetkeyEndAns->VARMOAR CODEEnd
While CONDITIONCODEGetkey->VARMOAR CODEEnd
While CONDITIONCODERepeat GetkeyEndAns->VARMOAR CODE End
This code is actually incorrect the Ans does not store to VAR.
:While CONDITION:CODE:Repeat Ans:getKey:End:Ans→VAR:MORE CODE :End
:While STUFF:getKey→K:If K:prgmMOVE:(some stuff that has to be executed every time):End
Uhm Noah, by var I meant any real var. I wrote VAR because the user could decide to use whatever var from A to Z, and yes you can store Ans to real vars, I tried and it works.
This should work:Code: [Select]:While CONDITION:CODE:Repeat Ans:getKey:End:Ans→VAR:MORE CODE :EndWhat I do for Chip's Challenge is along the lines of Code: [Select]:While STUFF:getKey→K:If K:prgmMOVE:(some stuff that has to be executed every time):EndprgmMOVE contains all the code for if the player moved, so if they didn't move the (useless) code isn't executed. There's stuff besides a key press that triggers movement (or at least the need to run the movement code), but that's the gist of it.
:While STUFF:getKey→K:If K:Then:prgmMOVE:End:(some stuff that has to be executed every time):End
When using If statements with only 1 line afterwards, it's faster to execute that line WITHOUT the Then:End, but when skipping that line (in cases where key presses aren't pushed often), it's faster to have Then:End because instead of reading what's inside, it skips. Not sure if what I said just made sense, but to sum it up, it's faster to skip code using Then:End, and it's faster to execute the code just using If by itself.
Quote from: trevmeister66 on May 19, 2009, 05:34:10 pmWhen using If statements with only 1 line afterwards, it's faster to execute that line WITHOUT the Then:End, but when skipping that line (in cases where key presses aren't pushed often), it's faster to have Then:End because instead of reading what's inside, it skips. Not sure if what I said just made sense, but to sum it up, it's faster to skip code using Then:End, and it's faster to execute the code just using If by itself. So, when the condition is false (the next line is skipped) it's faster to use If:Then:End.When the condition is true (the code is executed) it's faster to just use If.Is that right? If that's the case, then whether to use the Then:End depends on if most of the time the condition will be true or false.