When I first started on BatteryCheck it was actually just a viewer to browse around the level and make sure I implemented the loader according to the specs. To make my demo a bit more fun and give the player something to do I really wanted a way to control Batteryman and make him stand on platforms. While my very primitive collision detection works it does not do any correction at all! And this is the reason you can get stuck in walls or sink in the floor after jumping. This obviously needs to be fixed for my next version and I have given myself a deadline of at most three months! (hopefully it will be sooner though)
Reading the Sonic Physics Guide again from the start helped refreshing my knowledge on how collision detection and response work for the older sonic games. If you want to know what I am talking about below you could read the Solid Tiles section until the A and B sensor lines used to detect the floor. The most important part of it is that there are two sensors instead of just one and they work together to detect the floor and slopes in Sonic games. The slopes are not important for BatteryCheck but they might be late when my engine could be used for Jazz Jackrabbit and SuperTux. The ground is only there when both sensors are triggered and if it's just one while walking you are walking on a ledge, and that should trigger a different animation of BatteryMan balancing trying not to fall. I am not sure yet what to do when only one of the triggers is activated while falling but I think I will ignore it until they both detect solid ground. When jumping the A and B triggers should be disabled and only detect again when you start to fall down, the reverse is true for C and D which are detecting the Ceiling.
The detection of solid pixels with the sensors is already working for the map meaning: floor, walls and ceilings. When this is detected for the floor I force the player to a 32x32 grid aligned position which is actually working much better than I expected. But what is actually required when a sensor detects a solid pixel is finding the surface of the solid object by moving in the other direction. To give an example when running into a wall at a speed let's say 3.5 pixels per frame (the max speed in BatteryCheck it's possible to get stuck into a wall at least that deep. So when the pixel is solid at offset 35 to the right a loop should be testing it at 34,33,32,etc until a non-solid pixel is found and correct the player position accordingly.
With these improvements in place the collision detection feels a lot more like it should be. The next thing to do is include the interactive elements into the isPixelSolid() function to make the floats, elevators and conveyors solid again too. Combined with the correction explained above the player should then also move when an elevator is moving or a float sinks into the water. Speaking of water...this needs to be detected separately because in water you take damage and can actually survive a while before sinking to the bottom. But let's not jump into that right now
Hopefully this technical insight into my progress was interesting enough, please let me know
Reading the Sonic Physics Guide again from the start helped refreshing my knowledge on how collision detection and response work for the older sonic games. If you want to know what I am talking about below you could read the Solid Tiles section until the A and B sensor lines used to detect the floor. The most important part of it is that there are two sensors instead of just one and they work together to detect the floor and slopes in Sonic games. The slopes are not important for BatteryCheck but they might be late when my engine could be used for Jazz Jackrabbit and SuperTux. The ground is only there when both sensors are triggered and if it's just one while walking you are walking on a ledge, and that should trigger a different animation of BatteryMan balancing trying not to fall. I am not sure yet what to do when only one of the triggers is activated while falling but I think I will ignore it until they both detect solid ground. When jumping the A and B triggers should be disabled and only detect again when you start to fall down, the reverse is true for C and D which are detecting the Ceiling.
The detection of solid pixels with the sensors is already working for the map meaning: floor, walls and ceilings. When this is detected for the floor I force the player to a 32x32 grid aligned position which is actually working much better than I expected. But what is actually required when a sensor detects a solid pixel is finding the surface of the solid object by moving in the other direction. To give an example when running into a wall at a speed let's say 3.5 pixels per frame (the max speed in BatteryCheck it's possible to get stuck into a wall at least that deep. So when the pixel is solid at offset 35 to the right a loop should be testing it at 34,33,32,etc until a non-solid pixel is found and correct the player position accordingly.
With these improvements in place the collision detection feels a lot more like it should be. The next thing to do is include the interactive elements into the isPixelSolid() function to make the floats, elevators and conveyors solid again too. Combined with the correction explained above the player should then also move when an elevator is moving or a float sinks into the water. Speaking of water...this needs to be detected separately because in water you take damage and can actually survive a while before sinking to the bottom. But let's not jump into that right now
Hopefully this technical insight into my progress was interesting enough, please let me know
