first Prototype
This commit is contained in:
parent
89503407e7
commit
c887a2168c
78 changed files with 2494 additions and 2 deletions
18
scenes/obstacle/meteor/meteor.gd
Normal file
18
scenes/obstacle/meteor/meteor.gd
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
class_name Meteor extends "res://scenes/obstacle/obstacle.gd"
|
||||
|
||||
@export var minSpeed: int = 100
|
||||
@export var maxSpeed: int = 1000
|
||||
|
||||
var speed: int = 1000
|
||||
var direction: int
|
||||
|
||||
func _init() -> void:
|
||||
var rng = RandomNumberGenerator.new()
|
||||
direction = rng.randi_range(0, 360)
|
||||
speed = rng.randi_range(minSpeed, maxSpeed)
|
||||
rotation = direction
|
||||
|
||||
|
||||
func _physics_process(delta: float) -> void:
|
||||
velocity = Vector2.UP.rotated(direction).normalized() * speed
|
||||
move_and_slide()
|
||||
1
scenes/obstacle/meteor/meteor.gd.uid
Normal file
1
scenes/obstacle/meteor/meteor.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://b82cnxsh4mn0f
|
||||
36
scenes/obstacle/meteor/meteor.tscn
Normal file
36
scenes/obstacle/meteor/meteor.tscn
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
[gd_scene load_steps=7 format=3 uid="uid://vl8duuwwrpqm"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://cgqo1nxq6xprm" path="res://scenes/obstacle/obstacle.tscn" id="1_skd46"]
|
||||
[ext_resource type="Script" uid="uid://b82cnxsh4mn0f" path="res://scenes/obstacle/meteor/meteor.gd" id="2_8c34n"]
|
||||
[ext_resource type="Texture2D" uid="uid://cfwyw1sr6x2np" path="res://icon.svg" id="3_jb48p"]
|
||||
|
||||
[sub_resource type="CircleShape2D" id="CircleShape2D_8c34n"]
|
||||
radius = 56.0
|
||||
|
||||
[sub_resource type="CircleShape2D" id="CircleShape2D_jb48p"]
|
||||
radius = 64.0
|
||||
|
||||
[sub_resource type="CircleShape2D" id="CircleShape2D_pganv"]
|
||||
radius = 64.0
|
||||
|
||||
[node name="Meteor" instance=ExtResource("1_skd46")]
|
||||
modulate = Color(1, 0, 0, 1)
|
||||
script = ExtResource("2_8c34n")
|
||||
minSpeed = 100
|
||||
maxSpeed = 1000
|
||||
health = 10
|
||||
|
||||
[node name="CollisionShape2D" parent="." index="0"]
|
||||
shape = SubResource("CircleShape2D_8c34n")
|
||||
|
||||
[node name="CollisionShape2D" parent="DamageArea" index="0"]
|
||||
shape = SubResource("CircleShape2D_jb48p")
|
||||
|
||||
[node name="CollisionShape2D" parent="hurtArea" index="0"]
|
||||
shape = SubResource("CircleShape2D_pganv")
|
||||
|
||||
[node name="Sprite2D" parent="." index="3"]
|
||||
texture = ExtResource("3_jb48p")
|
||||
|
||||
[editable path="DamageArea"]
|
||||
[editable path="hurtArea"]
|
||||
31
scenes/obstacle/obstacle.gd
Normal file
31
scenes/obstacle/obstacle.gd
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
class_name Obstacle extends CharacterBody2D
|
||||
|
||||
@onready var sprite = $Sprite2D
|
||||
@onready var lifeTimeTimer = $lifeTimeTimer
|
||||
|
||||
@export var damage: int = 10
|
||||
@export var health: int = 1
|
||||
@export var minHealth: int = 1
|
||||
@export var maxHealth: int = 1
|
||||
@export var lifeTime: int = 600
|
||||
|
||||
func _ready() -> void:
|
||||
lifeTimeTimer.start(lifeTime)
|
||||
health += damage
|
||||
|
||||
func spawn(damage: int):
|
||||
pass
|
||||
|
||||
|
||||
func _on_hurt_area_hurt(amount: int) -> void:
|
||||
hurt(amount)
|
||||
|
||||
func hurt(amount: int):
|
||||
if health - amount <= minHealth:
|
||||
queue_free()
|
||||
else:
|
||||
health -= amount
|
||||
|
||||
|
||||
func _on_life_time_timer_timeout() -> void:
|
||||
queue_free()
|
||||
1
scenes/obstacle/obstacle.gd.uid
Normal file
1
scenes/obstacle/obstacle.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://iu7hvfpevs65
|
||||
27
scenes/obstacle/obstacle.tscn
Normal file
27
scenes/obstacle/obstacle.tscn
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
[gd_scene load_steps=4 format=3 uid="uid://cgqo1nxq6xprm"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://eqo7k2ronf8k" path="res://scenes/areas/damageArea/damageArea.tscn" id="1_1ys07"]
|
||||
[ext_resource type="Script" uid="uid://iu7hvfpevs65" path="res://scenes/obstacle/obstacle.gd" id="1_osovj"]
|
||||
[ext_resource type="PackedScene" uid="uid://cglnd1ekr5u6r" path="res://scenes/areas/hurtArea/hurtArea.tscn" id="2_osovj"]
|
||||
|
||||
[node name="Obstacle" type="CharacterBody2D" groups=["obstacle"]]
|
||||
collision_layer = 2
|
||||
collision_mask = 46
|
||||
script = ExtResource("1_osovj")
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||
|
||||
[node name="DamageArea" parent="." instance=ExtResource("1_1ys07")]
|
||||
|
||||
[node name="hurtArea" parent="." instance=ExtResource("2_osovj")]
|
||||
|
||||
[node name="Sprite2D" type="Sprite2D" parent="."]
|
||||
|
||||
[node name="lifeTimeTimer" type="Timer" parent="."]
|
||||
one_shot = true
|
||||
|
||||
[connection signal="hurt" from="hurtArea" to="." method="_on_hurt_area_hurt"]
|
||||
[connection signal="timeout" from="lifeTimeTimer" to="." method="_on_life_time_timer_timeout"]
|
||||
|
||||
[editable path="DamageArea"]
|
||||
[editable path="hurtArea"]
|
||||
Loading…
Add table
Add a link
Reference in a new issue