mirror of
https://codeberg.org/Melon-Bread/Comets.gd.git
synced 2024-11-24 21:18:21 -05:00
Ship can now warp
This commit is contained in:
parent
914a6e4010
commit
3ad6004836
@ -34,6 +34,21 @@ ui_accept={
|
||||
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":0,"pressure":0.0,"pressed":true,"script":null)
|
||||
]
|
||||
}
|
||||
ui_select={
|
||||
"deadzone": 0.5,
|
||||
"events": [Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":3,"pressure":0.0,"pressed":false,"script":null)
|
||||
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":32,"physical_keycode":0,"key_label":0,"unicode":32,"echo":false,"script":null)
|
||||
, 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":0,"position":Vector2(0, 0),"global_position":Vector2(0, 0),"factor":1.0,"button_index":1,"canceled":false,"pressed":false,"double_click":false,"script":null)
|
||||
]
|
||||
}
|
||||
ui_cancel={
|
||||
"deadzone": 0.5,
|
||||
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":4194305,"physical_keycode":0,"key_label":0,"unicode":0,"echo":false,"script":null)
|
||||
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":1,"pressure":0.0,"pressed":true,"script":null)
|
||||
, 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":4194328,"key_label":0,"unicode":0,"echo":false,"script":null)
|
||||
, 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":0,"position":Vector2(0, 0),"global_position":Vector2(0, 0),"factor":1.0,"button_index":2,"canceled":false,"pressed":false,"double_click":false,"script":null)
|
||||
]
|
||||
}
|
||||
ui_left={
|
||||
"deadzone": 0.5,
|
||||
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":4194319,"physical_keycode":0,"key_label":0,"unicode":0,"echo":false,"script":null)
|
||||
|
@ -78,6 +78,9 @@ polygon = PackedVector2Array(-3, -31, 4, -31, 32, 28, 32, 33, 28, 33, 1, 16, -24
|
||||
wait_time = 0.5
|
||||
one_shot = true
|
||||
|
||||
[node name="WarpCooldown" type="Timer" parent="."]
|
||||
one_shot = true
|
||||
|
||||
[node name="Gun" type="Marker2D" parent="."]
|
||||
position = Vector2(0, -33)
|
||||
|
||||
@ -95,3 +98,4 @@ libraries = {
|
||||
}
|
||||
|
||||
[connection signal="timeout" from="ShotCooldown" to="." method="_on_shot_cooldown_timeout"]
|
||||
[connection signal="timeout" from="WarpCooldown" to="." method="_on_warp_cooldown_timeout"]
|
||||
|
@ -1,7 +1,5 @@
|
||||
extends Area2D
|
||||
|
||||
# FIXME: Tweak speed and LifeTimer values
|
||||
|
||||
@export var speed := 1400.00
|
||||
var direction := Vector2.UP
|
||||
|
||||
|
@ -1,6 +1,5 @@
|
||||
extends Node2D
|
||||
|
||||
# TODO: Make a small title screen that starts before the game scene
|
||||
# TODO: MAYBE track high score in a file & show it on HUD
|
||||
# TODO: MAYBE make ufo enemey that randomly flies in from ones sode to the other
|
||||
|
||||
|
@ -1,6 +1,5 @@
|
||||
extends CharacterBody2D
|
||||
|
||||
# TODO: Add the ability to "warp"
|
||||
# FIXME: Tweak speed and floatyness4
|
||||
|
||||
signal crashed
|
||||
@ -11,7 +10,13 @@ const BULLET = preload("res://scenes/bullet.tscn")
|
||||
@export var max_speed := 350.0
|
||||
@export var rotation_speed := 200.0
|
||||
|
||||
var viewport_size : Vector2
|
||||
|
||||
var can_shoot := true
|
||||
var can_warp := true
|
||||
|
||||
func _ready() -> void:
|
||||
viewport_size = get_viewport_rect().size
|
||||
|
||||
func _physics_process(delta: float) -> void:
|
||||
# Controls
|
||||
@ -21,6 +26,9 @@ func _physics_process(delta: float) -> void:
|
||||
if Input.is_action_pressed("ui_accept") and can_shoot:
|
||||
fire_gun($Gun.global_position, self.global_rotation)
|
||||
|
||||
if Input.is_action_pressed("ui_cancel") and can_warp:
|
||||
warp()
|
||||
|
||||
# Movement Logic
|
||||
## Accleration
|
||||
velocity += accleration_direction.rotated(rotation) * accleration * delta
|
||||
@ -34,7 +42,6 @@ func _physics_process(delta: float) -> void:
|
||||
move_and_slide()
|
||||
|
||||
# Screen Wrap
|
||||
var viewport_size := get_viewport_rect().size
|
||||
position.x = wrap(position.x, 0, viewport_size.x)
|
||||
position.y = wrap(position.y, 0,viewport_size.y)
|
||||
|
||||
@ -47,7 +54,15 @@ func fire_gun(pos : Vector2, rot : float) -> void:
|
||||
can_shoot = false
|
||||
$ShotCooldown.start()
|
||||
|
||||
func crash():
|
||||
func warp() -> void:
|
||||
var random_position := Vector2.ZERO
|
||||
random_position.x = randf_range(0, viewport_size.x)
|
||||
random_position.y = randf_range(0, viewport_size.y)
|
||||
position = random_position
|
||||
can_warp = false
|
||||
$WarpCooldown.start()
|
||||
|
||||
func crash() -> void:
|
||||
# TODO: Make some kind of crash animation or crashed sprite
|
||||
crashed.emit()
|
||||
$AnimationPlayer.play("crash")
|
||||
@ -55,3 +70,6 @@ func crash():
|
||||
|
||||
func _on_shot_cooldown_timeout() -> void:
|
||||
can_shoot = true
|
||||
|
||||
func _on_warp_cooldown_timeout() -> void:
|
||||
can_warp = true
|
||||
|
Loading…
Reference in New Issue
Block a user