This is a fixed version where the little guy you move around has better fake/real collision detection. It no longer overlaps the playfield pixels like it did sometimes in the first version. It corrects itself as soon as it starts to happen, so the problem I had in the first version is eliminated. In other words, similar to what SeaGtGruff said below, it uses a combination of 'collision prevention' and collision detection to make the sprite behave properly. This is the smoothest sprite/wall collision I've seen in a bB program so far. Move the sprite around the playfield pixels and see for yourself.
Here's the .bin file to use with an emulator or Harmony cartridge:
ex_sprite_with_ball_missile_and_collision_2011y_06m_16d_0425t.bin 4K
69 downloadsHere's the bB code:
ex_sprite_with_ball_missile_and_collision_2011y_06m_16d_0425t.bas 31.53K
68 downloadsOld Version:
This is the first draft of an example program that has a sprite, a bouncing ball, a missile you can shoot, and a mix of real and fake collision detection.
Use the joystick to move the sprite. Press the fire button to shoot the missile. Press the reset switch to reset the program and toggle between two screens.
Here's the .bin file to use with an emulator or Harmony cartridge:
ex_sprite_with_ball_missile_and_collision_2011y_06m_10d_0334t.bin 4K
50 downloadsHere's the bB code:
ex_sprite_with_ball_missile_and_collision_2011y_06m_10d_0334t.bas 29.67K
40 downloadsI think it took about a week, but I finally got the ball to bounce around without screwing up and acting weird. I'm still not happy with the code. After trying all kinds of things, it started working, but I don't know why or how. If someone with a bigger brain can make it work using better code, I'd appreciate it.
The fake collision detection for the Player0 sprite using pfread works, but it's not as good as I'd like it to be. The sprite can overlap playfield pixels a little bit depending on how you move. Again, if anyone can improve on the code, please do so.
It would be nice if this example program was in better shape before I put it on the bB page.
Edited by Random Terrain, Mon Jun 20, 2011 11:32 AM.














