DEVLOG 2: Added New weapons and reload system
Just made a new shotgun and a machine gun and a melee weapon to go with the original pistol.
However, this was not the smoothest journey…
Fixing the 360-Degree Aim Bug
The biggest headache was a bug where the shooting worked perfectly in the bottom-left quadrant of the screen but went completely wild in the other three. It turned out to be an issue with local versus global coordinates when mixing the player node’s position and the muzzle position. I fixed it by bypassing the muzzle’s relative math entirely and calculating the trajectory straight from the player’s core global position. Now aiming and shooting are perfectly consistent all 360 degrees around the player.
Reloading States and Auto-Reload
I wired up the static reload sprites so they actually show up visually. The issue before was that the sprite swap was happening after the timer finished, so it never showed up. Now it swaps to the reload frame instantly when you press R, and then swaps back to the normal shooting frame when the timer finishes. I also made it so that the second your mag drops to zero, it calls the reload function automatically without making you click an extra time.
here is how I made the different gun types
enum GunType { PISTOL, SHOTGUN, MACHINE_GUN, KNIFE}
var gun_stats = {
GunType.PISTOL: {"current_ammo": 7, "ammo_max": 7, "reload_time": 1.0, "spread": 0, "projectiles": 1, "is_automatic": false, "is_melee": false},
GunType.SHOTGUN: {"current_ammo": 2, "ammo_max": 2, "reload_time": 2.0, "spread": 0.22, "projectiles": 5, "is_automatic": false, "is_melee": false},
GunType.KNIFE: {"current_ammo": 1, "ammo_max": 1, "reload_time": 0.4, "spread": 0, "projectiles": 0, "is_automatic": false, "is_melee": true},
GunType.MACHINE_GUN: {"current_ammo": 30, "ammo_max": 30, "reload_time": 2.2, "spread": 0.08, "projectiles": 1, "is_automatic": true, "is_melee": false}
}
Mobile-Friendly Drag and Release Controls
I completely changed how aiming and firing work to make the game ready for a mobile layout. Instead of just clicking to shoot, you now hold down the mouse button (or your finger on a screen) to bring up the trajectory line and aim. For semi-auto weapons like the pistol and shotgun, you rotate around as much as you want to frame the shot, and the gun fires the exact moment you release the button. For the machine gun, it continuously fires while you hold it down but limits the rate of fire with a quick cooldown loop so it doesn’t empty all 30 rounds in one frame. The player also keeps turning smoothly even when they aren’t actively clicking.
What’s Next?
- Making the zombies
- The ‘waves’ mechanic
- Player and Zombie damage system
- Loot System
- Polish up the reload UI
- Add collision rules for house
I also made a test level to get an idea of how the level will be layered out. Check out the video! (if it loads…)
Comments 0
No comments yet. Be the first!
Sign in to join the conversation.