Hi all,
I'm working on a 2D game where the player will start with a pistol, and then will be able to walk over pickups to temporary upgrade to a better weapon, like a shotgun for example, for about a minute or so before reverting back to the pistol. My question is; would the coding structure/logic look something like this?:
Bullet scene:
Area2D
-Sprite
-CollisionLayer
Bullet script/class:
Contains functions for handing basic physics, on_body_entered and exit
Base Gun scene:
Node2D
-Sprite
-Position2D (to determine where bullets spawn from)
Base Gun script/class:
Function to instance and shoot bullet scene
Function that determines fire rate, bullet speed, cooldown between shots, etc. variables
Pickup scene:
Similar to Base Gun scene
Pickup script:
Extend Base Gun class, but different variables like fire rate for the different pickup types
Player scene:
Create Node 2D scene called WeaponManager
Instance the Base Gun and Pickups as child nodes
Player script:
Functions to determine current weapon in WeaponManager and call that pickup's firing pattern set in Pickup script
I know I'm missing a couple of functions, but just trying to determine the overall correct way before jumping in with two-feet. For some reason, I keep going between adding the fire rate, bullet speed, etc to the Bullet script vs the Base Gun script.
Appreciate any opinions on this!