mirror of
https://codeberg.org/Melon-Bread/Comets.gd.git
synced 2024-11-24 21:18:21 -05:00
Added Comet sizes
This commit is contained in:
parent
09c63cd432
commit
fb60dfce61
@ -6,8 +6,9 @@
|
|||||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_5nukh"]
|
[sub_resource type="RectangleShape2D" id="RectangleShape2D_5nukh"]
|
||||||
size = Vector2(4, 16)
|
size = Vector2(4, 16)
|
||||||
|
|
||||||
[node name="Bullet" type="Area2D" groups=["projectile"]]
|
[node name="Bullet" type="Area2D" groups=["bullet"]]
|
||||||
position = Vector2(0, -8)
|
position = Vector2(0, -8)
|
||||||
|
collision_layer = 2
|
||||||
collision_mask = 2
|
collision_mask = 2
|
||||||
script = ExtResource("1_jyq7a")
|
script = ExtResource("1_jyq7a")
|
||||||
|
|
||||||
|
@ -1,24 +1,48 @@
|
|||||||
extends Area2D
|
extends Area2D
|
||||||
|
|
||||||
# TODO: Have a list of "sizes" a comet can be
|
|
||||||
# TODO: Have speeds be determined on a rage based on its "size"
|
# TODO: Have speeds be determined on a rage based on its "size"
|
||||||
# TODO: Provide a specific score based on the "size"
|
# TODO: Provide a specific score based on the "size"
|
||||||
# TODO: Have the comet spawn 2 of the next "size" when hit
|
# TODO: Have the comet spawn 2 of the next "size" when hit
|
||||||
# TODO: Have the comet disapear if shot at is smallest "size"
|
# TODO: Have the comet disapear if shot at is smallest "size"
|
||||||
|
|
||||||
@export var movement_speed := 600
|
|
||||||
|
enum SIZE {SMALL, MEDIUM, LARGE}
|
||||||
|
|
||||||
|
@export var current_size : SIZE = SIZE.LARGE
|
||||||
|
|
||||||
|
var size_data = {
|
||||||
|
SIZE.SMALL : {"Scale": 0.5, "Speed-Multi": 1.5},
|
||||||
|
SIZE.MEDIUM : {"Scale": 1.0, "Speed-Multi": 1.0},
|
||||||
|
SIZE.LARGE : {"Scale": 2.5, "Speed-Multi": 0.5}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
var movement_speed : int
|
||||||
|
var movement_speed_min : int = 100
|
||||||
|
var movement_speed_max : int = 500
|
||||||
|
var movement_direciton := Vector2.UP
|
||||||
|
|
||||||
var rotation_speed : int
|
var rotation_speed : int
|
||||||
var rotaion_direction : int
|
var rotaion_direction : int
|
||||||
|
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
rotaion_direction = randi_range(-1, 1)
|
movement_speed = randi_range(movement_speed_min, movement_speed_max)
|
||||||
rotation_speed = randi_range(50, 250)
|
movement_speed *= size_data[current_size]["Speed-Multi"]
|
||||||
|
|
||||||
|
rotaion_direction = randi_range(0, 1)
|
||||||
|
if rotaion_direction < 1:
|
||||||
|
rotaion_direction = -1
|
||||||
|
rotation_speed = randi_range(50, 150)
|
||||||
|
rotate(randi_range(0, 360))
|
||||||
|
|
||||||
|
self.scale *= size_data[current_size]["Scale"]
|
||||||
|
|
||||||
func _physics_process(delta: float) -> void:
|
func _physics_process(delta: float) -> void:
|
||||||
rotate(deg_to_rad(rotaion_direction * rotation_speed * delta))
|
$CollisionPolygon2D.rotate(deg_to_rad(rotaion_direction * rotation_speed * delta))
|
||||||
|
$Sprite2D.rotate(deg_to_rad(rotaion_direction * rotation_speed * delta))
|
||||||
|
|
||||||
# TODO: Add "floating in space" movement
|
position += movement_direciton.rotated(rotation) * movement_speed * delta
|
||||||
|
|
||||||
# Screen Wrap
|
# Screen Wrap
|
||||||
var viewport_size := get_viewport_rect().size
|
var viewport_size := get_viewport_rect().size
|
||||||
@ -27,6 +51,10 @@ func _physics_process(delta: float) -> void:
|
|||||||
|
|
||||||
func _on_body_entered(body: Node2D) -> void:
|
func _on_body_entered(body: Node2D) -> void:
|
||||||
print(body)
|
print(body)
|
||||||
# TODO: Add "explosion" logic if bullet hits me
|
if body.is_in_group("bullet"):
|
||||||
|
explode()
|
||||||
if body.is_in_group("ship"):
|
if body.is_in_group("ship"):
|
||||||
body.crash()
|
body.crash()
|
||||||
|
|
||||||
|
func explode() -> void:
|
||||||
|
queue_free()
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
[ext_resource type="Script" path="res://scenes/comet.gd" id="1_33qxe"]
|
[ext_resource type="Script" path="res://scenes/comet.gd" id="1_33qxe"]
|
||||||
|
|
||||||
[node name="Comet" type="Area2D"]
|
[node name="Comet" type="Area2D"]
|
||||||
|
collision_layer = 3
|
||||||
script = ExtResource("1_33qxe")
|
script = ExtResource("1_33qxe")
|
||||||
|
|
||||||
[node name="Sprite2D" type="Sprite2D" parent="."]
|
[node name="Sprite2D" type="Sprite2D" parent="."]
|
||||||
|
@ -25,3 +25,14 @@ position = Vector2(622, 309)
|
|||||||
|
|
||||||
[node name="Comet" parent="." instance=ExtResource("2_b37uv")]
|
[node name="Comet" parent="." instance=ExtResource("2_b37uv")]
|
||||||
position = Vector2(276, 249)
|
position = Vector2(276, 249)
|
||||||
|
current_size = 1
|
||||||
|
|
||||||
|
[node name="Comet2" parent="." instance=ExtResource("2_b37uv")]
|
||||||
|
position = Vector2(439, 459)
|
||||||
|
|
||||||
|
[node name="Comet3" parent="." instance=ExtResource("2_b37uv")]
|
||||||
|
position = Vector2(834, 136)
|
||||||
|
current_size = 0
|
||||||
|
|
||||||
|
[node name="Comet4" parent="." instance=ExtResource("2_b37uv")]
|
||||||
|
position = Vector2(938, 402)
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
extends Area2D
|
extends Area2D
|
||||||
|
|
||||||
# TODO: Tweak speed and LifeTimer values
|
# FIXME: Tweak speed and LifeTimer values
|
||||||
|
|
||||||
@export var speed := 1400.00
|
@export var speed := 1400.00
|
||||||
var direction := Vector2.UP
|
var direction := Vector2.UP
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
extends CharacterBody2D
|
extends CharacterBody2D
|
||||||
|
|
||||||
# TODO: Add the ability to "warp"
|
# TODO: Add the ability to "warp"
|
||||||
# TODO: Tweak speed and shoot time values
|
# FIXME: Tweak speed and shoot time values
|
||||||
|
# FIXME: Tweak Ship's scale
|
||||||
|
|
||||||
const BULLET = preload("res://scenes/bullet.tscn")
|
const BULLET = preload("res://scenes/bullet.tscn")
|
||||||
|
|
||||||
@ -41,7 +42,7 @@ func fire_gun(pos : Vector2, rot : float) -> void:
|
|||||||
bullet.position = pos
|
bullet.position = pos
|
||||||
bullet.rotation = rot
|
bullet.rotation = rot
|
||||||
$Projectiles.add_child(bullet)
|
$Projectiles.add_child(bullet)
|
||||||
$ShootSounds.play()
|
$ShootSound.play()
|
||||||
can_shoot = false
|
can_shoot = false
|
||||||
$ShotCooldown.start()
|
$ShotCooldown.start()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user