Jump to content
IGNORED

In C, Sprite touching pattern.


Recommended Posts

In the C coding guide or by experience.

 

Which command or what collision routine do you guys use for when a sprite is colliding or over a pattern.

 

I have some ideas but it's those damn offsets because the sprite position is the upper left hand corner.

 

Would love to hear your thoughts and input.

 

TIA

 

Link to comment
Share on other sites

The one thing that stands out from memory reading about Adventure that it checks if the controller is left or right in one frame, and check left/right collision, then up and down the next frame, then check up and down collision. If you're going diagonal up/left, it'll move you left one frame, and then up the next frame. You would need to use bitwise to trim out which controller bit is up or left. That way, you can check if the ball is inside wall, if it is it'll bounce you out.

Anyway, for C.


if(joypad_1&UP){playerp=2*16;
if (walk==0){walk=15;}

y=(playery+8)/8;
x=(playerx+8)/8;
TileID = get_char(x,y);
if(TileID>=192){playery--;}
}


if(joypad_1&RIGHT){playerp=1*16;
if (walk==0){walk=15;}
y=(playery+12)/8;
x=(playerx+12)/8;
TileID = get_char(x,y);
if(TileID>=192){playerx++;}
}

if(joypad_1&DOWN){playerp=0*16;
if (walk==0){walk=15;}
y=(playery+16)/8;
x=(playerx+8)/8;
TileID = get_char(x,y);
if(TileID>=192){playery++;}
}
if(joypad_1&LEFT){playerp=3*16;
if (walk==0){walk=15;}
y=(playery+12)/8;
x=(playerx+4)/8;
TileID = get_char(x,y);
if(TileID>=192){playerx--;}
}

This is the code I used for beach clean up. Notice this is for 16x16 sprites. You're able to go diagonal.

Here's some information on Adventure's collision detection, http://atariage.com/forums/topic/245005-wall-collisions-in-adventure/?hl=%2Badventure+%2Bcollision+%2Bwall

Edited by Kiwi
Link to comment
Share on other sites

Thank you for the help.
I am rewriting some some code and optimizing a lot to make things faster.

As far as the Atari version of Adventure and it's limitations I had to write the Coleco version from scratch as well as the graphics and sound despite being similar.

Aspect ratio and colors are different so I have to take liberties.

In my version the rooms are completely drawn on one scan line then you are free to move about the room without having to bother about it ever again.

 

Objects are drawn after the room and I am looking at better ways to do that but for the amount of object currently cause no speed issues but if I were to go up to 255 I suspect it would slow down.

My engine is great for the size of Adventure or DOUBLE the size of the original Adventure but if I were to go more intensive I probably could not get away with it.

Either way I will come in under 32k and will do everything I can to be polished and bug free.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
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...