Ok, so I don't have the code I had been trying to get this to work because I accidentally overwrote it when I was ungrouping some files.
But I never got it to actually move towards you, entirely.

Code:
1->S
1->T
16->N
8->O
ClrHome
While 1
Output(T,S,"A
Output(O,N,"B
Repeat K
getkey->K
End
Output(T,S,"
Output(O,N,"
S+(K=26)-(K=24->S
T+(K=34)-(K=25->T
O+(T-1>O)-(T+1<O->O
N+(S-1>N)-(S+1<N->N
End


Note: Untested.

This should move the enemy towards you if you are more than 1 square away from it.
What about the code that you had in the Program Ideas thread, Sonlen?
That code came from this and what I had been working on.
Sonlen wrote:
That code came from this and what I had been working on.
Ah, so would you like me to post the changes that I made to your code to make it move at most one space horizontally or vertically per iteration here?
KermMartian wrote:
Sonlen wrote:
That code came from this and what I had been working on.
Ah, so would you like me to post the changes that I made to your code to make it move at most one space horizontally or vertically per iteration here?

If you mean the one here, go for it, otherwise the one in the Program Ideas thread does that.
Here it is from the Program Ideas topic, to avoid hijacking that thread:

BASIC Code wrote:
:ClrHome
:14→A:3→B
:3→C:3→D
:"XXXXXXXXXXXXXXXXX XX XX XX XX XX XXXXXXXXXXXXXXXXX→Str1
:Output(1,1,Str1
:Output(D,C,"*
:Output(B,A,"π
:Repeat A=C and B=D
:¦ Repeat Ans
:¦ ¦ getKey
:¦ End
:¦ Ans→K
:¦ Output(B,A,"
:¦ Output(D,C,"
:¦ A+(A≠15 and K=26)-(A≠2 and K=24→A
:¦ B+(B≠7 and K=34)-(B≠2 and K=25→B
:¦ If not(D-B) or .5<rand
:¦ Then
:¦ ¦ C+(C≠2 and A-1>C)-(C≠15 and A+1<C→C
:¦ Else
:¦ ¦ D+(D≠2 and B-1>D)-(D≠7 and B+1<D→D
:¦ End
:¦ Output(B,A,"π
:¦ Output(D,C,"*
:End
:ClrHome
:Output(1,4,"YOU LOSE
:Pause
:ClrHome
:Return
Generated by SourceCoder, © 2005-2010 Cemetech
[/quote]
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement