bullet physics layer
This commit is contained in:
parent
9a6ea2c7b9
commit
55c2aeac80
1 changed files with 10 additions and 7 deletions
|
|
@ -8,8 +8,8 @@ extends Area2D
|
|||
signal recycled()
|
||||
|
||||
|
||||
## The number of bullets to allocate at startup.
|
||||
const INITIAL_ALLOCATED_BULLETS: int = 2000
|
||||
# ## The number of bullets to allocate at startup.
|
||||
#const INITIAL_ALLOCATED_BULLETS: int = 2000
|
||||
|
||||
|
||||
## Texture to draw for the bullet.
|
||||
|
|
@ -39,10 +39,10 @@ const INITIAL_ALLOCATED_BULLETS: int = 2000
|
|||
## The amount of time in seconds that the bullet has existed.
|
||||
var time_elapsed: float = 0.0
|
||||
|
||||
## If the bullet has been grazed before
|
||||
## Whether the bullet has already been grazed by the player.
|
||||
var grazed: bool = false
|
||||
|
||||
static var _cached_bullets: Array[Bullet] = []
|
||||
#static var _cached_bullets: Array[Bullet] = []
|
||||
static var _hitbox_shapes: Dictionary[Vector2i, RectangleShape2D] = {}
|
||||
|
||||
|
||||
|
|
@ -66,6 +66,7 @@ static func create(
|
|||
bullet.hitbox_size = hitbox_size
|
||||
bullet.direction = direction
|
||||
bullet.face_direction = face_direction
|
||||
|
||||
bullet.time_elapsed = 0.0
|
||||
bullet.grazed = false
|
||||
|
||||
|
|
@ -82,13 +83,15 @@ func recycle() -> void:
|
|||
recycled.emit()
|
||||
|
||||
|
||||
static func _static_init() -> void:
|
||||
for _i in INITIAL_ALLOCATED_BULLETS:
|
||||
_cached_bullets.append(Bullet.new())
|
||||
#static func _static_init() -> void:
|
||||
#for _i in INITIAL_ALLOCATED_BULLETS:
|
||||
#_cached_bullets.append(Bullet.new())
|
||||
|
||||
|
||||
func _init() -> void:
|
||||
monitoring = false
|
||||
collision_layer = 1 << 3
|
||||
collision_mask = 0
|
||||
add_to_group(&"bullets")
|
||||
_hitbox.debug_color.a = 0.0
|
||||
add_child(_hitbox)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue