` ``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`

The previous code had a memory leak D: which is a very bad thing!

]]>Thanks :)

and I don't know if anyone remembers me, I left when the summer started. School and a visual basic class got me back into ti basic.

]]>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!

]]>` ``X+sum(ΔList(K={24,26→X Y+sum(ΔList(K={34,25→Y`

` ``X+(K=26)-(K=24)->X Y+(K=25)-(K=25)->Y`

If K=24 is going to evaluate to 1 already, why multiply it by one? Adding a coefficient is only necessary if you are incrementing by a non-one value:

` ``X+5(K=26)-5(K=24)->X Y+5(K=25)-5(K=25)->Y`

I'm sure this is already on the optimization page, I have seen this used in loads of places. ]]>

Very well written also. ]]>

` ``X+1(K=26)->X X-1(K=25)->X Y+1(K=25)->Y Y-1(K=340->Y`

If the "left" key is pressed then *"(k=26)"* will evaluate to true (or 1) so you'll get:

` ``X+1(1)->X`

now if you have payed attention at math class you know that X+1(1) is the same as X+1*(1).

So go ahead and change all your IF statements that only change variables into booleans! it really is a great speed enhancer!

Good luck!

]]>