Im back after a big break

Are you new to 6502, NES, or even programming in general? Post any of your questions here. Remember - the only dumb question is the question that remains unasked.

Moderator: Moderators

Post Reply
User avatar
log in
Posts: 72
Joined: Tue Jun 24, 2008 1:06 pm
Location: neverland

Im back after a big break

Post by log in »

well,im back.. i didn't had much time to work on my nes programming..but..i broke my ankle


So..i got enough time now.. :cry:

I will read all my documents again , already know everything about the set up etc.
I got stuck on the collision decetion programming.

So can somebody please give me a exsample or a good document (its really hard to find some good info about this)

This wil really cheer me up :D /then i got something to do with my laptob

PS: offtopic how is it with garage cart 2? somebody mentioned that you guys are working on it?
im a newbie,lets see how far i can get
Celius
Posts: 2159
Joined: Sun Jun 05, 2005 2:04 pm
Location: Minneapolis, Minnesota, United States
Contact:

Post by Celius »

Collision detection can be a tricky thing, depending on the type of game, and also, whether you're talking sprite on sprite, or sprite on background.

For sprite on sprite (Software metasprites, not hardware sprites), you probably want to do a sort of bounding box collision. You set up bounding boxes around an object by keeping track of the object's coordinates and calculating the Y positions of the top and bottom borders of the box, and the X positions of the left and right borders of the box based off of the object's coords. So each object(metasprite) that can collide with another has these boxes around them. Then what you do is a simple series of comparisons to check if the sprites aren't overlapping. If it fails all of the checks, the objects have collided. These comparisons compare the positions of the bounding box borders of two objects that could be colliding. See here for more information:

http://nesdev.com/bbs/viewtopic.php?t=3743

For sprite to background, it's a bit different. You still want to have the bounding boxes set up around the sprite, but you keep track of certain points on the bounding box that will collide with the background. In order to collide with that background, you have to have a map of some sort in RAM or ROM which describes what's on screen or to be collided with. You usually take the coordinates of the points on these bounding boxes, and somehow find out what tile is at that position in the map. Once you find out which tile (It could be a metatile, or single tile, or whatever) is being collided with, you can do what you want. Usually there are different tile types (water, diagonal solid, complete solid, etc.) that are collided with, so you want to do different things depending on which tile type you collided with.

How exactly you go about doing this depends on what limits you have, what type of game you're making, etc.

Oh, and sorry about your ankle. I've been lucky enough to have never had a broken limb ever; it sounds like it would hurt a lot =(.
User avatar
log in
Posts: 72
Joined: Tue Jun 24, 2008 1:06 pm
Location: neverland

Post by log in »

well i broke my ankle just by making a bad step,very funny if you imagine that i did a lot of sports (soccer,boxing,tennis)and broke nothing. :D

Im making a simple pong clone
I still have the sprites and background stuff

just need to ad collision in there and music (and maybe a start screen later)
I will read your links thanks.
im a newbie,lets see how far i can get
albailey
Posts: 177
Joined: Thu Jul 13, 2006 3:15 pm

Post by albailey »

There's lots of good 2D stuff in the graphics gems series
http://tog.acm.org/GraphicsGems/gems.html

I'll admit that I've never made reference to this for my NES programming, but I used to refer to it alot back in my ray-tracing days.

Let me know if you find anything good in there.

Al
User avatar
Memblers
Site Admin
Posts: 3901
Joined: Mon Sep 20, 2004 6:04 am
Location: Indianapolis
Contact:

Post by Memblers »

Maybe you've seen this, but I thought it gives a pretty good overview of hit detection:
http://www.greggman.com/mckids/programming_mc_kids.htm

And Garage Cart 2, it's coming along nicely. I entered the actual coding phase of it at the beginning of last week, and have been hacking away at it for a couple hours every day since then. Currently it's twice the ROM size of GC#1, with slightly more than twice the games. I'm still seeking last-minute additions (H mirroring required).

I hope you're ankle gets better, I remember having a sprained ankle once and that sucked plenty enough (the pain randomly came back even years later - not anymore though).
Post Reply