Trying to synchronize bullet with fake calculated ship velocity.
This commit is contained in:
parent
6856dcb172
commit
030304dc48
8 changed files with 75 additions and 6 deletions
|
|
@ -18,8 +18,9 @@ config/icon="res://icon.svg"
|
||||||
|
|
||||||
window/size/viewport_width=216
|
window/size/viewport_width=216
|
||||||
window/size/viewport_height=384
|
window/size/viewport_height=384
|
||||||
window/size/window_width_override=648
|
window/size/window_width_override=1296
|
||||||
window/size/window_height_override=1152
|
window/size/window_height_override=2304
|
||||||
|
window/subwindows/embed_subwindows=false
|
||||||
window/stretch/mode="viewport"
|
window/stretch/mode="viewport"
|
||||||
window/stretch/aspect="keep_width"
|
window/stretch/aspect="keep_width"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,46 @@
|
||||||
[gd_scene format=3 uid="uid://dqd8cxe7aj3b4"]
|
[gd_scene format=3 uid="uid://dqd8cxe7aj3b4"]
|
||||||
|
|
||||||
[ext_resource type="PackedScene" uid="uid://bj4fytc3sy482" path="res://scenes/world.tscn" id="1_uwrxv"]
|
[ext_resource type="PackedScene" uid="uid://bj4fytc3sy482" path="res://scenes/world.tscn" id="1_uwrxv"]
|
||||||
|
[ext_resource type="Texture2D" uid="uid://egqbrm636m4h" path="res://graphics/title.png" id="2_yqjtg"]
|
||||||
|
|
||||||
[node name="Main" type="Node2D" unique_id=1673976895]
|
[node name="Game" type="Node2D" unique_id=1673976895]
|
||||||
|
|
||||||
[node name="World" parent="." unique_id=1317852169 instance=ExtResource("1_uwrxv")]
|
[node name="World" parent="." unique_id=1317852169 instance=ExtResource("1_uwrxv")]
|
||||||
|
|
||||||
|
[node name="TitleMenu" type="Control" parent="." unique_id=1792253558]
|
||||||
|
layout_mode = 3
|
||||||
|
anchors_preset = 0
|
||||||
|
offset_right = 216.0
|
||||||
|
offset_bottom = 384.0
|
||||||
|
size_flags_horizontal = 3
|
||||||
|
size_flags_vertical = 3
|
||||||
|
|
||||||
|
[node name="HBoxContainer" type="HBoxContainer" parent="TitleMenu" unique_id=1084707548]
|
||||||
|
layout_mode = 1
|
||||||
|
anchors_preset = -1
|
||||||
|
anchor_left = 0.004
|
||||||
|
anchor_top = 0.16700001
|
||||||
|
anchor_right = 1.0
|
||||||
|
anchor_bottom = 0.609
|
||||||
|
offset_left = 10.136
|
||||||
|
offset_top = -0.12800598
|
||||||
|
offset_right = -10.600006
|
||||||
|
offset_bottom = 0.4960022
|
||||||
|
grow_horizontal = 2
|
||||||
|
grow_vertical = 2
|
||||||
|
|
||||||
|
[node name="Title" type="TextureRect" parent="TitleMenu/HBoxContainer" unique_id=1389062363]
|
||||||
|
layout_mode = 2
|
||||||
|
size_flags_horizontal = 10
|
||||||
|
size_flags_vertical = 4
|
||||||
|
texture = ExtResource("2_yqjtg")
|
||||||
|
|
||||||
|
[node name="TextureRect" type="ColorRect" parent="TitleMenu" unique_id=23737797]
|
||||||
|
z_index = -2
|
||||||
|
layout_mode = 1
|
||||||
|
anchors_preset = 15
|
||||||
|
anchor_right = 1.0
|
||||||
|
anchor_bottom = 1.0
|
||||||
|
grow_horizontal = 2
|
||||||
|
grow_vertical = 2
|
||||||
|
color = Color(0.67049235, 0.66050816, 0.7086971, 1)
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,14 @@
|
||||||
[gd_scene format=3 uid="uid://coix5dqblmu7r"]
|
[gd_scene format=3 uid="uid://coix5dqblmu7r"]
|
||||||
|
|
||||||
[ext_resource type="Script" uid="uid://otm88638j7f8" path="res://scripts/player.gd" id="1_g2els"]
|
[ext_resource type="Script" uid="uid://otm88638j7f8" path="res://scripts/player.gd" id="1_g2els"]
|
||||||
|
[ext_resource type="PackedScene" uid="uid://ddpclu2vdy2ve" path="res://scenes/stock_weapon.tscn" id="2_dqkch"]
|
||||||
[ext_resource type="Texture2D" uid="uid://cq4we1m1yv22s" path="res://graphics/ship.png" id="2_qhqgy"]
|
[ext_resource type="Texture2D" uid="uid://cq4we1m1yv22s" path="res://graphics/ship.png" id="2_qhqgy"]
|
||||||
|
|
||||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_dqkch"]
|
[sub_resource type="RectangleShape2D" id="RectangleShape2D_dqkch"]
|
||||||
|
|
||||||
[node name="Player" type="Area2D" unique_id=652131079]
|
[node name="Player" type="Area2D" unique_id=652131079]
|
||||||
script = ExtResource("1_g2els")
|
script = ExtResource("1_g2els")
|
||||||
|
weapon_current = ExtResource("2_dqkch")
|
||||||
|
|
||||||
[node name="Ship" type="Sprite2D" parent="." unique_id=1155866924]
|
[node name="Ship" type="Sprite2D" parent="." unique_id=1155866924]
|
||||||
unique_name_in_owner = true
|
unique_name_in_owner = true
|
||||||
|
|
|
||||||
|
|
@ -16,3 +16,7 @@ texture = ExtResource("3_mvdrj")
|
||||||
|
|
||||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="." unique_id=1890946059]
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="." unique_id=1890946059]
|
||||||
shape = SubResource("RectangleShape2D_mvdrj")
|
shape = SubResource("RectangleShape2D_mvdrj")
|
||||||
|
|
||||||
|
[node name="VisibleOnScreenNotifier2D" type="VisibleOnScreenNotifier2D" parent="." unique_id=985862716]
|
||||||
|
|
||||||
|
[connection signal="screen_exited" from="VisibleOnScreenNotifier2D" to="." method="_on_visible_on_screen_notifier_2d_screen_exited"]
|
||||||
|
|
|
||||||
|
|
@ -7,3 +7,4 @@ anchor_right = 1.0
|
||||||
anchor_bottom = 1.0
|
anchor_bottom = 1.0
|
||||||
grow_horizontal = 2
|
grow_horizontal = 2
|
||||||
grow_vertical = 2
|
grow_vertical = 2
|
||||||
|
size_flags_vertical = 3
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,7 @@
|
||||||
[gd_scene format=3 uid="uid://bj4fytc3sy482"]
|
[gd_scene format=3 uid="uid://bj4fytc3sy482"]
|
||||||
|
|
||||||
|
[ext_resource type="PackedScene" uid="uid://14fhj8834pkq" path="res://scenes/ui.tscn" id="1_nnsk1"]
|
||||||
|
|
||||||
[node name="World" type="Node2D" unique_id=1317852169]
|
[node name="World" type="Node2D" unique_id=1317852169]
|
||||||
|
|
||||||
|
[node name="UI" parent="." unique_id=480295610 instance=ExtResource("1_nnsk1")]
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,8 @@ var shield: int = 0: set = shield_set
|
||||||
var can_shoot: bool = true
|
var can_shoot: bool = true
|
||||||
var is_shooting: bool = false
|
var is_shooting: bool = false
|
||||||
|
|
||||||
var weapon_current = load("res://scenes/stock_weapon.tscn")
|
@export var weapon_current : PackedScene
|
||||||
|
#var weapon_current = load("res://scenes/stock_weapon.tscn")
|
||||||
var weapon_cooldown = Timer
|
var weapon_cooldown = Timer
|
||||||
var weapon_rate: float = 0.1
|
var weapon_rate: float = 0.1
|
||||||
var weapon_timer: float = 0.0
|
var weapon_timer: float = 0.0
|
||||||
|
|
@ -32,6 +33,21 @@ func _process(delta):
|
||||||
position += input * speed * delta
|
position += input * speed * delta
|
||||||
position = position.clamp(Vector2(12,12), screensize - Vector2(12,12))
|
position = position.clamp(Vector2(12,12), screensize - Vector2(12,12))
|
||||||
|
|
||||||
|
# Update velocity based on input
|
||||||
|
var direction = Vector2.ZERO
|
||||||
|
if Input.is_action_pressed("down"):
|
||||||
|
direction.y += 1
|
||||||
|
if Input.is_action_pressed("up"):
|
||||||
|
direction.y -= 1
|
||||||
|
|
||||||
|
# Normalize direction and apply speed
|
||||||
|
if direction.length() > 0:
|
||||||
|
velocity = direction.normalized() * speed
|
||||||
|
|
||||||
|
# Update velocity
|
||||||
|
velocity += velocity * delta
|
||||||
|
|
||||||
|
|
||||||
if Input.is_action_pressed("shoot"):
|
if Input.is_action_pressed("shoot"):
|
||||||
print("Spacebar pressed!")
|
print("Spacebar pressed!")
|
||||||
is_shooting = true
|
is_shooting = true
|
||||||
|
|
|
||||||
|
|
@ -7,5 +7,7 @@ extends Area2D
|
||||||
|
|
||||||
|
|
||||||
func _process(delta):
|
func _process(delta):
|
||||||
#position.y += shot_data.speed * delta #This works normally
|
position += transform.y * (shot_data.speed - player.velocity.y) * delta #This works normally
|
||||||
position += (transform.y + player.velocity) * shot_data.speed * delta
|
#position += (transform.y + player.velocity) * shot_data.speed * delta #This doesn'tt
|
||||||
|
func _on_visible_on_screen_notifier_2d_screen_exited() -> void:
|
||||||
|
queue_free()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue