Hey all,
So I'm current working on a roguelike project but I have hit an annoying stumbling block that I'm not sure how to solve.
I'm implementing a mob system where I can add mobs to various map coordinates and display them on the screen. I'm also using their position to determine whether or not they should be drawn as well as for collision. The array that I've set up works perfectly and I can draw them to the screen, but I am encountering a weird bug(?) when I loop over the array in a for loop to compare values. Here is the full code that I have written so far:

Code:
.A
./front frames
[FFC1C3E7C33E23FB]→Pic0
[C1C3E7C33E62F3FF]
[FFC1C3E7C37CC4DF]
[C1C3E7C37C46CFFF]
./right frames
[FFC1E1EBA13E22DB]
[C1E1EBE1DF9393E7]
[FFC1E1EBE19F93DB]
[C1E1EBE1BE2223E7]
./left frames
[FF8387D7857C44DB]
[8387D787FBC9C9E7]
[FF8387D787F9C9DB]
[8387D7877D44C4E7]
./back frames
[FF83C3FFA3223BF3]
[83C3FFA3227AF3FF]
[FF83C3FFC544DCCF]
[83C3FFC5445ECFFF]
./slime frames
[FFFFFFC7A3410183]→Pic2
[FFFFC7A3A38383C7]
[FFFFFFC7A3410183]
[FFFFFFFF81600081]
./wall tile, 00
[45FF11FF45FF11FF]→Pic1
./ground tile, 01
[FFFFFFFFFFEFFFFF]
./tile map
[00000000000000000000000000000000000000000000000000000000000000000000000000]→GDB0
[00000000000000000000000000000000000000000000000000000000000000000000000000]
[00000000000000000000000000000000000000000000000000000000000000000000000000]
[00000000000000000000000000000000000000000000000000000000000000000000000000]
[00000000000000000000000000000000000000000000000000000000000000000000000000]
[00000000000000010101010100000000000000000000000000000101010101000000000000]
[00000000000000010101010100000000000000000000000000000101010101000000000000]
[00000000000000010101010100000000000000000000000000000101010101000000000000]
[00000000000000010101010100000000000000000000000000000101010101000000000000]
[00000000000000010101010101010101010101010101010101010101010101000000000000]
[00000000000000000000000000000000000101010101010100000101010101000000000000]
[00000000000000000000000000000000000101010101010100000101010101000000000000]
[00000000000000000000000000000000000101010101010100000101010101000000000000]
[00000000000000000000000000000101010101010101010100000101010101000000000000]
[00000000000000000000000000000100000101010101010100000000010000000000000000]
[00000000000000000000000000000100000000000000000000000000010000000000000000]
[00000000000000000000000000000100000000000000000000000000010000000000000000]
[00000000000000000000000000000100000000000000000000000000010000000000000000]
[00000000000000000000000000000100000000000101010101010101010000000000000000]
[00000000000000000000000000000100000000000101010101010000000000000000000000]
[00000000000000000000000000000101010101010101010101010000000000000000000000]
[00000000000000000000000000000000000001000101010101010000000000000000000000]
[00000000000000000000000000000000000001000101010101010000000000000000000000]
[00000000000000000000000000000000000001000000000100000000000000000000000000]
[00000000000000000000000000000000000001000000000100000000000000000000000000]
[00000000000000000000000000000000000001000000000100000000000000000000000000]
[00000000000000000000000000000000000001000000000100000000000000000000000000]
[00000000000000000000000000000000000001000000000000000000000000000000000000]
[00000000000000010101010101010101000001000000000000000000000000000000000000]
[00000000000000010101010101010101010101000000000000000000000000000000000000]
[00000000000000010101010101010101000000000000000000000000000000000000000000]
[00000000000000010101010101010101000000000000000000000000000000000000000000]
[00000000000000010101010101010101010101010101010101010101010101000000000000]
[00000000000000000000000000000000000000000000000000000000000000000000000000]
[00000000000000000000000000000000000000000000000000000000000000000000000000]
[00000000000000000000000000000000000000000000000000000000000000000000000000]
[00000000000000000000000000000000000000000000000000000000000000000000000000]
0->Q->P→V->H→I→J→F→S→L->K->T
Fix 5
AddMob(1,0)
AddMob(2,2)
AddMob(15,9)
AddMob(2,26)
ClrDraw
Repeat getKey(15)
  ./192 is the offset from the beginning of GDB0
  Q*37+P+192→Z
  If getKey(3) and (I=0) and (J=0) and ({Z+1+GDB0}=1)
    If Z+1≠M
      1→I
      32→S
    End
  End
  If getKey(2) and (I=0) and (J=0) and ({Z-1+GDB0}=1)
    If Z-1≠M
      0-1→I
      64→S
    End
  End
  If getKey(1) and (I=0) and (J=0) and ({Z+37+GDB0}=1)
    If Z+37≠M
      1→J
      0→S
    End
  End
  If getKey(4) and (I=0) and (J=0) and ({Z-37+GDB0}=1)
    If Z-37≠M
      0-1→J
      96→S
    End
  End
  F++
  H+I+I→H
  V+J+J→V
  If (H-8=0) or (H+8=0)
    P+I→P
    0→H→I
  End
  If (V-8=0) or (V+8=0)
    Q+J→Q
    0→V→J
  End
  DrawMap()
  DrawMob()
  Pt-Off(44,28,Pic0+(F/3^4*8)+S)
  ...Text(0,0,Z►Dec)
  For(E,1,L)
    E*4+L₁-4→G
    Text(0,E*6,{G+2}ʳ►Dec)
  End
  ...
  DispGraph
End
ClrDraw
Fix 4
Lbl AddMob
  ./r1 = x, r2 = y
  ./creates an array [x,y,y*37+x+192]
  If L<18
    r₂*37+r₁+192→{r₂→{r₁→{L+1→L*4+L₁-4}+1}+1}ʳ
  End
Return
Lbl DrawMob
  For(E,1,L)
    E*4+L₁-4→G
    {E*4+L₁-2}ʳ→M
    Text(0,0,M►Dec)
    ./If ((M-192≤Z) and (M+192≥Z))
      ./Text(0,E*6,"Drawn")
      {G}-P*8→r₁
      {G+1}-Q*8→r₂
      ./Text(0,0,M►Dec)
      Pt-Off(44+r₁-H,28+r₂-V,Pic2+(F/3^4*8))
      ./Else
      ./Text(0,E*6,"Not Drawn")
    ./End
  End
Return
Lbl DrawMap
  Q*37+P→T
  ClrDraw
  For(B,0,10)
    For(A,0,14)
      A-1*8-4-H→C
      B-1*8-4-V→D
      Pt-On(C,D,{B*37+A+T+GDB0}*8+Pic1)
    End
  End
Return

The problem occurs at the line If (M-192≤Z) and (M+192≥Z) because it is not checking for all values of M, only the last value of M. At first I thought I was doing something incorrectly, so I made a test program that compares a given value with a set of values in a variable length array:


Code:
.ARRAY
ClrHome
0→L
193→A
AddEntry(1156)
AddEntry(193)
AddEntry(208)
AddEntry(447)
Repeat getKey(15)
  CheckArray()
End
ClrHome
Lbl AddEntry
  r₁→{L+1→L*2+L₁-2}ʳ
Return
Lbl CheckArray
  For(I,1,L)
    {I*2+L₁-2}ʳ→B
    If A=B
      Output(0,0,"EQUAL")
      Pause 1800
      ClrHome
      Else
      Output(0,0,"NOT EQUAL")
      Pause 1800
      ClrHome
    End
  End
Return

This code runs perfectly. I've been commenting out various parts of my original code to see where I am going wrong, but I can't quite solve it on my own. I'm hoping a fresh pair of eyes might give some insight as to why it is not working. Thanks.
not sure is this is causing the issue, but as far as I know, in Axe, you can just:

If COND1 and (COND2)
do this
End

instead of:

If ((COND1) and (COND2))
do this
End

again, not sure if this will help, but it might
  
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