wave update

This commit is contained in:
Ultrablob 2024-04-26 16:32:56 -04:00
parent 1a2b9290c5
commit bb871371b6
13 changed files with 374 additions and 22 deletions

View file

@ -1,9 +1,11 @@
extends RichTextLabel extends RichTextLabel
@export var stopwatch: Stopwatch @export var stopwatch: Stopwatch
@export var spawner: Node2D
var config = ConfigFile.new() var config = ConfigFile.new()
var API_BASE = "https://flask-hello-world-nine-psi.vercel.app" const API_BASE = "https://flask-hello-world-nine-psi.vercel.app"
#const API_BASE = "http://localhost:5001"
func make_urlsafe(data: String): func make_urlsafe(data: String):
return data.replace("+", "-").replace("/", "_") return data.replace("+", "-").replace("/", "_")
@ -15,7 +17,7 @@ func submit_score():
var err = config.load("user://settings.cfg") var err = config.load("user://settings.cfg")
if not (err == OK and config.has_section_key("config", "username")): if not (err == OK and config.has_section_key("config", "username")):
text = "Error: No Username!\nSet a username in settings to submit scores" text = "Error: No Username!\nSet a username in settings to submit scores"
var encrypted_score = "EGH" + make_urlsafe(Marshalls.utf8_to_base64(str(stopwatch.time_elapsed))) + "eHa" + make_urlsafe(Marshalls.utf8_to_base64(config.get_value("config", "username"))) var encrypted_score = "EGH" + make_urlsafe(Marshalls.utf8_to_base64(str(stopwatch.time_elapsed))) + "eHa" + make_urlsafe(Marshalls.utf8_to_base64(config.get_value("config", "username")) + "lAx" + make_urlsafe(Marshalls.utf8_to_base64(str(spawner.wave_count-1))))
$HTTPRequest.request_completed.connect(_on_request_completed) $HTTPRequest.request_completed.connect(_on_request_completed)
$HTTPRequest.request(API_BASE + "/leaderboard?score=%s" % encrypted_score, [], HTTPClient.METHOD_POST) $HTTPRequest.request(API_BASE + "/leaderboard?score=%s" % encrypted_score, [], HTTPClient.METHOD_POST)
@ -28,10 +30,9 @@ func _on_request_completed(result, response_code, headers, body):
for score in scoredata: for score in scoredata:
scores.append(float(score[1])) scores.append(float(score[1]))
#print(scores) #print(scores)
var score = stopwatch.time_elapsed #print(scoredata)
#print(score)
var placement = float(json["position"]) var placement = float(json["position"])
#print(placement) print(placement)
if placement >= 1: if placement >= 1:
text = "[center]You placed #%d\n[/center]" % [placement] text = "[center]You placed #%d\n[/center]" % [placement]
@ -39,7 +40,10 @@ func _on_request_completed(result, response_code, headers, body):
text = "[center]You placed top %d%%\n[/center]" % [placement * 100] text = "[center]You placed top %d%%\n[/center]" % [placement * 100]
var n = 1 var n = 1
while n <= 50 and n <= len(scores): while n <= 50 and n <= len(scores):
text += "[fill]%s #%d %s[/fill]" % [ scoredata[n-1][0], n, seconds2mmss(scores[n-1]) ] #print(n)
#print(scoredata[n-1])
text += "[fill]%s #%d Wave %s %s[/fill]" % [ scoredata[n-1][0], n, scoredata[n-1][2], seconds2mmss(scores[n-1]) ]
#print([ scoredata[n-1][0], n, scoredata[n-1][2], seconds2mmss(scores[n-1]) ])
n += 1 n += 1
func closest(my_number:int, my_array:Array)->int: func closest(my_number:int, my_array:Array)->int:

View file

@ -7,7 +7,7 @@ var exagon = preload("res://exagon.tscn")
@onready var notifier = $"../Notification" @onready var notifier = $"../Notification"
var num_quares = 0 var num_quares = 0
var max_quares = 3 var max_quares = 3
var exagons = 1 var exagons = 0
var absolute_movement = false var absolute_movement = false
var config = ConfigFile.new() var config = ConfigFile.new()
@ -95,7 +95,7 @@ func aquire_exagon():
update_display() update_display()
func update_display(): func update_display():
$"../UI/Quare Count".text = "%d Quares\n%d Exagons" % [(max_quares - num_quares), exagons] $"../UI/Quare Count".text = "%d Quares\n" % [(max_quares - num_quares)]
func destroy(): func destroy():
$DeathFX.play() $DeathFX.play()

View file

@ -1,8 +1,10 @@
extends Node2D extends Node2D
@export var waves: Array[Wave] @export var waves: Array[Wave]
@export var wave_label: Label
var portal = preload("res://portal.tscn") var portal = preload("res://portal.tscn")
var enemies_previous = false var enemies_previous = false
var wave_count = 0
func _ready(): func _ready():
spawn_loop() spawn_loop()
@ -17,6 +19,8 @@ func check_enemies_loop():
func spawn_loop(): func spawn_loop():
for wave in waves: for wave in waves:
wave_count += 1
wave_label.text = "Wave %d" % wave_count
print("Starting Next Wave") print("Starting Next Wave")
for i in range(len(wave.enemies)): for i in range(len(wave.enemies)):
spawn_enemies(wave.quantities[i], wave.spawning_duration, wave.enemies[i]) spawn_enemies(wave.quantities[i], wave.spawning_duration, wave.enemies[i])
@ -26,6 +30,9 @@ func spawn_loop():
await get_tree().create_timer(wave.spawning_duration).timeout await get_tree().create_timer(wave.spawning_duration).timeout
await get_tree().create_timer(wave.wait).timeout await get_tree().create_timer(wave.wait).timeout
$"../GameOver".text = "YOU WIN!"
$"../Player".destroy()
func spawn_enemies(count: int, duration: float, enemy: WaveEnemy): func spawn_enemies(count: int, duration: float, enemy: WaveEnemy):
var delay = duration / count var delay = duration / count
for i in range(count): for i in range(count):

120
bullet-tar.tscn Normal file
View file

@ -0,0 +1,120 @@
[gd_scene load_steps=16 format=3 uid="uid://b75dkyryn0qnb"]
[ext_resource type="PackedScene" uid="uid://c6ybtahxwpukd" path="res://bullet.tscn" id="1_kjw43"]
[ext_resource type="Texture2D" uid="uid://foqvx0qb0gic" path="res://tar_bullet.png" id="2_cgmk6"]
[sub_resource type="AtlasTexture" id="AtlasTexture_ykf7j"]
atlas = ExtResource("2_cgmk6")
region = Rect2(0, 0, 64, 64)
[sub_resource type="AtlasTexture" id="AtlasTexture_kjnwa"]
atlas = ExtResource("2_cgmk6")
region = Rect2(64, 0, 64, 64)
[sub_resource type="AtlasTexture" id="AtlasTexture_jus8a"]
atlas = ExtResource("2_cgmk6")
region = Rect2(128, 0, 64, 64)
[sub_resource type="AtlasTexture" id="AtlasTexture_rxw5c"]
atlas = ExtResource("2_cgmk6")
region = Rect2(192, 0, 64, 64)
[sub_resource type="AtlasTexture" id="AtlasTexture_angk7"]
atlas = ExtResource("2_cgmk6")
region = Rect2(256, 0, 64, 64)
[sub_resource type="AtlasTexture" id="AtlasTexture_j4ckd"]
atlas = ExtResource("2_cgmk6")
region = Rect2(320, 0, 64, 64)
[sub_resource type="AtlasTexture" id="AtlasTexture_5rrvv"]
atlas = ExtResource("2_cgmk6")
region = Rect2(384, 0, 64, 64)
[sub_resource type="AtlasTexture" id="AtlasTexture_j3w1s"]
atlas = ExtResource("2_cgmk6")
region = Rect2(448, 0, 64, 64)
[sub_resource type="AtlasTexture" id="AtlasTexture_nrj3w"]
atlas = ExtResource("2_cgmk6")
region = Rect2(512, 0, 64, 64)
[sub_resource type="AtlasTexture" id="AtlasTexture_dwrya"]
atlas = ExtResource("2_cgmk6")
region = Rect2(576, 0, 64, 64)
[sub_resource type="AtlasTexture" id="AtlasTexture_1ebs7"]
atlas = ExtResource("2_cgmk6")
region = Rect2(640, 0, 64, 64)
[sub_resource type="SpriteFrames" id="SpriteFrames_78fjs"]
animations = [{
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_ykf7j")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_ykf7j")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_ykf7j")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_ykf7j")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_kjnwa")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_jus8a")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_rxw5c")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_angk7")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_j4ckd")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_5rrvv")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_j3w1s")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_nrj3w")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_dwrya")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_1ebs7")
}],
"loop": true,
"name": &"default",
"speed": 10.0
}]
[sub_resource type="CircleShape2D" id="CircleShape2D_q18vg"]
radius = 45.0
[node name="Bullet" instance=ExtResource("1_kjw43")]
linear_damp = 1.0
[node name="Sprite2D" parent="." index="1"]
position = Vector2(2, 2)
scale = Vector2(2, 2)
sprite_frames = SubResource("SpriteFrames_78fjs")
animation = &"default"
autoplay = ""
offset = Vector2(-0.854763, 1.21806)
[node name="Explosion" type="Area2D" parent="." index="2"]
rotation = -1.5708
[node name="CollisionShape2D" type="CollisionShape2D" parent="Explosion" index="0"]
shape = SubResource("CircleShape2D_q18vg")
[connection signal="animation_looped" from="Sprite2D" to="." method="explode"]

View file

@ -1,9 +1,20 @@
extends RigidBody2D extends RigidBody2D
var bounces = 0 var bounces = 0
@onready var player = $"../Player"
func _process(delta): func _physics_process(delta):
$Sprite2D.global_rotation = linear_velocity.angle() + deg_to_rad(90) apply_central_force((global_position - player.global_position).normalized() * -50)
if linear_velocity.length() < 10:
$Sprite2D.play("default")
if player in $Explosion.get_overlapping_bodies():
$Sprite2D.play("default")
func explode():
for item in $Explosion.get_overlapping_bodies():
hit(item)
queue_free()
func hit(body): func hit(body):
if body.is_in_group("destructible"): if body.is_in_group("destructible"):

File diff suppressed because one or more lines are too long

141
riangle-tar.tscn Normal file
View file

@ -0,0 +1,141 @@
[gd_scene load_steps=18 format=3 uid="uid://mlb0a8hdbtqw"]
[ext_resource type="Script" path="res://riangle.gd" id="1_eh3cx"]
[ext_resource type="Texture2D" uid="uid://c562ut0sxn6we" path="res://riangle-tar.png" id="2_1actw"]
[ext_resource type="Script" path="res://Gun.gd" id="3_5oxo6"]
[ext_resource type="PackedScene" uid="uid://b75dkyryn0qnb" path="res://bullet-tar.tscn" id="4_t8bmd"]
[sub_resource type="AtlasTexture" id="AtlasTexture_fr0hq"]
atlas = ExtResource("2_1actw")
region = Rect2(0, 0, 64, 64)
[sub_resource type="AtlasTexture" id="AtlasTexture_ndbtj"]
atlas = ExtResource("2_1actw")
region = Rect2(64, 0, 64, 64)
[sub_resource type="AtlasTexture" id="AtlasTexture_46les"]
atlas = ExtResource("2_1actw")
region = Rect2(128, 0, 64, 64)
[sub_resource type="AtlasTexture" id="AtlasTexture_8g8fq"]
atlas = ExtResource("2_1actw")
region = Rect2(192, 0, 64, 64)
[sub_resource type="AtlasTexture" id="AtlasTexture_u4hko"]
atlas = ExtResource("2_1actw")
region = Rect2(256, 0, 64, 64)
[sub_resource type="AtlasTexture" id="AtlasTexture_6m3wq"]
atlas = ExtResource("2_1actw")
region = Rect2(320, 0, 64, 64)
[sub_resource type="AtlasTexture" id="AtlasTexture_n2fc5"]
atlas = ExtResource("2_1actw")
region = Rect2(384, 0, 64, 64)
[sub_resource type="AtlasTexture" id="AtlasTexture_jeriy"]
atlas = ExtResource("2_1actw")
region = Rect2(448, 0, 64, 64)
[sub_resource type="AtlasTexture" id="AtlasTexture_phsui"]
atlas = ExtResource("2_1actw")
region = Rect2(512, 0, 64, 64)
[sub_resource type="AtlasTexture" id="AtlasTexture_n314x"]
atlas = ExtResource("2_1actw")
region = Rect2(576, 0, 64, 64)
[sub_resource type="AtlasTexture" id="AtlasTexture_xm4pv"]
atlas = ExtResource("2_1actw")
region = Rect2(640, 0, 64, 64)
[sub_resource type="AtlasTexture" id="AtlasTexture_cojx6"]
atlas = ExtResource("2_1actw")
region = Rect2(704, 0, 64, 64)
[sub_resource type="SpriteFrames" id="SpriteFrames_xlxob"]
animations = [{
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_fr0hq")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_ndbtj")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_46les")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_8g8fq")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_u4hko")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_6m3wq")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_n2fc5")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_jeriy")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_phsui")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_n314x")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_xm4pv")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_cojx6")
}],
"loop": true,
"name": &"default",
"speed": 5.0
}]
[node name="Riangle" type="CharacterBody2D" groups=["destructible", "enemy"]]
scale = Vector2(0.25, 0.25)
script = ExtResource("1_eh3cx")
[node name="Sprite2D" type="AnimatedSprite2D" parent="."]
texture_filter = 1
position = Vector2(-29.5874, 1.58741)
rotation = 1.5708
scale = Vector2(3.61152, 3.61152)
sprite_frames = SubResource("SpriteFrames_xlxob")
autoplay = "default"
speed_scale = 2.0
[node name="Gun2" type="Marker2D" parent="."]
position = Vector2(-224, 284)
rotation = 2.0944
script = ExtResource("3_5oxo6")
bullet = ExtResource("4_t8bmd")
[node name="Gun3" type="Marker2D" parent="."]
position = Vector2(-224, -284)
rotation = -2.0944
scale = Vector2(1, 1)
script = ExtResource("3_5oxo6")
bullet = ExtResource("4_t8bmd")
[node name="Gun" type="Marker2D" parent="."]
position = Vector2(272, 0)
script = ExtResource("3_5oxo6")
bullet = ExtResource("4_t8bmd")
[node name="Timer" type="Timer" parent="."]
autostart = true
[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="."]
position = Vector2(-8, 0)
polygon = PackedVector2Array(-80, -104, 100, 0, -80, 104)
[connection signal="timeout" from="Timer" to="Gun2" method="shoot"]
[connection signal="timeout" from="Timer" to="Gun3" method="shoot"]
[connection signal="timeout" from="Timer" to="Gun" method="shoot"]
[connection signal="timeout" from="Timer" to="." method="destroy"]

View file

@ -1,4 +1,4 @@
extends StaticBody2D extends PhysicsBody2D
func destroy(): func destroy():
var explosion = load("res://explosion.tscn").instantiate() var explosion = load("res://explosion.tscn").instantiate()

View file

@ -1,6 +1,6 @@
extends Node2D extends Node2D
var riangle = preload("res://riangle.tscn") var riangle = preload("res://riangle-tar.tscn")
func spawn(): func spawn():
process_mode = Node.PROCESS_MODE_DISABLED process_mode = Node.PROCESS_MODE_DISABLED
@ -12,16 +12,17 @@ func spawn():
zone.add_child(node) zone.add_child(node)
node.global_rotation = zone.global_rotation node.global_rotation = zone.global_rotation
node.global_position = global_position node.global_position = global_position
tween.tween_property(node, "position", Vector2.ZERO, 1) tween.tween_property(node, "position", Vector2.ZERO, 0.5)
func eject(): func eject():
var tween = get_tree().create_tween().set_ease(Tween.EASE_IN_OUT).set_trans(Tween.TRANS_SINE) var tween = get_tree().create_tween().set_ease(Tween.EASE_IN_OUT).set_trans(Tween.TRANS_SINE)
for spawner in get_children(): for spawner in get_children():
var riangle = spawner.get_child(0) var riangle = spawner.get_child(0)
tween.tween_property(riangle, "position", Vector2(200, 0), 1) tween.tween_property(riangle, "position", Vector2(randi_range(200, 400), 0), 0.5)
tween.tween_property(spawner, "process_mode", PROCESS_MODE_PAUSABLE, 0) tween.tween_property(spawner, "process_mode", PROCESS_MODE_PAUSABLE, 0.1)
await tween.finished await tween.finished
await get_tree().create_timer(1).timeout
for spawner in get_children(): for spawner in get_children():
spawner.process_mode = Node.PROCESS_MODE_INHERIT spawner.process_mode = Node.PROCESS_MODE_INHERIT

4
tar.gd
View file

@ -1,5 +1,9 @@
extends Node2D extends Node2D
func _ready():
await get_tree().create_timer(1).timeout
phase()
func phase(): func phase():
$Sprite.play("spawn") $Sprite.play("spawn")
$"Riangle Zone".spawn() $"Riangle Zone".spawn()

View file

@ -172,7 +172,7 @@ position = Vector2(-37, -45)
rotation = 4.08407 rotation = 4.08407
[node name="Timer" type="Timer" parent="."] [node name="Timer" type="Timer" parent="."]
wait_time = 5.0 wait_time = 6.0
autostart = true autostart = true
[connection signal="timeout" from="Timer" to="." method="phase"] [connection signal="timeout" from="Timer" to="." method="phase"]

BIN
tar_bullet.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.1 KiB

34
tar_bullet.png.import Normal file
View file

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://foqvx0qb0gic"
path="res://.godot/imported/tar_bullet.png-08e640e18ab53943b06cc5af1c289c51.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://tar_bullet.png"
dest_files=["res://.godot/imported/tar_bullet.png-08e640e18ab53943b06cc5af1c289c51.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1