Test of Concept
It's 2 am Tuesday Morning over here in Michigan, and I am finishing up a test of concept program. I am writing a 2D, top down, tile based, puzzle game. So far I have a tile background, and 5 different objects that take up space on the grid (The player, walls, and three mob sprites, each of which moves differently) Hopefully after a little more work, and a good night's rest, I'll have my first upload posted.Already I have started to notice the quirks of tile based games. Because sprites take up a single tile, and then abruptly shift into the next tile over, collisions arnt detected until both objects are sitting in the same space. This causes a quick flash as the sprite in question collides with a solid object and then a frame later moves back to it's previous position. Even at the highest of frame rates, its impossible not to notice. The other thing (so far) is that because all sprites move at the same time, its actually possible to "dodge" an unfriendly sprite as the two of you switch places. I think that offsetting the move time of the player and the other sprites by a single frame should fix this without it looking really bad, but I haven't had the time just yet to work that out.
Ok, time for some sleep, and hopefully I can remember how to package this all up.
(log in to comment)
Comments
Sounds like you need to search the surrounding tiles, as well the tile that the sprite is in, for potential colliding objects.
draw_screen
for each moving object:
old pos = pos
move
if collision:
pos = old pos
This should solve both issues mentioned. It doesn't matter if player A is moving right and player B is moving left. When player A tries to move right he is bounced back, and when player B tries to move left he is also bounced back.