bullet factory, push attack
This commit is contained in:
		
							parent
							
								
									7eca676464
								
							
						
					
					
						commit
						1ed49408f6
					
				@ -20,3 +20,26 @@ config/icon="res://icon.svg"
 | 
			
		||||
folder_colors={
 | 
			
		||||
"res://scenes/": "red"
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
[input]
 | 
			
		||||
 | 
			
		||||
left={
 | 
			
		||||
"deadzone": 0.5,
 | 
			
		||||
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":65,"key_label":0,"unicode":97,"location":0,"echo":false,"script":null)
 | 
			
		||||
]
 | 
			
		||||
}
 | 
			
		||||
right={
 | 
			
		||||
"deadzone": 0.5,
 | 
			
		||||
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":68,"key_label":0,"unicode":100,"location":0,"echo":false,"script":null)
 | 
			
		||||
]
 | 
			
		||||
}
 | 
			
		||||
shove={
 | 
			
		||||
"deadzone": 0.5,
 | 
			
		||||
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":76,"key_label":0,"unicode":108,"location":0,"echo":false,"script":null)
 | 
			
		||||
]
 | 
			
		||||
}
 | 
			
		||||
shoot={
 | 
			
		||||
"deadzone": 0.5,
 | 
			
		||||
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":77,"key_label":0,"unicode":109,"location":0,"echo":false,"script":null)
 | 
			
		||||
]
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										15
									
								
								februarygodotgame/scenes/bullet.tscn
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										15
									
								
								februarygodotgame/scenes/bullet.tscn
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,15 @@
 | 
			
		||||
[gd_scene load_steps=3 format=3 uid="uid://b1jq6yi0dh3c0"]
 | 
			
		||||
 | 
			
		||||
[ext_resource type="Script" path="res://scripts/bullet.gd" id="1_okq17"]
 | 
			
		||||
 | 
			
		||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_va0yp"]
 | 
			
		||||
size = Vector2(10, 4)
 | 
			
		||||
 | 
			
		||||
[node name="Area2D" type="Area2D"]
 | 
			
		||||
script = ExtResource("1_okq17")
 | 
			
		||||
 | 
			
		||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
 | 
			
		||||
shape = SubResource("RectangleShape2D_va0yp")
 | 
			
		||||
debug_color = Color(0.952024, 0.180224, 0.327437, 0.42)
 | 
			
		||||
 | 
			
		||||
[connection signal="body_entered" from="." to="." method="_on_body_entered"]
 | 
			
		||||
@ -1,8 +1,15 @@
 | 
			
		||||
[gd_scene load_steps=9 format=3 uid="uid://bt6uaac8wfn8k"]
 | 
			
		||||
[gd_scene load_steps=10 format=3 uid="uid://bt6uaac8wfn8k"]
 | 
			
		||||
 | 
			
		||||
[ext_resource type="Script" path="res://scripts/trigger.gd" id="1_8ewqq"]
 | 
			
		||||
[ext_resource type="Script" path="res://scripts/gamecontroller.gd" id="1_wwyby"]
 | 
			
		||||
[ext_resource type="Script" path="res://scripts/player.gd" id="2_j20wl"]
 | 
			
		||||
[ext_resource type="PackedScene" uid="uid://cjvyslsoa7olc" path="res://scenes/player.tscn" id="3_771dm"]
 | 
			
		||||
[ext_resource type="PackedScene" uid="uid://b1jq6yi0dh3c0" path="res://scenes/bullet.tscn" id="4_a2pol"]
 | 
			
		||||
[ext_resource type="Script" path="res://scripts/scene_manager.gd" id="5_xhw0f"]
 | 
			
		||||
 | 
			
		||||
[sub_resource type="WorldBoundaryShape2D" id="WorldBoundaryShape2D_gmy8j"]
 | 
			
		||||
 | 
			
		||||
[sub_resource type="CircleShape2D" id="CircleShape2D_civmy"]
 | 
			
		||||
radius = 21.0238
 | 
			
		||||
 | 
			
		||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_ggdp1"]
 | 
			
		||||
size = Vector2(72, 20)
 | 
			
		||||
@ -10,81 +17,9 @@ size = Vector2(72, 20)
 | 
			
		||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_0u5k2"]
 | 
			
		||||
size = Vector2(34, 36)
 | 
			
		||||
 | 
			
		||||
[sub_resource type="WorldBoundaryShape2D" id="WorldBoundaryShape2D_gmy8j"]
 | 
			
		||||
 | 
			
		||||
[sub_resource type="CircleShape2D" id="CircleShape2D_civmy"]
 | 
			
		||||
radius = 21.0238
 | 
			
		||||
 | 
			
		||||
[sub_resource type="CircleShape2D" id="CircleShape2D_q23dn"]
 | 
			
		||||
 | 
			
		||||
[node name="Game" type="Node2D"]
 | 
			
		||||
script = ExtResource("1_wwyby")
 | 
			
		||||
 | 
			
		||||
[node name="Brick" type="StaticBody2D" parent="."]
 | 
			
		||||
position = Vector2(598, 444)
 | 
			
		||||
metadata/_edit_group_ = true
 | 
			
		||||
 | 
			
		||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="Brick"]
 | 
			
		||||
shape = SubResource("RectangleShape2D_ggdp1")
 | 
			
		||||
 | 
			
		||||
[node name="Brick4" type="StaticBody2D" parent="."]
 | 
			
		||||
position = Vector2(802, 440)
 | 
			
		||||
metadata/_edit_group_ = true
 | 
			
		||||
 | 
			
		||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="Brick4"]
 | 
			
		||||
shape = SubResource("RectangleShape2D_ggdp1")
 | 
			
		||||
 | 
			
		||||
[node name="Brick3" type="StaticBody2D" parent="."]
 | 
			
		||||
position = Vector2(706, 421)
 | 
			
		||||
metadata/_edit_group_ = true
 | 
			
		||||
 | 
			
		||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="Brick3"]
 | 
			
		||||
shape = SubResource("RectangleShape2D_ggdp1")
 | 
			
		||||
 | 
			
		||||
[node name="Brick2" type="StaticBody2D" parent="."]
 | 
			
		||||
position = Vector2(832, 195)
 | 
			
		||||
rotation = -0.802851
 | 
			
		||||
metadata/_edit_group_ = true
 | 
			
		||||
 | 
			
		||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="Brick2"]
 | 
			
		||||
shape = SubResource("RectangleShape2D_ggdp1")
 | 
			
		||||
 | 
			
		||||
[node name="crate1" type="RigidBody2D" parent="."]
 | 
			
		||||
position = Vector2(446, 462)
 | 
			
		||||
rotation = -0.516507
 | 
			
		||||
metadata/_edit_group_ = true
 | 
			
		||||
 | 
			
		||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="crate1"]
 | 
			
		||||
shape = SubResource("RectangleShape2D_0u5k2")
 | 
			
		||||
debug_color = Color(0.868673, 0.347634, 0.15033, 0.42)
 | 
			
		||||
 | 
			
		||||
[node name="crate3" type="RigidBody2D" parent="."]
 | 
			
		||||
position = Vector2(376, 466)
 | 
			
		||||
rotation = -0.516507
 | 
			
		||||
metadata/_edit_group_ = true
 | 
			
		||||
 | 
			
		||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="crate3"]
 | 
			
		||||
shape = SubResource("RectangleShape2D_0u5k2")
 | 
			
		||||
debug_color = Color(0.868673, 0.347634, 0.15033, 0.42)
 | 
			
		||||
 | 
			
		||||
[node name="crate2" type="RigidBody2D" parent="."]
 | 
			
		||||
position = Vector2(920, 473)
 | 
			
		||||
rotation = -1.2792
 | 
			
		||||
metadata/_edit_group_ = true
 | 
			
		||||
 | 
			
		||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="crate2"]
 | 
			
		||||
shape = SubResource("RectangleShape2D_0u5k2")
 | 
			
		||||
debug_color = Color(0.868673, 0.347634, 0.15033, 0.42)
 | 
			
		||||
 | 
			
		||||
[node name="crate4" type="RigidBody2D" parent="."]
 | 
			
		||||
position = Vector2(868, 476)
 | 
			
		||||
rotation = -1.2792
 | 
			
		||||
metadata/_edit_group_ = true
 | 
			
		||||
 | 
			
		||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="crate4"]
 | 
			
		||||
shape = SubResource("RectangleShape2D_0u5k2")
 | 
			
		||||
debug_color = Color(0.868673, 0.347634, 0.15033, 0.42)
 | 
			
		||||
 | 
			
		||||
[node name="StaticBody2D" type="StaticBody2D" parent="."]
 | 
			
		||||
position = Vector2(601, 500)
 | 
			
		||||
metadata/_edit_group_ = true
 | 
			
		||||
@ -101,14 +36,86 @@ metadata/_edit_group_ = true
 | 
			
		||||
shape = SubResource("CircleShape2D_civmy")
 | 
			
		||||
debug_color = Color(0.611909, 0.392035, 0.935088, 0.42)
 | 
			
		||||
 | 
			
		||||
[node name="CharacterBody2D" type="CharacterBody2D" parent="."]
 | 
			
		||||
position = Vector2(568, 381)
 | 
			
		||||
script = ExtResource("2_j20wl")
 | 
			
		||||
[node name="level" type="Node2D" parent="."]
 | 
			
		||||
 | 
			
		||||
[node name="Brick" type="StaticBody2D" parent="level"]
 | 
			
		||||
position = Vector2(598, 444)
 | 
			
		||||
metadata/_edit_group_ = true
 | 
			
		||||
 | 
			
		||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="CharacterBody2D"]
 | 
			
		||||
shape = SubResource("CircleShape2D_q23dn")
 | 
			
		||||
debug_color = Color(0.273614, 0.618219, 0.385754, 0.42)
 | 
			
		||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="level/Brick"]
 | 
			
		||||
shape = SubResource("RectangleShape2D_ggdp1")
 | 
			
		||||
 | 
			
		||||
[node name="Brick4" type="StaticBody2D" parent="level"]
 | 
			
		||||
position = Vector2(802, 440)
 | 
			
		||||
metadata/_edit_group_ = true
 | 
			
		||||
 | 
			
		||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="level/Brick4"]
 | 
			
		||||
shape = SubResource("RectangleShape2D_ggdp1")
 | 
			
		||||
 | 
			
		||||
[node name="Brick3" type="StaticBody2D" parent="level"]
 | 
			
		||||
position = Vector2(706, 421)
 | 
			
		||||
metadata/_edit_group_ = true
 | 
			
		||||
 | 
			
		||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="level/Brick3"]
 | 
			
		||||
shape = SubResource("RectangleShape2D_ggdp1")
 | 
			
		||||
 | 
			
		||||
[node name="Brick2" type="StaticBody2D" parent="level"]
 | 
			
		||||
position = Vector2(832, 195)
 | 
			
		||||
rotation = -0.802851
 | 
			
		||||
metadata/_edit_group_ = true
 | 
			
		||||
 | 
			
		||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="level/Brick2"]
 | 
			
		||||
shape = SubResource("RectangleShape2D_ggdp1")
 | 
			
		||||
 | 
			
		||||
[node name="crates" type="Node2D" parent="."]
 | 
			
		||||
 | 
			
		||||
[node name="crate1" type="RigidBody2D" parent="crates"]
 | 
			
		||||
position = Vector2(446, 462)
 | 
			
		||||
rotation = -0.516507
 | 
			
		||||
metadata/_edit_group_ = true
 | 
			
		||||
 | 
			
		||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="crates/crate1"]
 | 
			
		||||
shape = SubResource("RectangleShape2D_0u5k2")
 | 
			
		||||
debug_color = Color(0.868673, 0.347634, 0.15033, 0.42)
 | 
			
		||||
 | 
			
		||||
[node name="crate3" type="RigidBody2D" parent="crates"]
 | 
			
		||||
position = Vector2(376, 466)
 | 
			
		||||
rotation = -0.516507
 | 
			
		||||
metadata/_edit_group_ = true
 | 
			
		||||
 | 
			
		||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="crates/crate3"]
 | 
			
		||||
shape = SubResource("RectangleShape2D_0u5k2")
 | 
			
		||||
debug_color = Color(0.868673, 0.347634, 0.15033, 0.42)
 | 
			
		||||
 | 
			
		||||
[node name="crate2" type="RigidBody2D" parent="crates"]
 | 
			
		||||
position = Vector2(920, 473)
 | 
			
		||||
rotation = -1.2792
 | 
			
		||||
scale = Vector2(1, 1)
 | 
			
		||||
metadata/_edit_group_ = true
 | 
			
		||||
 | 
			
		||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="crates/crate2"]
 | 
			
		||||
shape = SubResource("RectangleShape2D_0u5k2")
 | 
			
		||||
debug_color = Color(0.868673, 0.347634, 0.15033, 0.42)
 | 
			
		||||
 | 
			
		||||
[node name="crate4" type="RigidBody2D" parent="crates"]
 | 
			
		||||
position = Vector2(868, 476)
 | 
			
		||||
rotation = -1.2792
 | 
			
		||||
scale = Vector2(1, 1)
 | 
			
		||||
metadata/_edit_group_ = true
 | 
			
		||||
 | 
			
		||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="crates/crate4"]
 | 
			
		||||
shape = SubResource("RectangleShape2D_0u5k2")
 | 
			
		||||
debug_color = Color(0.868673, 0.347634, 0.15033, 0.42)
 | 
			
		||||
 | 
			
		||||
[node name="CharacterBody2D" parent="." instance=ExtResource("3_771dm")]
 | 
			
		||||
position = Vector2(461, 282)
 | 
			
		||||
 | 
			
		||||
[node name="Area2D" parent="." instance=ExtResource("4_a2pol")]
 | 
			
		||||
position = Vector2(284, 341)
 | 
			
		||||
 | 
			
		||||
[node name="SceneManager" type="Node" parent="."]
 | 
			
		||||
unique_name_in_owner = true
 | 
			
		||||
script = ExtResource("5_xhw0f")
 | 
			
		||||
 | 
			
		||||
[connection signal="areaTrigger" from="Trigger" to="." method="_on_trigger_area_trigger"]
 | 
			
		||||
[connection signal="body_entered" from="Trigger" to="Trigger" method="_on_body_entered"]
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										25
									
								
								februarygodotgame/scenes/player.tscn
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										25
									
								
								februarygodotgame/scenes/player.tscn
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,25 @@
 | 
			
		||||
[gd_scene load_steps=3 format=3 uid="uid://cjvyslsoa7olc"]
 | 
			
		||||
 | 
			
		||||
[ext_resource type="Script" path="res://scripts/player.gd" id="1_ffdhb"]
 | 
			
		||||
 | 
			
		||||
[sub_resource type="CircleShape2D" id="CircleShape2D_q23dn"]
 | 
			
		||||
 | 
			
		||||
[node name="CharacterBody2D" type="CharacterBody2D"]
 | 
			
		||||
script = ExtResource("1_ffdhb")
 | 
			
		||||
metadata/_edit_group_ = true
 | 
			
		||||
 | 
			
		||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
 | 
			
		||||
shape = SubResource("CircleShape2D_q23dn")
 | 
			
		||||
debug_color = Color(0.273614, 0.618219, 0.385754, 0.42)
 | 
			
		||||
 | 
			
		||||
[node name="rightCast" type="RayCast2D" parent="."]
 | 
			
		||||
target_position = Vector2(16, 0)
 | 
			
		||||
 | 
			
		||||
[node name="leftCast" type="RayCast2D" parent="."]
 | 
			
		||||
target_position = Vector2(-16, 0)
 | 
			
		||||
 | 
			
		||||
[node name="rightTarget" type="Node2D" parent="."]
 | 
			
		||||
position = Vector2(18, -15)
 | 
			
		||||
 | 
			
		||||
[node name="leftTarget" type="Node2D" parent="."]
 | 
			
		||||
position = Vector2(-19, -15)
 | 
			
		||||
							
								
								
									
										17
									
								
								februarygodotgame/scripts/bullet.gd
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										17
									
								
								februarygodotgame/scripts/bullet.gd
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,17 @@
 | 
			
		||||
class_name Bullet extends Area2D
 | 
			
		||||
 | 
			
		||||
var speed = 750
 | 
			
		||||
 | 
			
		||||
signal hit(bullet, body)
 | 
			
		||||
 | 
			
		||||
func setSpeed(value):
 | 
			
		||||
	speed = value
 | 
			
		||||
	
 | 
			
		||||
#animation
 | 
			
		||||
func _physics_process(delta: float) -> void:
 | 
			
		||||
	position += transform.x * speed * delta
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
func _on_body_entered(body: Node2D) -> void:
 | 
			
		||||
	print("bullet collision")
 | 
			
		||||
	hit.emit(self, body)
 | 
			
		||||
@ -3,6 +3,18 @@ extends CharacterBody2D
 | 
			
		||||
 | 
			
		||||
const SPEED = 300.0
 | 
			
		||||
const JUMP_VELOCITY = -400.0
 | 
			
		||||
const PUSH_FORCE = 500
 | 
			
		||||
 | 
			
		||||
var faceLeft = false
 | 
			
		||||
var pushRightEnabled = false
 | 
			
		||||
var pushLeftEnabled = false
 | 
			
		||||
var pushTarget
 | 
			
		||||
 | 
			
		||||
@onready var right_cast: RayCast2D = $rightCast
 | 
			
		||||
@onready var left_cast: RayCast2D = $leftCast
 | 
			
		||||
@onready var right_target: Node2D = $rightTarget
 | 
			
		||||
@onready var left_target: Node2D = $leftTarget
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
func _physics_process(delta: float) -> void:
 | 
			
		||||
@ -16,13 +28,50 @@ func _physics_process(delta: float) -> void:
 | 
			
		||||
 | 
			
		||||
	# Get the input direction and handle the movement/deceleration.
 | 
			
		||||
	# As good practice, you should replace UI actions with custom gameplay actions.
 | 
			
		||||
	var direction := Input.get_axis("ui_left", "ui_right")
 | 
			
		||||
	var direction := Input.get_axis("left", "right")
 | 
			
		||||
	if Input.is_action_just_pressed("shove") && pushRightEnabled && faceLeft == false:
 | 
			
		||||
		pushTarget.apply_central_impulse(Vector2(1,0) * PUSH_FORCE)
 | 
			
		||||
		pushRightEnabled = false
 | 
			
		||||
	if Input.is_action_just_pressed("shove") && pushLeftEnabled && faceLeft == true:
 | 
			
		||||
		pushTarget.apply_central_impulse(Vector2(-1,0) * PUSH_FORCE)
 | 
			
		||||
		pushLeftEnabled = false
 | 
			
		||||
	# shoot attack
 | 
			
		||||
	if Input.is_action_just_pressed("shoot"):
 | 
			
		||||
		if faceLeft == false:
 | 
			
		||||
			%SceneManager.makeBullet(right_target.global_transform, 700)
 | 
			
		||||
		if faceLeft == true:
 | 
			
		||||
			%SceneManager.makeBullet(left_target.global_transform, -700)
 | 
			
		||||
	
 | 
			
		||||
	
 | 
			
		||||
	if direction:
 | 
			
		||||
		velocity.x = direction * SPEED
 | 
			
		||||
	else:
 | 
			
		||||
		velocity.x = move_toward(velocity.x, 0, SPEED)
 | 
			
		||||
		
 | 
			
		||||
	if direction <0:
 | 
			
		||||
		faceLeft = true
 | 
			
		||||
	if direction >0:
 | 
			
		||||
		faceLeft = false
 | 
			
		||||
		
 | 
			
		||||
 | 
			
		||||
	move_and_slide()
 | 
			
		||||
	if right_cast.is_colliding():
 | 
			
		||||
		print("something on my right")
 | 
			
		||||
		var collider = right_cast.get_collider()
 | 
			
		||||
		if collider is Node:
 | 
			
		||||
			if collider is RigidBody2D:
 | 
			
		||||
				print("shove this crate")
 | 
			
		||||
				#record that we can shove right
 | 
			
		||||
				pushRightEnabled = true
 | 
			
		||||
				#record what object to shove
 | 
			
		||||
				pushTarget = collider
 | 
			
		||||
	if left_cast.is_colliding():
 | 
			
		||||
		var collider = left_cast.get_collider()
 | 
			
		||||
		if collider is Node:
 | 
			
		||||
			if collider is RigidBody2D:
 | 
			
		||||
				pushLeftEnabled = true
 | 
			
		||||
				pushTarget = collider
 | 
			
		||||
				
 | 
			
		||||
	for i in get_slide_collision_count():
 | 
			
		||||
		var c = get_slide_collision(i)
 | 
			
		||||
		if c.get_collider() is RigidBody2D:
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										32
									
								
								februarygodotgame/scripts/scene_manager.gd
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										32
									
								
								februarygodotgame/scripts/scene_manager.gd
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,32 @@
 | 
			
		||||
extends Node
 | 
			
		||||
 | 
			
		||||
var bulletsFiredTotal = 0
 | 
			
		||||
var bulletsMadeTotal = 0
 | 
			
		||||
var bulletArray= []
 | 
			
		||||
 | 
			
		||||
var bullet = preload("res://scenes/bullet.tscn")
 | 
			
		||||
 | 
			
		||||
# bullet factory - makes bullets
 | 
			
		||||
func bulletFactory():
 | 
			
		||||
	var mybullet
 | 
			
		||||
	if bulletArray.size() < 7:
 | 
			
		||||
		print("new bullet at factory")
 | 
			
		||||
		mybullet = bullet.instantiate()
 | 
			
		||||
		mybullet.connect("hit", bulletHit)
 | 
			
		||||
	else:
 | 
			
		||||
		print("recycled bullet at factory")
 | 
			
		||||
		mybullet = bulletArray.pop_back()
 | 
			
		||||
		
 | 
			
		||||
	bulletArray.push_front(mybullet)
 | 
			
		||||
	return mybullet
 | 
			
		||||
	
 | 
			
		||||
# order desk for bullets
 | 
			
		||||
func makeBullet(position, speed):
 | 
			
		||||
	print("make a bullet")
 | 
			
		||||
	var newBullet = bulletFactory()
 | 
			
		||||
	owner.add_child(newBullet)
 | 
			
		||||
	newBullet.setSpeed(speed)
 | 
			
		||||
	newBullet.transform = position
 | 
			
		||||
	
 | 
			
		||||
func bulletHit(bullet, body):
 | 
			
		||||
	print("Tell the game controller a bullet hit something")
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user