Author Topic: My hittesting doesn't work.  (Read 5528 times)

0 Members and 1 Guest are viewing this topic.

Offline lookitsan00b

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 173
  • Rating: +37/-3
    • View Profile
My hittesting doesn't work.
« on: November 04, 2010, 06:12:04 pm »
Why doesn't this work? ???
Code: [Select]
.Ball move
{B-1}+{B-3}→{B-1} .move X
{B}+{B-2}→{B}       .move Y
If -2>=>={B-1} or ({B-1}>=>=90)
  0-{B-3}→{B-3}
End
If -4>=>={B} or ({B}>=>=56)
  0-{B-2}→{B-2}
End

where:
{B-3} = xvel
{B-2} = yvel
{B-1} = x
{B} = y

The ball does not bounce off the left and top walls.  It eventually bounces, but REALLY far off screen.
Btw the reason for the odd numbers is I'm using a padded sprite... (4 on top, 2 on each side)
My TI-94+SE is broken.  I used some flawed existential conditioning on it, and it crashed. :(

Activity level:
{====______}

Spoiler For Securite:
{=========_}

A couple security flaws
Need a good backdoor short of reinstalling the OS
Completely immobilized and invalidated by Zstart. And rendered incompatible.
Spoiler For FFTATIA:
{====______}

framework: mostly done
graphics engine: undergoing complete rewrite
still need character and enemy sprites!!! :P

SirCmpwn

  • Guest
Re: My hittesting doesn't work.
« Reply #1 on: November 04, 2010, 06:14:04 pm »
It looks like you are having problems with unsigned numbers.  Try this:
Code: [Select]
.Ball move
{B-1}+{B-3}→{B-1} .move X
{B}+{B-2}→{B}       .move Y
If -2>=>=sign{B-1} or (sign{B-1}>=>=90)
  0-{B-3}→{B-3}
End
If -4>=>=sign{B} or (sign{B}>=>=56)
  0-{B-2}→{B-2}
End

where:
{B-3} = xvel
{B-2} = yvel
{B-1} = x
{B} = y
« Last Edit: November 04, 2010, 06:14:13 pm by SirCmpwn »

Offline yunhua98

  • You won't this read sentence right.
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2718
  • Rating: +214/-12
  • Go take a dive in the River Lethe.
    • View Profile
Re: My hittesting doesn't work.
« Reply #2 on: November 04, 2010, 06:14:45 pm »
hello, and welcome here.  I'm that sure at the moment, but are you using the B as a location in RAM or as a variable?

EDIT:  ninja'd
« Last Edit: November 04, 2010, 06:15:18 pm by yunhua98 »

Spoiler For =====My Projects=====:
Minor setback due to code messing up.  On hold for Contest.
<hr>
On hold for Contest.


Spoiler For ===Staff Memberships===:






Have you seen any good news-worthy programs/events?  If so, PM me with an article to be included in the next issue of CGPN!
The Game is only a demo, the code that allows one to win hasn't been done.
To paraphrase Oedipus, Hamlet, Lear, and all those guys, "I wish I had known this some time ago."
Signature Last Updated: 12/26/11
<hr>

Offline lookitsan00b

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 173
  • Rating: +37/-3
    • View Profile
Re: My hittesting doesn't work.
« Reply #3 on: November 04, 2010, 06:16:16 pm »
So it doesn't just assume that my numbers are signed, even if I use the signed comparisons?
I never really understood signed numbers, thanks.

EDIT: B is a location in ram, L1 + 3, to be exact.
« Last Edit: November 04, 2010, 06:16:57 pm by lookitsan00b »
My TI-94+SE is broken.  I used some flawed existential conditioning on it, and it crashed. :(

Activity level:
{====______}

Spoiler For Securite:
{=========_}

A couple security flaws
Need a good backdoor short of reinstalling the OS
Completely immobilized and invalidated by Zstart. And rendered incompatible.
Spoiler For FFTATIA:
{====______}

framework: mostly done
graphics engine: undergoing complete rewrite
still need character and enemy sprites!!! :P

ASHBAD_ALVIN

  • Guest
Re: My hittesting doesn't work.
« Reply #4 on: November 04, 2010, 06:19:29 pm »
Welcome, lookitsan00b! :D

yeah, signed numbers have a different range of numbers to them all together.

EDIT: well maybe not all together, but they are kinda different

For example, an unsigned byte is 0-255, but a signed one is -128-127.
For words (two bytes), it's 0-65535 unsigned, -32768-32767 signed.

Though unless you use sign{, they're read as the same numbers.
« Last Edit: November 04, 2010, 06:20:12 pm by ASHBAD_ALVIN »

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: My hittesting doesn't work.
« Reply #5 on: November 04, 2010, 06:21:03 pm »
1 byte signed = -128 to 127
1 byte unsigned = 0 to 255
2 byte signed = -32768 to 32767
2 byte unsigned = 0 to 65535

Welcome here, by the way :)

EDIT: I got ninja'd
« Last Edit: November 04, 2010, 06:21:14 pm by DJ Omnimaga »

SirCmpwn

  • Guest
Re: My hittesting doesn't work.
« Reply #6 on: November 04, 2010, 06:21:13 pm »
Welcome to Omnimaga, by the way.  Here's a quick overview of how signed numbers work:
You really can't store negative numbers on a computer.  You probably know you can store any number in a single byte from 0-255.  However, we have decided that from 0-127 will be 0 to 127, and from 128-255 will be -1 to -128.  So for example, if you have -1, it would be stored as 255.  However, if you add 1 to -1, you should get zero, right?  Well, this works because when you hit 256 or higher adding single bytes, you start over at zero.  So, adding 1 (1) to -1 (255) is the same as 255+1, which equals 256, which rolls over to zero (-1+1).  Don't worry if you have trouble, this is one of the hardest concepts in computing ever.
Axe gives you the option of using signed or unsigned numbers.  So with signed numbers that are single bytes, you have to specify what kind of numbers they are.
« Last Edit: November 04, 2010, 06:21:42 pm by SirCmpwn »

Offline lookitsan00b

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 173
  • Rating: +37/-3
    • View Profile
Re: My hittesting doesn't work.
« Reply #7 on: November 04, 2010, 06:21:25 pm »
I understand signed numbers, I did a little asm before moving to axe.  I just assumed that the signed comparisons took care of that for me...
Speaking of which, where do i find "Sign{"? I know I saw it somewhere, but I can't seem to find it again.
My TI-94+SE is broken.  I used some flawed existential conditioning on it, and it crashed. :(

Activity level:
{====______}

Spoiler For Securite:
{=========_}

A couple security flaws
Need a good backdoor short of reinstalling the OS
Completely immobilized and invalidated by Zstart. And rendered incompatible.
Spoiler For FFTATIA:
{====______}

framework: mostly done
graphics engine: undergoing complete rewrite
still need character and enemy sprites!!! :P

SirCmpwn

  • Guest
Re: My hittesting doesn't work.
« Reply #8 on: November 04, 2010, 06:23:14 pm »
It's in the Math menu.  They key is int(.

Offline lookitsan00b

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 173
  • Rating: +37/-3
    • View Profile
Re: My hittesting doesn't work.
« Reply #9 on: November 04, 2010, 06:24:05 pm »
Okay thanks!
My TI-94+SE is broken.  I used some flawed existential conditioning on it, and it crashed. :(

Activity level:
{====______}

Spoiler For Securite:
{=========_}

A couple security flaws
Need a good backdoor short of reinstalling the OS
Completely immobilized and invalidated by Zstart. And rendered incompatible.
Spoiler For FFTATIA:
{====______}

framework: mostly done
graphics engine: undergoing complete rewrite
still need character and enemy sprites!!! :P

Offline calc84maniac

  • eZ80 Guru
  • Coder Of Tomorrow
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2912
  • Rating: +471/-17
    • View Profile
    • TI-Boy CE
Re: My hittesting doesn't work.
« Reply #10 on: November 04, 2010, 06:25:29 pm »
It's needed for loading signed 8-bit values, because the value is extended to 16-bit after the load. So for example, you'll want the 16-bit result to end up as -1 (aka 65535) instead of 255. The sign{} instruction does this for you.
"Most people ask, 'What does a thing do?' Hackers ask, 'What can I make it do?'" - Pablos Holman

ASHBAD_ALVIN

  • Guest
Re: My hittesting doesn't work.
« Reply #11 on: November 04, 2010, 06:26:44 pm »
I found it in the math menu, instead of int( methinks

EDIT: super ninja'd
« Last Edit: November 04, 2010, 06:26:55 pm by ASHBAD_ALVIN »

Offline yunhua98

  • You won't this read sentence right.
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2718
  • Rating: +214/-12
  • Go take a dive in the River Lethe.
    • View Profile
Re: My hittesting doesn't work.
« Reply #12 on: November 04, 2010, 06:27:27 pm »
yeah, thats the Axe Tokens, it intalls a hook when you have an Axe header.

Edit: oh, I thought that was a question.
« Last Edit: November 04, 2010, 06:27:54 pm by yunhua98 »

Spoiler For =====My Projects=====:
Minor setback due to code messing up.  On hold for Contest.
<hr>
On hold for Contest.


Spoiler For ===Staff Memberships===:






Have you seen any good news-worthy programs/events?  If so, PM me with an article to be included in the next issue of CGPN!
The Game is only a demo, the code that allows one to win hasn't been done.
To paraphrase Oedipus, Hamlet, Lear, and all those guys, "I wish I had known this some time ago."
Signature Last Updated: 12/26/11
<hr>

Offline lookitsan00b

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 173
  • Rating: +37/-3
    • View Profile
Re: My hittesting doesn't work.
« Reply #13 on: November 04, 2010, 06:30:01 pm »
Wow! I just expected it to keep it as an 8-bit number. That explains it. Now what happens when I load 255 from B, increment it, and store it back?
Btw, works like a charm. Time to add hittesting for the paddle and blocks!
(btw, yes, it is a breakout clone, figured it was a good first project)
My TI-94+SE is broken.  I used some flawed existential conditioning on it, and it crashed. :(

Activity level:
{====______}

Spoiler For Securite:
{=========_}

A couple security flaws
Need a good backdoor short of reinstalling the OS
Completely immobilized and invalidated by Zstart. And rendered incompatible.
Spoiler For FFTATIA:
{====______}

framework: mostly done
graphics engine: undergoing complete rewrite
still need character and enemy sprites!!! :P

SirCmpwn

  • Guest
Re: My hittesting doesn't work.
« Reply #14 on: November 04, 2010, 06:30:40 pm »
Very nice!  Glad to help!  And may I direct you to our Introduce Yourself board?