cute lil prototype
This commit is contained in:
parent
57f147236a
commit
0e4a55d7bd
19 changed files with 305 additions and 2 deletions
18
Prefabs/obstacle.tscn
Normal file
18
Prefabs/obstacle.tscn
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
[gd_scene load_steps=4 format=3 uid="uid://jb677rdhbj83"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://cnapenyo7b610" path="res://Prefabs/spinny.gd" id="1_htne5"]
|
||||
[ext_resource type="Texture2D" uid="uid://x8huf40a6dhq" path="res://Sprites/testObstacle.png" id="1_ifkp4"]
|
||||
|
||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_vef74"]
|
||||
size = Vector2(64, 64)
|
||||
|
||||
[node name="Obstacle" type="RigidBody2D"]
|
||||
gravity_scale = 0.0
|
||||
angular_damp_mode = 1
|
||||
script = ExtResource("1_htne5")
|
||||
|
||||
[node name="Sprite2D" type="Sprite2D" parent="."]
|
||||
texture = ExtResource("1_ifkp4")
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||
shape = SubResource("RectangleShape2D_vef74")
|
||||
12
Prefabs/spare_battery.tscn
Normal file
12
Prefabs/spare_battery.tscn
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
[gd_scene load_steps=3 format=3 uid="uid://cfdsa5scvso6m"]
|
||||
|
||||
[ext_resource type="Texture2D" uid="uid://1uqioi3jaw62" path="res://Sprites/batteryOutline.png" id="1_extsq"]
|
||||
[ext_resource type="Texture2D" uid="uid://1gx13iy21l2a" path="res://Sprites/batteryfull.png" id="2_n31ms"]
|
||||
|
||||
[node name="Battery2" type="TextureProgressBar"]
|
||||
max_value = 16.0
|
||||
value = 16.0
|
||||
fill_mode = 3
|
||||
texture_under = ExtResource("1_extsq")
|
||||
texture_progress = ExtResource("2_n31ms")
|
||||
tint_progress = Color(0, 1, 0, 1)
|
||||
11
Prefabs/spinny.gd
Normal file
11
Prefabs/spinny.gd
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
extends RigidBody2D
|
||||
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready() -> void:
|
||||
angular_velocity = randf_range(1,3)
|
||||
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(delta: float) -> void:
|
||||
pass
|
||||
1
Prefabs/spinny.gd.uid
Normal file
1
Prefabs/spinny.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://cnapenyo7b610
|
||||
BIN
Sprites/batteryBar.pdn
Normal file
BIN
Sprites/batteryBar.pdn
Normal file
Binary file not shown.
BIN
Sprites/batteryEmpty.png
Normal file
BIN
Sprites/batteryEmpty.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 353 B |
34
Sprites/batteryEmpty.png.import
Normal file
34
Sprites/batteryEmpty.png.import
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://ccynaibhuobpl"
|
||||
path="res://.godot/imported/batteryEmpty.png-5154000f16fee6ac654cb42658ea959e.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://Sprites/batteryEmpty.png"
|
||||
dest_files=["res://.godot/imported/batteryEmpty.png-5154000f16fee6ac654cb42658ea959e.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
|
||||
BIN
Sprites/batteryOutline.png
Normal file
BIN
Sprites/batteryOutline.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 410 B |
34
Sprites/batteryOutline.png.import
Normal file
34
Sprites/batteryOutline.png.import
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://1uqioi3jaw62"
|
||||
path="res://.godot/imported/batteryOutline.png-b360f372e0706eef76c2981c879540ff.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://Sprites/batteryOutline.png"
|
||||
dest_files=["res://.godot/imported/batteryOutline.png-b360f372e0706eef76c2981c879540ff.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
|
||||
BIN
Sprites/batteryfull.png
Normal file
BIN
Sprites/batteryfull.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 403 B |
34
Sprites/batteryfull.png.import
Normal file
34
Sprites/batteryfull.png.import
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://1gx13iy21l2a"
|
||||
path="res://.godot/imported/batteryfull.png-5f915430beb8a01d35ced1f546406e16.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://Sprites/batteryfull.png"
|
||||
dest_files=["res://.godot/imported/batteryfull.png-5f915430beb8a01d35ced1f546406e16.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
|
||||
BIN
Sprites/testObstacle.png
Normal file
BIN
Sprites/testObstacle.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 392 B |
34
Sprites/testObstacle.png.import
Normal file
34
Sprites/testObstacle.png.import
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://x8huf40a6dhq"
|
||||
path="res://.godot/imported/testObstacle.png-034534075f7b66af068ae98ae72e94b5.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://Sprites/testObstacle.png"
|
||||
dest_files=["res://.godot/imported/testObstacle.png-034534075f7b66af068ae98ae72e94b5.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
|
||||
32
battery_manager.gd
Normal file
32
battery_manager.gd
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
extends HBoxContainer
|
||||
|
||||
@export var current_battery : TextureProgressBar
|
||||
@export var battery_drain : float = 1
|
||||
@export var starting_batteries : int = 3
|
||||
var cb_value : float = 16
|
||||
var extra_batteries : int
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready() -> void:
|
||||
extra_batteries = starting_batteries -1
|
||||
redraw_extra_batteries()
|
||||
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(delta: float) -> void:
|
||||
if cb_value <= 0:
|
||||
extra_batteries -= 1
|
||||
cb_value = 16
|
||||
redraw_extra_batteries()
|
||||
var thrust : float = Input.get_action_strength("thrust")
|
||||
cb_value -= thrust * delta * battery_drain
|
||||
current_battery.value = cb_value
|
||||
|
||||
func redraw_extra_batteries():
|
||||
for i in range(get_children().size()):
|
||||
if(i != 0):
|
||||
get_child(i).queue_free()
|
||||
|
||||
for i in range(extra_batteries):
|
||||
var new_extra = load("res://Prefabs/spare_battery.tscn").instantiate()
|
||||
add_child(new_extra)
|
||||
1
battery_manager.gd.uid
Normal file
1
battery_manager.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://mwbiu2ajbxlk
|
||||
65
game.tscn
65
game.tscn
|
|
@ -1,8 +1,14 @@
|
|||
[gd_scene load_steps=8 format=3 uid="uid://hv07lm2tjwn4"]
|
||||
[gd_scene load_steps=14 format=3 uid="uid://hv07lm2tjwn4"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://crrbht7mwhgyc" path="res://Prefabs/lander.tscn" id="1_80nbo"]
|
||||
[ext_resource type="Script" uid="uid://bltj2frs6vqwj" path="res://autoscroll.gd" id="1_feb5d"]
|
||||
[ext_resource type="Script" uid="uid://mwbiu2ajbxlk" path="res://battery_manager.gd" id="1_ryrav"]
|
||||
[ext_resource type="Texture2D" uid="uid://evhjxwdbsmlo" path="res://Sprites/start.png" id="2_e2o6t"]
|
||||
[ext_resource type="Texture2D" uid="uid://1uqioi3jaw62" path="res://Sprites/batteryOutline.png" id="2_eow3j"]
|
||||
[ext_resource type="Texture2D" uid="uid://1gx13iy21l2a" path="res://Sprites/batteryfull.png" id="3_j5wjh"]
|
||||
[ext_resource type="PackedScene" uid="uid://cfdsa5scvso6m" path="res://Prefabs/spare_battery.tscn" id="4_eow3j"]
|
||||
[ext_resource type="Script" uid="uid://dd8psfqfobgau" path="res://test_obstacle_spawner.gd" id="6_vef74"]
|
||||
[ext_resource type="PackedScene" uid="uid://jb677rdhbj83" path="res://Prefabs/obstacle.tscn" id="8_j5wjh"]
|
||||
|
||||
[sub_resource type="Gradient" id="Gradient_mwb40"]
|
||||
offsets = PackedFloat32Array(0.806763, 1)
|
||||
|
|
@ -35,10 +41,51 @@ offset_right = 40.0
|
|||
offset_bottom = 40.0
|
||||
texture = SubResource("NoiseTexture2D_mwb40")
|
||||
|
||||
[node name="UI" type="Control" parent="CanvasLayer"]
|
||||
layout_mode = 3
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
|
||||
[node name="BatteryHolder" type="HBoxContainer" parent="CanvasLayer/UI" node_paths=PackedStringArray("current_battery")]
|
||||
layout_mode = 1
|
||||
offset_right = 68.0
|
||||
offset_bottom = 32.0
|
||||
script = ExtResource("1_ryrav")
|
||||
current_battery = NodePath("Battery")
|
||||
battery_drain = 4.0
|
||||
|
||||
[node name="Battery" type="TextureProgressBar" parent="CanvasLayer/UI/BatteryHolder"]
|
||||
layout_mode = 2
|
||||
max_value = 16.0
|
||||
value = 16.0
|
||||
fill_mode = 3
|
||||
texture_under = ExtResource("2_eow3j")
|
||||
texture_progress = ExtResource("3_j5wjh")
|
||||
tint_progress = Color(0, 1, 0, 1)
|
||||
|
||||
[node name="Battery2" parent="CanvasLayer/UI/BatteryHolder" instance=ExtResource("4_eow3j")]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="Battery3" type="TextureProgressBar" parent="CanvasLayer/UI/BatteryHolder"]
|
||||
layout_mode = 2
|
||||
max_value = 16.0
|
||||
value = 16.0
|
||||
fill_mode = 3
|
||||
texture_under = ExtResource("2_eow3j")
|
||||
texture_progress = ExtResource("3_j5wjh")
|
||||
tint_progress = Color(0, 1, 0, 1)
|
||||
|
||||
[node name="Camera2D" type="Camera2D" parent="."]
|
||||
anchor_mode = 0
|
||||
script = ExtResource("1_feb5d")
|
||||
|
||||
[node name="TestObstacleSpawner" type="Node2D" parent="Camera2D"]
|
||||
position = Vector2(673, 0)
|
||||
script = ExtResource("6_vef74")
|
||||
|
||||
[node name="Lander" parent="." instance=ExtResource("1_80nbo")]
|
||||
position = Vector2(95, 324)
|
||||
|
||||
|
|
@ -52,4 +99,20 @@ texture = ExtResource("2_e2o6t")
|
|||
position = Vector2(-262.5, 170)
|
||||
shape = SubResource("RectangleShape2D_feb5d")
|
||||
|
||||
[node name="Obstacle" parent="." instance=ExtResource("8_j5wjh")]
|
||||
position = Vector2(240, 265)
|
||||
|
||||
[node name="Obstacle2" parent="." instance=ExtResource("8_j5wjh")]
|
||||
position = Vector2(301, 100)
|
||||
|
||||
[node name="Obstacle3" parent="." instance=ExtResource("8_j5wjh")]
|
||||
position = Vector2(425, 224)
|
||||
|
||||
[node name="Obstacle4" parent="." instance=ExtResource("8_j5wjh")]
|
||||
position = Vector2(582, 320)
|
||||
|
||||
[node name="Obstacle5" parent="." instance=ExtResource("8_j5wjh")]
|
||||
position = Vector2(549, 39)
|
||||
|
||||
[connection signal="moved" from="Lander" to="Camera2D" method="_on_lander_moved"]
|
||||
[connection signal="moved" from="Lander" to="Camera2D/TestObstacleSpawner" method="_on_lander_moved"]
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ config_version=5
|
|||
config/name="Lunar"
|
||||
run/main_scene="uid://hv07lm2tjwn4"
|
||||
config/features=PackedStringArray("4.4", "GL Compatibility")
|
||||
config/icon="res://icon.svg"
|
||||
config/icon="uid://bd5oswedqnenh"
|
||||
|
||||
[display]
|
||||
|
||||
|
|
|
|||
28
test_obstacle_spawner.gd
Normal file
28
test_obstacle_spawner.gd
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
extends Node2D
|
||||
|
||||
var active : bool = false
|
||||
var next_spawn : float = 3
|
||||
var spawn_delay : float = 3
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready() -> void:
|
||||
pass # Replace with function body.
|
||||
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(delta: float) -> void:
|
||||
if active:
|
||||
next_spawn -= delta
|
||||
if next_spawn <= 0:
|
||||
spawn_obstacle()
|
||||
spawn_delay -= spawn_delay * 0.02
|
||||
next_spawn = spawn_delay
|
||||
|
||||
func spawn_obstacle():
|
||||
var randy = randi_range(0,360) #y pos to spawn the new obstacle at
|
||||
var new_obstacle : Node2D = load("res://Prefabs/obstacle.tscn").instantiate()
|
||||
new_obstacle.global_position = Vector2(global_position.x, randy)
|
||||
get_tree().get_root().add_child(new_obstacle)
|
||||
|
||||
func _on_lander_moved() -> void:
|
||||
active = true
|
||||
1
test_obstacle_spawner.gd.uid
Normal file
1
test_obstacle_spawner.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://dd8psfqfobgau
|
||||
Loading…
Add table
Add a link
Reference in a new issue