Omnimaga

Calculator Community => TI Calculators => Axe => Topic started by: Michael.3545 on October 26, 2010, 06:49:08 pm

Title: Some (big) issues with ghosts
Post by: Michael.3545 on October 26, 2010, 06:49:08 pm
Hello Omnimagicians, I seem to be having a bit of an issue.  I am working on a pacman clone (http://ourl.ca/7499).  The ghosts used to behave like this:
(http://img828.imageshack.us/img828/6641/pacmanw.gif)

I finally added a method of controlling the ghost's movements, and instead of moving as expected, I got this:
(http://img220.imageshack.us/img220/4895/ohno.gif)

This is the code I added:
Code: [Select]
:   .G-BRAIN
:..............
:
:   .On tile
:   !If {A}^7 or ({B}^7)
:    L4+2?P
:    0?{L4}r
:    0?{P}
:    If J
:     J*?1?{L4}
:    Else
:     K*?1?{L4+1}
:    End
:
:.stop indent
:
:.1  UP
:!If pxl-Test({A},{B}-1)r
:If {L4+1}??1
: 0?{{P}*2+L4+3}
: ?1?{{P}*2+L4+4}
: {P}+1?{P}
:End
:End
:
:.2  RIGHT
:!If pxl-Test({A}+7,{B})r
:If {L4}?1
: 1?{{P}*2+L4+3}
: 0?{{P}*2+L4+4)
: {P}+1?{P}
:End
:End
:
:.3  DOWN
:!If pxl-Test({A},{B}+7)r
:If {L4+1}?1
: 0?{{P}*2+L4+3}
: 1?{{P}*2+L4+4}
: {P}+1?{P}
:End
:End
:
:.4  LEFT
:!If pxl-Test({A}-1,{B})r
:If {L4}??1
: ?1?{{P}*2+L4+3}
: 0?{{P}*2+L4+4}
: {P}+1?{P}
:End
:End
:
:.resume indent
:
:    {rand^{L4+2}*2+L4+3}?P
:    {P}?iPart(U}
:    {P+1}?iPart(V}
:    sub(GGD)
:   End
:
:..............

I am using L4 as super temporary storage.  It is used in one routine during my loop, and I write completely new data to it each time I use it, so volatility isn't an issue.  I tested all of the things I wasn't sure about (such as using pxl-test() on an off-screen locaiton) and all of that sort of stuff works as expected.

Here is what my variables do:


Here is the structure of L4:


*These values are either 1, 0, or -1.

Thanks for your help!  It is depressing that I couldn't figure it out myself.  :'(
Title: Re: Some (big) issues with ghosts
Post by: Michael.3545 on November 01, 2010, 01:54:07 pm
*bump*
Title: Re: Some (big) issues with ghosts
Post by: squidgetx on November 01, 2010, 03:24:44 pm
Are the black pieces (the walls) black on the backbuffer as well? Because I see in your code you are using pxl-test()r

Also, I'm not sure how well negative numbers and nibbles mix. I had this problem in cuberunner, and ended up just using whole bytes for the direction of the velocity vector. Normally a -1 is parsed as a 65535, and a -1 in a sign{} is parsed as a 255. (talking about addition/multiplication here), but a -1 as a nibble is parsed as....15? I'm not really sure.

Third, this looks problematic:
Code: [Select]
:    {rand^{L4+2}*2+L4+3}→P
:    {P}→iPart(U}
:    {P+1}→iPart(V}

If I can understand what you're doing, L4 holds numbers you want to use, not pointers. So I think you might want
Code: [Select]
:    rand^{L4+2}*2+L4+3→P
:    {P}→iPart(U}
:    {P+1}→iPart(V}
instead.
Title: Re: Some (big) issues with ghosts
Post by: Runer112 on November 01, 2010, 06:39:37 pm
Well it took like three hours of stepping through the instructions one-by-one in wabbitemu's debugger, but I think I isolated and solved all the problems. :)
Title: Re: Some (big) issues with ghosts
Post by: Michael.3545 on November 01, 2010, 11:25:57 pm
Judging by what runer changed, I guess it was an issue with the nibbles values, as squidget suggestet.

Well it took like three hours of stepping through the instructions one-by-one in wabbitemu's debugger, but I think I isolated and solved all the problems. :)

This is way beyond what I expected from anyone.  Runer112, you have earned my undying thanks and definitely mention in the final program.  Your new source is indeed working exactly as it should, much to my elation.  I have sent it to my calc, and will be looking to see what you did over the next few days.  If I can't work it out myself, I will post back here.  Thanks!

 :)
Title: Re: Some (big) issues with ghosts
Post by: DJ Omnimaga on November 01, 2010, 11:58:07 pm
Wow nice Runer112. Hopefully it works well :D