bug: Fix low-resolution text
This commit is contained in:
parent
64c055b23f
commit
e287853798
13 changed files with 1463 additions and 104 deletions
|
|
@ -13,8 +13,8 @@ const CREDIT_LABELS_LINKS := {
|
|||
"Extra Life Jingle" : ["Mrthenoronha : freesound.org", "https://freesound.org/people/Mrthenoronha/sounds/518306/"]
|
||||
}
|
||||
|
||||
const LEFT_COL_WIDTH := 300
|
||||
const RIGHT_COL_WIDTH := 300
|
||||
const LEFT_COL_WIDTH := 350
|
||||
const RIGHT_COL_WIDTH := 350
|
||||
|
||||
func _ready() -> void:
|
||||
$Back.pressed.connect(_emit_back)
|
||||
|
|
|
|||
|
|
@ -3,10 +3,10 @@
|
|||
[ext_resource type="Script" uid="uid://cf1vwutwpi4rf" path="res://Scripts/game_over.gd" id="1_ojehl"]
|
||||
|
||||
[sub_resource type="LabelSettings" id="LabelSettings_i2yjh"]
|
||||
font_size = 72
|
||||
font_size = 120
|
||||
|
||||
[sub_resource type="LabelSettings" id="LabelSettings_ojehl"]
|
||||
font_size = 32
|
||||
font_size = 48
|
||||
|
||||
[node name="Control" type="Control"]
|
||||
layout_mode = 3
|
||||
|
|
@ -34,9 +34,10 @@ layout_mode = 1
|
|||
anchors_preset = 5
|
||||
anchor_left = 0.5
|
||||
anchor_right = 0.5
|
||||
offset_left = -195.0
|
||||
offset_right = 195.0
|
||||
offset_bottom = 99.0
|
||||
offset_left = -326.0
|
||||
offset_top = -55.0
|
||||
offset_right = 326.0
|
||||
offset_bottom = 110.0
|
||||
grow_horizontal = 2
|
||||
text = "Game Over"
|
||||
label_settings = SubResource("LabelSettings_i2yjh")
|
||||
|
|
@ -46,10 +47,10 @@ layout_mode = 1
|
|||
anchors_preset = 5
|
||||
anchor_left = 0.5
|
||||
anchor_right = 0.5
|
||||
offset_left = -60.5
|
||||
offset_top = 85.0
|
||||
offset_right = 60.5
|
||||
offset_bottom = 130.0
|
||||
offset_left = -90.5
|
||||
offset_top = 80.0
|
||||
offset_right = 90.5
|
||||
offset_bottom = 147.0
|
||||
grow_horizontal = 2
|
||||
text = "Score: 0"
|
||||
label_settings = SubResource("LabelSettings_ojehl")
|
||||
|
|
@ -59,9 +60,10 @@ layout_mode = 1
|
|||
anchors_preset = 5
|
||||
anchor_left = 0.5
|
||||
anchor_right = 0.5
|
||||
offset_left = -75.0
|
||||
offset_top = 155.0
|
||||
offset_right = 75.0
|
||||
offset_bottom = 190.0
|
||||
offset_left = -125.0
|
||||
offset_top = 170.0
|
||||
offset_right = 125.0
|
||||
offset_bottom = 223.0
|
||||
grow_horizontal = 2
|
||||
theme_override_font_sizes/font_size = 32
|
||||
text = "New Game"
|
||||
|
|
|
|||
|
|
@ -4,18 +4,19 @@
|
|||
[ext_resource type="Texture2D" uid="uid://cv84w0y2jg3i3" path="res://Sprites/i_are_spaceship.png" id="1_fn5yt"]
|
||||
|
||||
[sub_resource type="CapsuleShape2D" id="CapsuleShape2D_6vqwg"]
|
||||
radius = 3.0
|
||||
height = 10.0
|
||||
radius = 2.0
|
||||
height = 8.0
|
||||
|
||||
[node name="Laser" type="Area2D"]
|
||||
script = ExtResource("1_6vqwg")
|
||||
|
||||
[node name="Sprite2D" type="Sprite2D" parent="."]
|
||||
position = Vector2(-1, 1)
|
||||
scale = Vector2(2, 2)
|
||||
scale = Vector2(1.5, 1.5)
|
||||
texture = ExtResource("1_fn5yt")
|
||||
region_enabled = true
|
||||
region_rect = Rect2(34, 17, 3, 7)
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||
position = Vector2(0, 1)
|
||||
shape = SubResource("CapsuleShape2D_6vqwg")
|
||||
|
|
|
|||
|
|
@ -1,9 +1,10 @@
|
|||
[gd_scene load_steps=2 format=3 uid="uid://j2mr8pluyo37"]
|
||||
[gd_scene load_steps=2 format=3 uid="uid://dkqojwn3escv3"]
|
||||
|
||||
[ext_resource type="Texture2D" uid="uid://cvfsmhdbgh8vh" path="res://Sprites/idle_spaceship.png" id="1_bkce2"]
|
||||
|
||||
[node name="Life" type="TextureRect"]
|
||||
offset_right = 15.0
|
||||
offset_bottom = 24.0
|
||||
[node name="TextureRect" type="TextureRect"]
|
||||
custom_minimum_size = Vector2(30, 48)
|
||||
offset_right = 30.0
|
||||
texture = ExtResource("1_bkce2")
|
||||
expand_mode = 5
|
||||
stretch_mode = 4
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
[ext_resource type="Script" uid="uid://dxbdiq4y3mqtd" path="res://Scripts/main_menu.gd" id="1_28flt"]
|
||||
|
||||
[sub_resource type="LabelSettings" id="LabelSettings_i2yjh"]
|
||||
font_size = 72
|
||||
font_size = 120
|
||||
|
||||
[node name="Control" type="Control"]
|
||||
layout_mode = 3
|
||||
|
|
@ -31,46 +31,38 @@ layout_mode = 1
|
|||
anchors_preset = 5
|
||||
anchor_left = 0.5
|
||||
anchor_right = 0.5
|
||||
offset_left = -195.0
|
||||
offset_right = 195.0
|
||||
offset_bottom = 99.0
|
||||
offset_left = -273.0
|
||||
offset_top = -52.0
|
||||
offset_right = 273.0
|
||||
offset_bottom = 113.0
|
||||
grow_horizontal = 2
|
||||
text = "Asteroids"
|
||||
label_settings = SubResource("LabelSettings_i2yjh")
|
||||
horizontal_alignment = 1
|
||||
|
||||
[node name="New Game" type="Button" parent="Container"]
|
||||
[node name="ButtonContainer" type="VBoxContainer" parent="Container"]
|
||||
layout_mode = 1
|
||||
anchors_preset = 5
|
||||
anchor_left = 0.5
|
||||
anchor_right = 0.5
|
||||
offset_left = -75.0
|
||||
offset_top = 105.0
|
||||
offset_right = 75.0
|
||||
offset_bottom = 140.0
|
||||
offset_left = -125.0
|
||||
offset_top = 120.0
|
||||
offset_right = 125.0
|
||||
offset_bottom = 420.0
|
||||
grow_horizontal = 2
|
||||
theme_override_constants/separation = 15
|
||||
|
||||
[node name="New Game" type="Button" parent="Container/ButtonContainer"]
|
||||
layout_mode = 2
|
||||
theme_override_font_sizes/font_size = 32
|
||||
text = "New Game"
|
||||
|
||||
[node name="Quit" type="Button" parent="Container"]
|
||||
layout_mode = 1
|
||||
anchors_preset = 5
|
||||
anchor_left = 0.5
|
||||
anchor_right = 0.5
|
||||
offset_left = -75.0
|
||||
offset_top = 205.0
|
||||
offset_right = 75.0
|
||||
offset_bottom = 240.0
|
||||
grow_horizontal = 2
|
||||
text = "Quit"
|
||||
|
||||
[node name="Credits" type="Button" parent="Container"]
|
||||
layout_mode = 1
|
||||
anchors_preset = 5
|
||||
anchor_left = 0.5
|
||||
anchor_right = 0.5
|
||||
offset_left = -75.0
|
||||
offset_top = 155.0
|
||||
offset_right = 75.0
|
||||
offset_bottom = 190.0
|
||||
grow_horizontal = 2
|
||||
[node name="Credits" type="Button" parent="Container/ButtonContainer"]
|
||||
layout_mode = 2
|
||||
theme_override_font_sizes/font_size = 32
|
||||
text = "Credits"
|
||||
|
||||
[node name="Quit" type="Button" parent="Container/ButtonContainer"]
|
||||
layout_mode = 2
|
||||
theme_override_font_sizes/font_size = 32
|
||||
text = "Quit"
|
||||
|
|
|
|||
|
|
@ -77,14 +77,16 @@ animations = [{
|
|||
}]
|
||||
|
||||
[sub_resource type="ConvexPolygonShape2D" id="ConvexPolygonShape2D_kek77"]
|
||||
points = PackedVector2Array(-6, 0, -7, 7, 8, 7, 7, 0, 0, -8)
|
||||
points = PackedVector2Array(-7, 0, -8, 7, 7, 7, 6, 0, 0, -8)
|
||||
|
||||
[node name="Ship" type="CharacterBody2D"]
|
||||
scale = Vector2(2, 2)
|
||||
script = ExtResource("1_6ejuo")
|
||||
Laser = ExtResource("2_8aq7e")
|
||||
pew = ExtResource("3_fwcnm")
|
||||
|
||||
[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."]
|
||||
position = Vector2(-1, 0)
|
||||
sprite_frames = SubResource("SpriteFrames_1bvp3")
|
||||
animation = &"right"
|
||||
autoplay = "idle"
|
||||
|
|
@ -94,4 +96,4 @@ position = Vector2(0, -4)
|
|||
shape = SubResource("ConvexPolygonShape2D_kek77")
|
||||
|
||||
[node name="Muzzle" type="Marker2D" parent="."]
|
||||
position = Vector2(0, -15)
|
||||
position = Vector2(0, -14)
|
||||
|
|
|
|||
|
|
@ -12,5 +12,5 @@ func _ready() -> void:
|
|||
}
|
||||
|
||||
for btn_name in buttons.keys():
|
||||
var btn = $Container.get_node(btn_name)
|
||||
var btn = $Container/ButtonContainer.get_node(btn_name)
|
||||
btn.pressed.connect(func(): emit_signal(buttons[btn_name]))
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ func _physics_process(delta: float) -> void:
|
|||
last_shot = 0.0
|
||||
|
||||
func die():
|
||||
position = get_viewport_rect().size
|
||||
position = get_viewport_rect().size / 2
|
||||
speed = Vector2(0, 0)
|
||||
inv_time = 3.0
|
||||
|
||||
|
|
|
|||
|
|
@ -20,9 +20,9 @@ func _ready():
|
|||
add_child(timer)
|
||||
|
||||
func spawn_time_from_score(score: int) -> float:
|
||||
var min_time = 0.3
|
||||
var max_time = 2.0
|
||||
var max_score = 50000.0
|
||||
var min_time = 0.2
|
||||
var max_time = 1.5
|
||||
var max_score = 100000.0
|
||||
|
||||
# Clamp score so it doesn’t overshoot
|
||||
var clamped_score = clamp(score, 0, max_score)
|
||||
|
|
@ -38,45 +38,47 @@ func spawn_time_from_score(score: int) -> float:
|
|||
return lerp(max_time, min_time, curved_t)
|
||||
|
||||
func spawn_enemy():
|
||||
var enemy = asteroids[randi_range(0, 3)].instantiate()
|
||||
var pos = get_random_edge_position()
|
||||
enemy.position = pos
|
||||
|
||||
var idx = randi_range(0, 3)
|
||||
var enemy = asteroids[idx].instantiate()
|
||||
# Direction vector toward center
|
||||
var center = screen_size * 0.5
|
||||
|
||||
enemy.rot_velocity = randf_range(-PI, PI)
|
||||
enemy.rotation = randf_range(0, PI)
|
||||
|
||||
var scl = randi_range(2 + idx, 5 + 3*idx)
|
||||
enemy.scale = Vector2(scl, scl)
|
||||
|
||||
var pos = get_random_edge_position(Utils.get_half_size(enemy))
|
||||
var dir = (center - pos).normalized()
|
||||
|
||||
# Add some randomness so it's not always perfect
|
||||
var angle_variation = randf_range(-0.5, 0.5) # radians (~±14 degrees)
|
||||
dir = dir.rotated(angle_variation)
|
||||
|
||||
# Apply starting velocity
|
||||
enemy.rot_velocity = randf_range(0, PI)
|
||||
enemy.velocity = dir * randf_range(50, 200)
|
||||
enemy.rotation = randf_range(0, PI)
|
||||
|
||||
var scl = randi_range(1, 5)
|
||||
enemy.scale = Vector2(scl, scl)
|
||||
enemy.velocity = dir * randf_range(75, 250)
|
||||
enemy.position = pos
|
||||
|
||||
enemy.add_to_group("enemies")
|
||||
add_child(enemy)
|
||||
|
||||
timer.wait_time = spawn_time_from_score(Game.score)
|
||||
|
||||
func get_random_edge_position() -> Vector2:
|
||||
func get_random_edge_position(half_size: Vector2) -> Vector2:
|
||||
# Pick which edge (0=top,1=bottom,2=left,3=right)
|
||||
var edge = randi() % 4
|
||||
match edge:
|
||||
0: # top
|
||||
return Vector2(randf() * screen_size.x, 0)
|
||||
return Vector2(randf() * screen_size.x, -half_size.y)
|
||||
1: # bottom
|
||||
return Vector2(randf() * screen_size.x, screen_size.y)
|
||||
return Vector2(randf() * screen_size.x, screen_size.y + half_size.y)
|
||||
2: # left
|
||||
return Vector2(0, randf() * screen_size.y)
|
||||
return Vector2(-half_size.x, randf() * screen_size.y)
|
||||
3: # right
|
||||
return Vector2(screen_size.x, randf() * screen_size.y)
|
||||
return Vector2(screen_size.x + half_size.x, randf() * screen_size.y)
|
||||
return Vector2.ZERO
|
||||
|
||||
|
||||
func stop():
|
||||
timer.stop()
|
||||
|
||||
|
|
|
|||
|
|
@ -1,20 +1,34 @@
|
|||
extends Node2D
|
||||
|
||||
func get_half_size(sprt: Node2D):
|
||||
var half_size: Vector2
|
||||
func get_half_size(node: Node2D) -> Vector2:
|
||||
var tex_size := Vector2.ZERO
|
||||
var sprite: Node2D = null
|
||||
|
||||
if sprt is Sprite2D:
|
||||
half_size = (sprt.texture.get_size() * sprt.scale) / 2.0
|
||||
elif sprt is AnimatedSprite2D:
|
||||
var tex: Texture2D = sprt.sprite_frames.get_frame_texture(sprt.animation, 0)
|
||||
if tex:
|
||||
half_size = (tex.get_size() * sprt.scale) / 2.0
|
||||
else:
|
||||
half_size = Vector2.ZERO
|
||||
# Try to find a Sprite2D or AnimatedSprite2D child
|
||||
if node is Sprite2D or node is AnimatedSprite2D:
|
||||
sprite = node
|
||||
else:
|
||||
half_size = Vector2.ZERO
|
||||
for child in node.get_children():
|
||||
if child is Sprite2D or child is AnimatedSprite2D:
|
||||
sprite = child
|
||||
break
|
||||
|
||||
return half_size
|
||||
if sprite == null:
|
||||
return Vector2.ZERO
|
||||
|
||||
# Get texture size
|
||||
if sprite is Sprite2D:
|
||||
if sprite.texture:
|
||||
tex_size = sprite.texture.get_size()
|
||||
elif sprite is AnimatedSprite2D:
|
||||
var tex: Texture2D = sprite.sprite_frames.get_frame_texture(sprite.animation, 0)
|
||||
if tex:
|
||||
tex_size = tex.get_size()
|
||||
|
||||
# Combine parent scaling (global scale includes both)
|
||||
var global_scl = sprite.get_global_transform().get_scale()
|
||||
|
||||
return (tex_size * global_scl) * 0.5
|
||||
|
||||
func wrap_position(node: Node2D) -> void:
|
||||
var rect = node.get_viewport_rect()
|
||||
|
|
|
|||
23
main.tscn
23
main.tscn
|
|
@ -1,4 +1,4 @@
|
|||
[gd_scene load_steps=7 format=3 uid="uid://cmlg48m6buclv"]
|
||||
[gd_scene load_steps=6 format=3 uid="uid://cmlg48m6buclv"]
|
||||
|
||||
[ext_resource type="Texture2D" uid="uid://cuqofgxmpn2fu" path="res://Sprites/space.png" id="1_7mycd"]
|
||||
[ext_resource type="Script" uid="uid://dpa4j6me328ak" path="res://Scripts/ui.gd" id="2_272bh"]
|
||||
|
|
@ -6,8 +6,6 @@
|
|||
[ext_resource type="Script" uid="uid://mfgrqlsgsyrx" path="res://Scripts/spawner.gd" id="4_1bvp3"]
|
||||
[ext_resource type="Script" uid="uid://miwfeu4n6uh7" path="res://Scripts/lives.gd" id="4_kek77"]
|
||||
|
||||
[sub_resource type="LabelSettings" id="LabelSettings_7mycd"]
|
||||
|
||||
[node name="Node2D" type="Node2D"]
|
||||
|
||||
[node name="Background" type="TextureRect" parent="."]
|
||||
|
|
@ -20,25 +18,24 @@ stretch_mode = 1
|
|||
script = ExtResource("2_272bh")
|
||||
|
||||
[node name="Score" type="Label" parent="UI"]
|
||||
visible = false
|
||||
anchors_preset = 1
|
||||
anchor_left = 1.0
|
||||
anchor_right = 1.0
|
||||
offset_left = -66.0
|
||||
offset_top = 2.0
|
||||
offset_right = -5.0
|
||||
offset_bottom = 25.0
|
||||
offset_left = -102.0
|
||||
offset_top = 10.0
|
||||
offset_right = -11.0
|
||||
offset_bottom = 44.0
|
||||
grow_horizontal = 0
|
||||
text = "Score: 0"
|
||||
label_settings = SubResource("LabelSettings_7mycd")
|
||||
horizontal_alignment = 2
|
||||
script = ExtResource("3_5vw27")
|
||||
|
||||
[node name="Lives" type="HBoxContainer" parent="UI"]
|
||||
offset_left = 6.0
|
||||
offset_top = 6.0
|
||||
offset_right = 46.0
|
||||
offset_bottom = 46.0
|
||||
offset_left = 15.0
|
||||
offset_top = 15.0
|
||||
offset_right = 199.0
|
||||
offset_bottom = 108.0
|
||||
theme_override_constants/separation = 10
|
||||
script = ExtResource("4_kek77")
|
||||
|
||||
[node name="Spawner" type="Node2D" parent="."]
|
||||
|
|
|
|||
1345
main_theme.tres
Normal file
1345
main_theme.tres
Normal file
File diff suppressed because one or more lines are too long
|
|
@ -22,7 +22,10 @@ Utils="*res://Scripts/utils.gd"
|
|||
[display]
|
||||
|
||||
window/stretch/mode="viewport"
|
||||
window/stretch/scale=1.5
|
||||
|
||||
[gui]
|
||||
|
||||
theme/custom="uid://bxhc76qakpr7r"
|
||||
|
||||
[input]
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue