Merge pull request 'Projectile Weapon' (#6) from player_weapon into main
Reviewed-on: #6
This commit was merged in pull request #6.
This commit is contained in:
commit
25eabd1364
14 files changed
+165
-62
No files matched your search
@@ -0,0 +1,6 @@
|
||||
extends Node
|
||||
|
||||
|
||||
@onready var test_level = $"../test_scene"
|
||||
@onready var projectile = $"../projectile"
|
||||
var death_counter = 3
|
||||
@@ -0,0 +1 @@
|
||||
uid://chv42jjv2lka4
|
||||
@@ -0,0 +1,17 @@
|
||||
extends Area2D
|
||||
|
||||
|
||||
var spawnpos: Vector2
|
||||
var direction = 0
|
||||
var speed = Vector2(1000, 0)
|
||||
var origin = Vector2(0, 0)
|
||||
const distance = 500
|
||||
|
||||
|
||||
|
||||
func _physics_process(delta: float) -> void:
|
||||
position += speed * delta
|
||||
origin += speed * delta
|
||||
|
||||
if abs(origin.x) >= distance:
|
||||
queue_free()
|
||||
@@ -0,0 +1 @@
|
||||
uid://7hy57dacf4nh
|
||||
@@ -15,6 +15,10 @@ run/main_scene="uid://btktv5aqpafau"
|
||||
config/features=PackedStringArray("4.7", "Forward Plus")
|
||||
config/icon="res://icon.svg"
|
||||
|
||||
[autoload]
|
||||
|
||||
GloblaData="*uid://chv42jjv2lka4"
|
||||
|
||||
[display]
|
||||
|
||||
window/stretch/mode="canvas_items"
|
||||
@@ -76,6 +80,11 @@ run={
|
||||
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":16,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":69,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null)
|
||||
]
|
||||
}
|
||||
fire={
|
||||
"deadzone": 0.2,
|
||||
"events": [Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"button_mask":1,"position":Vector2(150, 14),"global_position":Vector2(159, 62),"factor":1.0,"button_index":1,"canceled":false,"pressed":true,"double_click":false,"script":null)
|
||||
]
|
||||
}
|
||||
|
||||
[physics]
|
||||
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
extends CharacterBody2D
|
||||
|
||||
|
||||
var SPEED = Vector2(5, 0)
|
||||
const JUMP_VELOCITY = -400.0
|
||||
@onready var projectile: PackedScene = preload("res://scenes/projectile.tscn")
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
|
||||
$Timer.start()
|
||||
|
||||
|
||||
func _physics_process(delta: float) -> void:
|
||||
velocity += get_gravity() * delta
|
||||
move_and_slide()
|
||||
patrol()
|
||||
|
||||
|
||||
func patrol():
|
||||
position += SPEED
|
||||
|
||||
|
||||
func _on_timer_timeout() -> void:
|
||||
SPEED = -SPEED
|
||||
$Timer.start()
|
||||
|
||||
|
||||
func _on_area_2d_area_entered(area: Area2D) -> void:
|
||||
queue_free()
|
||||
|
||||
|
||||
func _on_area_2d_body_entered(body: Node2D) -> void:
|
||||
GloblaData.death_counter -= 1
|
||||
@@ -0,0 +1 @@
|
||||
uid://su208qu0ehcs
|
||||
+7
-3
@@ -1,6 +1,6 @@
|
||||
[gd_scene format=3 uid="uid://bjk1cmuogswyd"]
|
||||
[gd_scene format=3 uid="uid://dxx6mxv6x5yws"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://2jmspsmp5wpm" path="res://scripts/enemy.gd" id="1_7p1mj"]
|
||||
[ext_resource type="Script" uid="uid://su208qu0ehcs" path="res://scenes/enemy.gd" id="1_7p1mj"]
|
||||
|
||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_aqe1g"]
|
||||
size = Vector2(168, 167)
|
||||
@@ -10,7 +10,7 @@ size = Vector2(178, 168)
|
||||
|
||||
[node name="enemy" type="CharacterBody2D" unique_id=1471932521]
|
||||
collision_layer = 4
|
||||
collision_mask = 3
|
||||
collision_mask = 11
|
||||
script = ExtResource("1_7p1mj")
|
||||
|
||||
[node name="ColorRect" type="ColorRect" parent="." unique_id=519837051]
|
||||
@@ -24,9 +24,13 @@ shape = SubResource("RectangleShape2D_aqe1g")
|
||||
[node name="Timer" type="Timer" parent="." unique_id=356300230]
|
||||
|
||||
[node name="Area2D" type="Area2D" parent="." unique_id=461696644]
|
||||
collision_layer = 4
|
||||
collision_mask = 11
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="Area2D" unique_id=72940614]
|
||||
position = Vector2(84, 79)
|
||||
shape = SubResource("RectangleShape2D_yg5ta")
|
||||
|
||||
[connection signal="timeout" from="Timer" to="." method="_on_timer_timeout"]
|
||||
[connection signal="area_entered" from="Area2D" to="." method="_on_area_2d_area_entered"]
|
||||
[connection signal="body_entered" from="Area2D" to="." method="_on_area_2d_body_entered"]
|
||||
+22
-40
@@ -5,16 +5,13 @@
|
||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_d2by0"]
|
||||
size = Vector2(111, 105)
|
||||
|
||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_aqe1g"]
|
||||
size = Vector2(114.5, 109)
|
||||
|
||||
[node name="player" type="CharacterBody2D" unique_id=1596338883]
|
||||
collision_mask = 6
|
||||
script = ExtResource("1_3vyb7")
|
||||
|
||||
[node name="ColorRect" type="ColorRect" parent="." unique_id=42689460]
|
||||
[node name="ColorRect" type="ColorRect" parent="." unique_id=1060028972]
|
||||
offset_right = 111.0
|
||||
offset_bottom = 105.0
|
||||
offset_bottom = 104.0
|
||||
|
||||
[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="." unique_id=440932344]
|
||||
|
||||
@@ -22,41 +19,26 @@ offset_bottom = 105.0
|
||||
position = Vector2(55.5, 52.5)
|
||||
shape = SubResource("RectangleShape2D_d2by0")
|
||||
|
||||
[node name="Area2D" type="Area2D" parent="." unique_id=680224441]
|
||||
collision_mask = 4
|
||||
[node name="ColorRect2" type="ColorRect" parent="." unique_id=1595777933]
|
||||
offset_left = 2.0
|
||||
offset_top = -33.0
|
||||
offset_right = 28.0
|
||||
offset_bottom = -8.0
|
||||
color = Color(1, 0, 0, 1)
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="Area2D" unique_id=736937610]
|
||||
position = Vector2(55.25, 52.5)
|
||||
shape = SubResource("RectangleShape2D_aqe1g")
|
||||
[node name="ColorRect3" type="ColorRect" parent="." unique_id=261143567]
|
||||
offset_left = 82.0
|
||||
offset_top = -33.0
|
||||
offset_right = 108.0
|
||||
offset_bottom = -8.0
|
||||
color = Color(1, 0, 0, 1)
|
||||
|
||||
[node name="health" type="Control" parent="." unique_id=1976293596]
|
||||
layout_mode = 3
|
||||
anchors_preset = 0
|
||||
offset_right = 40.0
|
||||
offset_bottom = 40.0
|
||||
[node name="ColorRect4" type="ColorRect" parent="." unique_id=1858187239]
|
||||
offset_left = 42.0
|
||||
offset_top = -33.0
|
||||
offset_right = 68.0
|
||||
offset_bottom = -8.0
|
||||
color = Color(1, 0, 0, 1)
|
||||
|
||||
[node name="ColorRect" type="ColorRect" parent="health" unique_id=110340136]
|
||||
self_modulate = Color(1, 0, 0, 1)
|
||||
layout_mode = 0
|
||||
offset_left = 3.0
|
||||
offset_top = -42.0
|
||||
offset_right = 26.0
|
||||
offset_bottom = -20.0
|
||||
|
||||
[node name="ColorRect2" type="ColorRect" parent="health" unique_id=1043497392]
|
||||
self_modulate = Color(1, 0, 0, 1)
|
||||
layout_mode = 0
|
||||
offset_left = 37.0
|
||||
offset_top = -42.0
|
||||
offset_right = 60.0
|
||||
offset_bottom = -20.0
|
||||
|
||||
[node name="ColorRect3" type="ColorRect" parent="health" unique_id=175994440]
|
||||
self_modulate = Color(1, 0, 0, 1)
|
||||
layout_mode = 0
|
||||
offset_left = 70.0
|
||||
offset_top = -42.0
|
||||
offset_right = 93.0
|
||||
offset_bottom = -20.0
|
||||
|
||||
[connection signal="body_entered" from="Area2D" to="." method="_on_area_2d_body_entered"]
|
||||
[node name="Marker2D" type="Marker2D" parent="." unique_id=1559032825]
|
||||
position = Vector2(112, 38)
|
||||
@@ -0,0 +1,21 @@
|
||||
[gd_scene format=3 uid="uid://baiayu1xn68g0"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://7hy57dacf4nh" path="res://projecile.gd" id="1_c8fcr"]
|
||||
|
||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_aqe1g"]
|
||||
size = Vector2(44, 44)
|
||||
|
||||
[node name="projectile" type="Area2D" unique_id=478503233]
|
||||
collision_layer = 8
|
||||
collision_mask = 4
|
||||
script = ExtResource("1_c8fcr")
|
||||
|
||||
[node name="ColorRect" type="ColorRect" parent="." unique_id=1569566086]
|
||||
self_modulate = Color(0, 0, 0, 1)
|
||||
offset_top = -1.0
|
||||
offset_right = 40.0
|
||||
offset_bottom = 39.0
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="." unique_id=1408698135]
|
||||
position = Vector2(20, 19)
|
||||
shape = SubResource("RectangleShape2D_aqe1g")
|
||||
@@ -1,12 +1,14 @@
|
||||
[gd_scene format=3 uid="uid://d1xirc54wud0s"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://cmtdq6tedv1mm" path="res://scenes/player.tscn" id="1_g7g4h"]
|
||||
[ext_resource type="PackedScene" uid="uid://bjk1cmuogswyd" path="res://scenes/enemy.tscn" id="2_j8ivh"]
|
||||
[ext_resource type="Script" uid="uid://v7bcqfwryutg" path="res://scripts/test_scene.gd" id="1_j8ivh"]
|
||||
[ext_resource type="PackedScene" uid="uid://dxx6mxv6x5yws" path="res://scenes/enemy.tscn" id="2_j8ivh"]
|
||||
|
||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_aqe1g"]
|
||||
size = Vector2(1116.25, 73)
|
||||
|
||||
[node name="test_scene" type="Node2D" unique_id=1970054744]
|
||||
script = ExtResource("1_j8ivh")
|
||||
|
||||
[node name="ColorRect" type="ColorRect" parent="." unique_id=1255479846]
|
||||
offset_left = 2.0
|
||||
@@ -17,12 +19,13 @@ offset_bottom = 606.0
|
||||
[node name="player" parent="." unique_id=1596338883 instance=ExtResource("1_g7g4h")]
|
||||
position = Vector2(64, 386)
|
||||
|
||||
[node name="floor" type="StaticBody2D" parent="." unique_id=866269158]
|
||||
[node name="floor" type="StaticBody2D" parent="." unique_id=306980091]
|
||||
collision_layer = 2
|
||||
collision_mask = 5
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="floor" unique_id=1146724072]
|
||||
position = Vector2(561.125, 569)
|
||||
shape = SubResource("RectangleShape2D_aqe1g")
|
||||
|
||||
[node name="enemy" parent="floor" unique_id=1471932521 instance=ExtResource("2_j8ivh")]
|
||||
position = Vector2(527, 311)
|
||||
[node name="enemy" parent="." unique_id=1471932521 instance=ExtResource("2_j8ivh")]
|
||||
position = Vector2(695, 334)
|
||||
@@ -25,7 +25,7 @@ class_name PlatformerController2D
|
||||
@export var directionalSnap: bool = false
|
||||
##If enabled, the default movement speed will by 1/2 of the maxSpeed and the player must hold a "run" button to accelerate to max speed. Assign "run" (case sensitive) in the project input settings.
|
||||
@export var runningModifier: bool = false
|
||||
|
||||
var direction = 0
|
||||
#INFO JUMPING
|
||||
@export_category("Jumping and Gravity")
|
||||
##The peak height of your player's jump
|
||||
@@ -115,7 +115,7 @@ class_name PlatformerController2D
|
||||
@export var crouch_walk: bool
|
||||
##Animations must be named "roll" all lowercase as the check box says
|
||||
@export var roll: bool
|
||||
|
||||
var projectile = preload("res://scenes/projectile.tscn")
|
||||
|
||||
|
||||
#Variables determined by the developer set ones.
|
||||
@@ -138,7 +138,7 @@ var gravityActive: bool = true
|
||||
var dashing: bool = false
|
||||
var dashCount: int
|
||||
var rolling: bool = false
|
||||
var death_counter = 3
|
||||
|
||||
var twoWayDashHorizontal
|
||||
var twoWayDashVertical
|
||||
var eightWayDash
|
||||
@@ -158,7 +158,7 @@ var latched
|
||||
var wasLatched
|
||||
var crouching
|
||||
var groundPounding
|
||||
|
||||
var death_counter = 3
|
||||
var anim = PlayerSprite
|
||||
var col
|
||||
var animScaleLock : Vector2
|
||||
@@ -180,7 +180,7 @@ var dashTap
|
||||
var rollTap
|
||||
var downTap
|
||||
var twirlTap
|
||||
|
||||
var enemy = preload("res://scenes/enemy.tscn")
|
||||
func _ready():
|
||||
wasMovingR = true
|
||||
anim = PlayerSprite
|
||||
@@ -254,8 +254,6 @@ func _updateData():
|
||||
func _process(_delta):
|
||||
#INFO animations
|
||||
#directions
|
||||
if death_counter == 0:
|
||||
get_tree().quit()
|
||||
if is_on_wall() and !is_on_floor() and latch and wallLatching and ((wallLatchingModifer and latchHold) or !wallLatchingModifer):
|
||||
latched = true
|
||||
else:
|
||||
@@ -323,14 +321,25 @@ func _process(_delta):
|
||||
anim.speed_scale = 1
|
||||
anim.play("roll")
|
||||
|
||||
|
||||
|
||||
var dir: bool = 1
|
||||
|
||||
func _physics_process(delta):
|
||||
if death_counter == 2:
|
||||
$health/ColorRect3.hide()
|
||||
elif death_counter == 1:
|
||||
$health/ColorRect2.hide()
|
||||
if Input.is_action_pressed("right"):
|
||||
dir = 1
|
||||
if Input.is_action_pressed("left"):
|
||||
dir = 0
|
||||
if Input.is_action_just_pressed("fire"):
|
||||
var instance = projectile.instantiate()
|
||||
if !dir:
|
||||
instance.speed = -instance.speed
|
||||
instance.position = $Marker2D.global_position
|
||||
GloblaData.test_level.add_child(instance)
|
||||
if GloblaData.death_counter == 0:
|
||||
get_tree().quit()
|
||||
if GloblaData.death_counter == 2:
|
||||
$ColorRect3.hide()
|
||||
elif GloblaData.death_counter == 1:
|
||||
$ColorRect4.hide()
|
||||
if !dset:
|
||||
gdelta = delta
|
||||
dset = true
|
||||
@@ -682,5 +691,5 @@ func _placeHolder():
|
||||
print("")
|
||||
|
||||
|
||||
func _on_area_2d_body_entered(body: Node2D) -> void:
|
||||
death_counter -= 1
|
||||
func shoot():
|
||||
pass
|
||||
@@ -0,0 +1,11 @@
|
||||
extends Node2D
|
||||
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready() -> void:
|
||||
pass # Replace with function body.
|
||||
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(delta: float) -> void:
|
||||
pass
|
||||
@@ -0,0 +1 @@
|
||||
uid://v7bcqfwryutg
|
||||
Reference in new issue
Block a user