0
votes

Okay, I have read some articles about basic platformer creation, people say it's the hardest part - to make correct collisions at high speeds. Indeed, even if I have 60 fps, an object moving at like 50-100 pixels per tick is hard to trace. The problem is, if it hits a wall, it passes through it, detects going too far and returns the object to a defined point next to a wall with speed 0 (or ricochets). But if I have a 5 pixel wall in a middle of a stage, even at low speeds collision may just be missed. Yeah, you'd say "make 2 areas, check if object in one, another will be a whole hitTest zone to return from it" but what if I need a maze of randomly drawn walls? What is a good way to make thin walls an object wouldn't pass?

Thinking of platformer, I recall Castlevania and Metroid, it wasn't AS3, but still, maybe you know how they did it so smooth? Good fps? Predicting collisions? Or does nobody make crazy speeds like a ricocheting bullet?

I could really use some ideas before I dive into coding. I wish to at least know I'm moving the right way, even if it's hard. To not end up with 1000 lines, not remembering where is what and CPU load @ 95% for 1 single object XD My guess for now is make 4 invisible blocks right, left, up and down of the object and count each side collisions separately. But it may get ugly on the corners. 8 blocks maybe?

1

1 Answers

1
votes

At the moment, you're checking if the object is intersecting with a wall at the exact moment the frame happens, but really you want to know if the object ever intersected with the wall between the last frame and now. You can imagine a line between where the object was before and where it is now, so essentially you need to check if that line intersects with the line of the wall.

It's quite old, but tonypa has a nice tutorial here which goes over all of the basics.