Re: TIB: challenge
[Prev][Next][Index][Thread]
Re: TIB: challenge
That is faster, but you're only looking a snip of the code
we were using. The problem you run into is the 'Ans' gets updated each
time you store something, so eventually it doesn't contain the value of the
keypress when you need it.
The code you posted earlier uses Gotos and complex IF
statements, thus slowing the actual processing down. Basically, it has an
IF clause for each of the different arrow keys. If you try to combine the
code that handles keys on the same axis (i.e. right & left), you can
reduce the number of statements and eliminate the need for Gotos and
IFs.
(Here is the code you posted earlier)
>10->A
>10->B
*** Sets the starting
coordinates
>ClrDraw
*** Clears the screen
>Lbl
T
*** Defines the start of the loop
>Repeat
Ans
*** Starts the Main loop (use Repeat its
faster)
>Getkey
*** Gathers
keypress
>End
*** Checks for keypress
>If
Ans>25
*** Determines which secondary loop to use
>Goto
B
*** If Last line true, then shuttles to loop
>If
Ans==24
*** Start of secondary
loop
>then
*** If last line true, then executes
command
>B-1->B
***
Command
>Else
*** If test (If Ans==24) is false, then
executes
>A-1->A
***
Command
>End
*** Ends secondary
loop
>Pxlon(A,B
*** updates
graph
>GotoT
*** Returns to Main loop
>Lbl
B
*** Defines the start of the loop
>If
Ans==26
*** Start of secondary
loop
>Then
*** If last line true, then
executes command
>B+1->B
***
Command
>Else
*** If test (If Ans==24) is false, then
executes
>A+1->A
***
Command
>End
*** Ends secondary
loop
>Pxlon(A,B
*** updates graph
>Goto
T
*** Returns to Main loop
Here is a souped up version: (for the
86)
:10->A
:10->B
:Repeat G==22
**Exit key
: PxOn(A,B
: Repeat G
: getKy->G
: End
: PxOff(A,B
:
A+(G==34)-(G==25)->A **Boolean logic instead of
IFs
: B+(G==26)-(G==24)->B
:End
Remember, the above code does not handle boundaries (the
edges of the screen).
----- Original Message -----
Sent: Saturday, June 19, 1999 6:49
PM
Subject: Re: TIB: challenge
>Pretty simple, really.
>
>:Repeat
A
>:GetKey->A
>:End
Actually their is a faster way,
using the ans var:
Repeat Ans
GetKey
End
Did any of you
actually look at my routine that I posted eariler? I
challenge anyone to
come up with a faster one.
References: