BenMcLean #1 Posted August 22, 2014 (edited) I've been trying to build something with collision detection and I got the basic idea to store the sprite's current position in temporary variables, move the sprite to the place I want to check, and move it back to where I'd previously stored if there is a playfield obstacle in the way, while leaving the change permanently if it's clear. But for some reason, that basic concept doesn't seem to work. It gets stuck on the first obstacle encountered and cannot move anymore. Any idea why it's doing this? I'm guessing there's something about how sprite positions and/or the Atari's memory work that I'm not getting. A code example that produces this effect (which I've trimmed away most of the other stuff in my program) is attached. The score color changes if collision(player0, playfield) is true default.bas Edited August 22, 2014 by BenMcLean Quote Share this post Link to post Share on other sites
ZylonBane #2 Posted August 22, 2014 (edited) I assume you've constructed your algorithm with full knowledge that the collision registers for each sprite are set as they're drawn. EDIT: Okay, having looked at your source... you didn't. You seem to be assuming that the collision registers magically get updated immediately. They don't. They get updated after drawscreen. So you need to put the "if collision" code at the top of the player movement routine, not the bottom, because its job is checking the result of the previous frame, not the current one. At least, that's what I'm guessing is wrong. I haven't tested this theory, and I've never written any sprite manipulation code in bB. Edited August 22, 2014 by ZylonBane 1 Quote Share this post Link to post Share on other sites
+Random Terrain #3 Posted August 22, 2014 Here is one of the many ways you could do it: cd_2014y_08m_22d_1525t.bas But that's the old ugly sticky/bouncy method. I like the smooth method that includes pfread: randomterrain.com/atari-2600-memories-batari-basic-commands.html#sprite_collision_example Quote Share this post Link to post Share on other sites
BenMcLean #4 Posted August 22, 2014 (edited) I assume you've constructed your algorithm with full knowledge that the collision registers for each sprite are set as they're drawnNo, I didn't know that. Thanks for telling me. Random Terrain's site should probably mention that right here. Edited August 22, 2014 by BenMcLean Quote Share this post Link to post Share on other sites