Quote:
The way I plan on doing it is once a ground is visible on the screen, it will get its starting X-position and ending X-Position, And then it will compare that to the players X-Position as well as compare the Y-positions. But this method will eat up a lot of ROM space because I'd have to program hit detection for each ground surface in the entire game, and that's very impractical.
You need to be precise when programming, and there was a lot of hand waving there.
Quote:
The way I plan on doing it is once a ground is visible on the screen
What do you mean, "a" ground? A ground tile? An object that represents a single platform? You need to figure out how,
precisely, you're going to represent your maps as data - how you do collision detection with it falls directly from that. And for us to give you suggestions about how to store your maps, you need to tell us more - anything! - about the nature of them and your game. There really isn't a one-size-fits-all solution, especially on a limited 8-bit platform.
Quote:
it will get its starting X-position and ending X-Position
What will? Your game engine? How does it get that data? How often does it do this check?
Quote:
But this method will eat up a lot of ROM space because I'd have to program hit detection for each ground surface in the entire game
Again, it's not clear what you mean here. What is a "ground surface" in this context? You have something in mind, but you're too vague on the details for us to help you.
I'm hesitant to try to actually answer your question, because it feels like a case of giving a man a fish instead of teaching him to do it (and when he only has a vague idea of what water or a fishing rod are). But FWIW, say you're making a Zelda-like overhead game with no scrolling; you might store your map as a grid of 16 pixel by 16 pixel tile types. The NES has a 256x240 screen, so that'd be a 16 tile by 15 tile screen (because 256 divided by 16 = 16, and 240 divided by 16 = 15). You could assign each type of tile a number: grass might be 0, dirt road is 1, rock is 2, etc.
Your character's position on screen would be stored in pixels; to keep things simple, say it's a dot rather than a square. You'll probably want to figure out what tile they're on; to convert from pixels to tiles, you'd just divide by 16 and throw away the remainder. So if they're at X=148, Y=63 on screen, they're on the tile located at X=9, Y=3 in the map.
Conveniently, on old processors like the 6502, even though general purpose division is hard, division by a power of 2, like 16, is easy - every right shift divides a number by 2, so if you right shift four times, you'll divide by 2^4, or 16.
Now here's a question: when do you want to check for collisions? I'd say, maybe, whenever you try to move the character, you want to see if the new coordinates you're trying to move to can be walked on. So let's say the player is trying to move down one pixel, the new Y coordinate is 64 in pixel space, or 4 in tile space. So you'll want to check the map to see what kind of tile that is. How can you do that?
Well, let's assume you're storing your map as tile numbers from left to right, top to bottom. If Y were zero, how would figure out which number to look at? That's right, it'd just be the X tile coordinate. Now suppose X is 0, but Y is 1 - which tile do you check now? It'd be the first tile in the second row, which would be tile number 16. In general, to compute an index into your tile list, you'd calculate Ytile * the width of the map in tiles + Xtile. You can used indexed addressing to look a computed number up in a list of numbers like the tile map.
Now once you have the tile number, what do you do? Well, you have a bunch of options, but in the simplest case you can store a list mapping tile types (numbers) to a number that indicates whether or not you're allowed to walk on it - 0 means you can, 1 means you can't. Then you just use indexed addressing again to look up whether the tile is walkable or not, and behave accordingly.