Jump to content

# Collision prevention questions

## Recommended Posts

I found an old collision prevention example here on the forum   (collision_prevention_with_detection_2013y_05m_14d_0155t)

and started to try to implement it in a little test, it made alot of sense, this is how I understood that one

temp5 = ((player0x-15)/4)+1

;converts player0x right side coordinates to pfpixel coordinates

temp3 = ((player0x-15)/4)

;converts player0x left side coordinates to pfpixel coordinates

temp6 = ((player0y-1)/8)-1

;converts player0y coordinates to pfpixel coordinates just above the sprite

So I picture those cordinates changing every four regular pixels you move, kinda like a laggy roof that's following you

then you pfread that area for pfpixels by checking left and top, and right and top

if pfread(temp5,temp6) then if pfread(temp3,temp6) then goto __Skip_Move_Up

But then I looked if it had been updated on RT and it had and I'm a little confused with the new one

temp5 = (player0x-10)/4

temp6 = (player0y)/8

if temp5 < 34 then if pfread(temp5,temp6) then goto __Skip_Joy0_Down

temp4 = (player0x-17)/4

if temp4 < 34 then if pfread(temp4,temp6) then goto __Skip_Joy0_Down

temp3 = temp5 - 1

if temp3 < 34 then if pfread(temp3,temp6) then goto __Skip_Joy0_Down

Why are there four conversions, and three pfread for up and down?

Why check if the horisontal position is less than 34, isn't 31 the highest?

And I get that two pfpixels covers the players width but how is the height taken care off for left and right?

Edited by Lillapojkenpåön

#### Share this post

##### Share on other sites

Do you have a link to the post that has "collision_prevention_with_detection_2013y_05m_14d_0155t"?

Here are a few other versions we should look at:

I don't remember why I used 34 instead of 32. The collision prevention programs on the bB page might need to be updated.

#### Share this post

##### Share on other sites

Oh, I get it now

This is as simple as I could make it

If we use the correct numbers, the player will overlap one scanline at the top, and be one scanline above the bottom, since it can only be placed every other scanline I guess.

so I check one pixel above that for up, and also for the top pixel for left and right to keep it a box, that results in one scanline above and one below.

Edited by Lillapojkenpåön

#### Share this post

##### Share on other sites

I made another one that supports variable speeds.

If your speed is let's say three and you're going right it will loop and check

; 00111100A

; 01111110

; 11000011

; 10111101

; 11111111

; 11011011

; 01111110

; 00111100B

; 00111100 A

; 01111110

; 11000011

; 10111101

; 11111111

; 11011011

; 01111110

; 00111100 B

; 00111100  A

; 01111110

; 11000011

; 10111101

; 11111111

; 11011011

; 01111110

; 00111100  B

; 00111100   A

; 01111110

; 11000011

; 10111101

; 11111111

; 11011011

; 01111110

; 00111100   B

if there is playfield in the way the player will snap to the edge, if not it will move normally.

## Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

• ### Recently Browsing   0 members

No registered users viewing this page.

×
×
• Create New...