Question about sprites & pixel position

4 replies to this topic

#1 jeffryOFFLINE

jeffry

• 15 posts

Posted Thu May 17, 2018 4:46 AM

I am trying to code my own colision detection.

Everytime I think i have it ... I don't.

I am hoping someone get help me get back on track.

Suppose my player0 sprtie is a 8x8 square.

If I set player0x = 50 & player0y = 50  which pixel of my sprite will be at coordinates 50,50?

123454678

a ########

b ########

c ########

d ########

e ########

f  ########

g ########

h ########

Is  a1? h1? a8? h8?  Something else?

Also how does using the REFP0 affect this?

My code seems to me that everything looks correct yet it doesnt quite work. I believe if I can get a clear answer on which pixel is at the defined coordinate I can figure this out.

Thanks for any help to set me straight.

Edited by jeffry, Thu May 17, 2018 4:47 AM.

#2 Random TerrainOFFLINE

Random Terrain

Visual batari Basic User

• 28,964 posts
• Controlled Randomness
Replay Value
Nonlinear
• Location:North Carolina (USA)

Posted Thu May 17, 2018 5:28 AM

Have you played with any of the example programs below? You can move sprites around and see the coordinates in the score:

Find Border Coordinates

9 Objects with Coordinates

13 Objects With Coordinates and Collision (DPC+)

#3 Karl GONLINE

Karl G

Dragonstomper

• 793 posts

Posted Thu May 17, 2018 6:11 AM

H1. Reflecting the sprite won't affect the positioning of the sprite.

Edited by kdgarris, Thu May 17, 2018 6:15 AM.

#4 jeffryOFFLINE

jeffry

• Topic Starter
• 15 posts

Posted Thu May 17, 2018 12:06 PM

@Random Terrain

Thanks I had seen that program before in fact i modified it to measure and plot playfields.

I just never thought about utilizing it in this context .. brainfart I guess... Thanks!

P.S. I assume by your name you are the one with the similiarly named website.... SO THANK YOU again. you have given me unmeasurable guidence and help via that site.

@kdgarris... Thanks.. I was hopping that not accounting for the REF was part of my problem but alas I screwed up elsewhere

Thanks to Both of you!!!!

#5 RevEngOFFLINE

RevEng

Bit Player

• 5,176 posts
• Location:bottom of the stack

Posted Sat May 19, 2018 6:00 PM

The answer to your original question actually varies on the kernel used. The standard kernel uses your "h1" as the base. DPC+ uses your "a1". The multisprite kernel regular player uses "h1", and the virtual players are a bit offset from there.

The wrinkle to all of these is if you use NUSIZ#=5 or NUSIZ#=7 to modify the player size, it's pushed one pixel to the right.

I've put together a boxcollision routine for bB along with some samples, which you may be interested in.

0 user(s) are browsing this forum

0 members, 0 guests, 0 anonymous users