whoops i did not know that there was a page covering the whole boolean thing…sorry if i double posted…
Here is game another tip, again this is quite a common one but i thought i'd be nice to post it.
instead of getting that flickering screen because you clear the screen (probaly using ClrDraw or real(0,1 if you are using Xlib) every iteration or cycle the game goes through (e.g. Clear previous image, Update stats, Redraw etc) you could beter do some specific clearing. Now what i mean with this is that you should clear your hero's image (or in more specific terms sprite) instead of the whole screen! most things in your game are going to be static walls so there is no need to clear them of the screen if they do not change position! So here is a small example:
BADCODE
0→ K:0→ Y:0→ X
Lbl 1
ClrDraw
Text(Y,X,"H")
While not(sum({24,25,26,34}=K)) //This is a very poorly coded getKey routine I have been using it alot but the best getkey routine available
getKey→ K //is somewhere here on this site...and other places of course...
End
If K=24
Then
X-1→ X
End
If K=25
Then
Y-1→ Y //This may seem odd but the Ytop is 0 and the Ybottom is 62
End
If K=26
Then
X+1→ X
End
If K=34
Then
Y+1→ Y
End
Goto 1
Now that is simply a ridicolously long code for movement (altough…compared to ASM this really is very short…). If you read the previous tip you already could optimize the if statements into booleans, furthermore you could use a far better getKey routine but still there is this flickering!
Here is the solution:
GOOD(or at least BETTER)CODE
Delvar YDelvar X
ClrDraw
While 1
Text(Y,X,"H
Repeat Ans
getKey→ K
End
Text(Y,X," //five spaces
X+5(K=26)-5(K=24->X
Y+5(K=25)-5(K=25->Y
End
many thanks to builderboy for optimizing the code drastically!!
Well that should get you out of flickering trouble! well it DOES flicker but once again it enhances speed AND it looks nicer, more proffesional i would say :D.
Well I am sure I made some mistakes but those will undoubtly be improved by this experienced community…really the only way too achieve no flickering at all is ASM, you can try understanding it but I recommend understanding BASIC first (and all the optimizing tricks).
Good luck and happy programming!