make game more like a real game
This commit is contained in:
parent
73ddb8e6dc
commit
fce540a122
9 changed files with 55 additions and 78 deletions
|
@ -1,3 +1,3 @@
|
||||||
source_md5="5438542557626c9814ef2162a19e2908"
|
source_md5="5438542557626c9814ef2162a19e2908"
|
||||||
dest_md5="0ef11008070ef53cd0839c6e85118d97"
|
dest_md5="9d76f2a502b40f58f15d6243d8d732d4"
|
||||||
|
|
||||||
|
|
Binary file not shown.
14
Camera2D.gd
14
Camera2D.gd
|
@ -6,13 +6,15 @@ onready var screen_size = Vector2(ProjectSettings.get("display/window/size/width
|
||||||
onready var player = get_node("Player")
|
onready var player = get_node("Player")
|
||||||
onready var bg = get_node("Background")
|
onready var bg = get_node("Background")
|
||||||
|
|
||||||
export var tower_density = 200
|
export var tower_density = 250
|
||||||
var last_built = 300
|
var last_built = 500
|
||||||
|
|
||||||
func build_tower():
|
func build_tower():
|
||||||
var tower = Tower.instance()
|
var tower = Tower.instance()
|
||||||
tower.connect("exit", self, "_on_Tower_exit")
|
tower.connect("exit", self, "_on_Tower_exit")
|
||||||
var pos = Vector2(last_built, randf() * (screen_size.y - 200) - screen_size.y / 2 + 100) # The player's movement vector.
|
|
||||||
|
var pos = Vector2(last_built, (randf() * (screen_size.y * 0.7)) + screen_size.y * 0.15) # The player's movement vector.
|
||||||
|
|
||||||
tower.position = pos
|
tower.position = pos
|
||||||
|
|
||||||
add_child(tower)
|
add_child(tower)
|
||||||
|
@ -29,14 +31,10 @@ func update_view():
|
||||||
|
|
||||||
func _ready():
|
func _ready():
|
||||||
randomize()
|
randomize()
|
||||||
update_view()
|
|
||||||
|
|
||||||
print(screen_size)
|
print(screen_size)
|
||||||
while last_built < screen_size.x * 2:
|
while last_built < screen_size.x * 3:
|
||||||
build_tower()
|
build_tower()
|
||||||
|
|
||||||
func _on_Player_move():
|
|
||||||
update_view()
|
|
||||||
|
|
||||||
func _on_Tower_exit():
|
func _on_Tower_exit():
|
||||||
build_tower()
|
build_tower()
|
||||||
|
|
35
Main.tscn
35
Main.tscn
|
@ -1,21 +1,30 @@
|
||||||
[gd_scene load_steps=4 format=2]
|
[gd_scene load_steps=5 format=2]
|
||||||
|
|
||||||
[ext_resource path="res://Camera2D.gd" type="Script" id=1]
|
[ext_resource path="res://Camera2D.gd" type="Script" id=1]
|
||||||
[ext_resource path="res://icon.png" type="Texture" id=2]
|
[ext_resource path="res://Player.tscn" type="PackedScene" id=2]
|
||||||
[ext_resource path="res://Player.tscn" type="PackedScene" id=3]
|
[ext_resource path="res://res/sprites.png" type="Texture" id=3]
|
||||||
|
|
||||||
[node name="View" type="Node"]
|
[sub_resource type="AtlasTexture" id=1]
|
||||||
|
atlas = ExtResource( 3 )
|
||||||
|
region = Rect2( 0, 0, 144, 256 )
|
||||||
|
|
||||||
|
[node name="View" type="Node2D"]
|
||||||
script = ExtResource( 1 )
|
script = ExtResource( 1 )
|
||||||
|
|
||||||
[node name="Background" type="Sprite" parent="."]
|
[node name="Player" parent="." instance=ExtResource( 2 )]
|
||||||
position = Vector2( 774.747, 318.138 )
|
position = Vector2( 210, 320 )
|
||||||
scale = Vector2( 10, 10 )
|
|
||||||
texture = ExtResource( 2 )
|
|
||||||
region_enabled = true
|
|
||||||
region_rect = Rect2( 0, 0, 144, 256 )
|
|
||||||
|
|
||||||
[node name="Player" parent="." instance=ExtResource( 3 )]
|
|
||||||
position = Vector2( 155.182, -2.28882e-05 )
|
|
||||||
gravity = 0.0
|
gravity = 0.0
|
||||||
collision_layer = 0
|
collision_layer = 0
|
||||||
|
|
||||||
|
[node name="ParallaxBackground" type="ParallaxBackground" parent="."]
|
||||||
|
|
||||||
|
[node name="ParallaxLayer" type="ParallaxLayer" parent="ParallaxBackground"]
|
||||||
|
motion_scale = Vector2( 0.5, 1 )
|
||||||
|
motion_mirroring = Vector2( 420, 0 )
|
||||||
|
|
||||||
|
[node name="Background" type="Sprite" parent="ParallaxBackground/ParallaxLayer"]
|
||||||
|
position = Vector2( 209.839, 320 )
|
||||||
|
scale = Vector2( 2.91891, 2.5 )
|
||||||
|
texture = SubResource( 1 )
|
||||||
|
region_rect = Rect2( 0, 0, 144, 256 )
|
||||||
[connection signal="move" from="Player" to="." method="_on_Player_move"]
|
[connection signal="move" from="Player" to="." method="_on_Player_move"]
|
||||||
|
|
|
@ -34,12 +34,10 @@ func _process(delta):
|
||||||
|
|
||||||
position += Vector2(speed, speed_y * speed)
|
position += Vector2(speed, speed_y * speed)
|
||||||
|
|
||||||
emit_signal("move")
|
|
||||||
|
|
||||||
# TODO find the correct rotation, noob
|
# TODO find the correct rotation, noob
|
||||||
rotation = atan(speed_y / speed) + PI / 2
|
rotation = atan(speed_y / speed)
|
||||||
|
|
||||||
if position.y > screen_size.y / 2 - 100:
|
if position.y > screen_size.y:
|
||||||
emit_signal("hit")
|
emit_signal("hit")
|
||||||
print(position)
|
print(position)
|
||||||
playing = false
|
playing = false
|
||||||
|
|
67
Player.tscn
67
Player.tscn
|
@ -1,51 +1,31 @@
|
||||||
[gd_scene load_steps=5 format=2]
|
[gd_scene load_steps=6 format=2]
|
||||||
|
|
||||||
[ext_resource path="res://Player.gd" type="Script" id=1]
|
[ext_resource path="res://Player.gd" type="Script" id=1]
|
||||||
[ext_resource path="res://res/sprites.png" type="Texture" id=2]
|
[ext_resource path="res://res/sprites.png" type="Texture" id=2]
|
||||||
|
|
||||||
[sub_resource type="CapsuleShape2D" id=2]
|
[sub_resource type="CapsuleShape2D" id=1]
|
||||||
radius = 12.8837
|
radius = 12.8837
|
||||||
height = 4.07484
|
height = 4.07484
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id=2]
|
||||||
|
atlas = ExtResource( 2 )
|
||||||
|
region = Rect2( -4, 488, 84, 16 )
|
||||||
|
|
||||||
[sub_resource type="Animation" id=3]
|
[sub_resource type="Animation" id=3]
|
||||||
resource_name = "fly"
|
length = 0.8
|
||||||
length = 0.4
|
|
||||||
loop = true
|
loop = true
|
||||||
|
step = 0.2
|
||||||
tracks/0/type = "value"
|
tracks/0/type = "value"
|
||||||
tracks/0/path = NodePath("Sprite1:frame")
|
tracks/0/path = NodePath("Node2D/Sprite1:frame")
|
||||||
tracks/0/interp = 1
|
tracks/0/interp = 1
|
||||||
tracks/0/loop_wrap = true
|
tracks/0/loop_wrap = true
|
||||||
tracks/0/imported = false
|
tracks/0/imported = false
|
||||||
tracks/0/enabled = true
|
tracks/0/enabled = true
|
||||||
tracks/0/keys = {
|
tracks/0/keys = {
|
||||||
"times": PoolRealArray( 0 ),
|
"times": PoolRealArray( 0, 0.2, 0.4, 0.6 ),
|
||||||
"transitions": PoolRealArray( 1 ),
|
"transitions": PoolRealArray( 1, 1, 1, 1 ),
|
||||||
"update": 1,
|
"update": 1,
|
||||||
"values": [ 0 ]
|
"values": [ 1, 2, 1, 0 ]
|
||||||
}
|
|
||||||
tracks/1/type = "value"
|
|
||||||
tracks/1/path = NodePath("Sprite2:frame")
|
|
||||||
tracks/1/interp = 1
|
|
||||||
tracks/1/loop_wrap = true
|
|
||||||
tracks/1/imported = false
|
|
||||||
tracks/1/enabled = true
|
|
||||||
tracks/1/keys = {
|
|
||||||
"times": PoolRealArray( 0.1, 0.3 ),
|
|
||||||
"transitions": PoolRealArray( 1, 1 ),
|
|
||||||
"update": 1,
|
|
||||||
"values": [ 0, 0 ]
|
|
||||||
}
|
|
||||||
tracks/2/type = "value"
|
|
||||||
tracks/2/path = NodePath("Sprite3:frame")
|
|
||||||
tracks/2/interp = 1
|
|
||||||
tracks/2/loop_wrap = true
|
|
||||||
tracks/2/imported = false
|
|
||||||
tracks/2/enabled = true
|
|
||||||
tracks/2/keys = {
|
|
||||||
"times": PoolRealArray( 0.2 ),
|
|
||||||
"transitions": PoolRealArray( 1 ),
|
|
||||||
"update": 1,
|
|
||||||
"values": [ 0 ]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[node name="Player" type="Area2D"]
|
[node name="Player" type="Area2D"]
|
||||||
|
@ -57,28 +37,23 @@ __meta__ = {
|
||||||
|
|
||||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||||
rotation = 1.5708
|
rotation = 1.5708
|
||||||
shape = SubResource( 2 )
|
shape = SubResource( 1 )
|
||||||
|
|
||||||
[node name="Node2D" type="Node2D" parent="."]
|
[node name="Node2D" type="Node2D" parent="."]
|
||||||
scale = Vector2( 2, 2 )
|
scale = Vector2( 2, 2 )
|
||||||
|
|
||||||
[node name="Sprite1" type="Sprite" parent="Node2D"]
|
[node name="Sprite1" type="Sprite" parent="Node2D"]
|
||||||
texture = ExtResource( 2 )
|
texture = SubResource( 2 )
|
||||||
region_enabled = true
|
hframes = 3
|
||||||
region_rect = Rect2( 3, 491, 17, 12 )
|
frame = 1
|
||||||
|
|
||||||
[node name="Sprite2" type="Sprite" parent="Node2D"]
|
|
||||||
texture = ExtResource( 2 )
|
|
||||||
region_enabled = true
|
|
||||||
region_rect = Rect2( 31, 491, 17, 12 )
|
|
||||||
|
|
||||||
[node name="Sprite3" type="Sprite" parent="Node2D"]
|
|
||||||
texture = ExtResource( 2 )
|
|
||||||
region_enabled = true
|
|
||||||
region_rect = Rect2( 59, 491, 17, 12 )
|
|
||||||
|
|
||||||
[node name="AnimationPlayer" type="AnimationPlayer" parent="Node2D"]
|
[node name="AnimationPlayer" type="AnimationPlayer" parent="Node2D"]
|
||||||
root_node = NodePath("../..")
|
root_node = NodePath("../..")
|
||||||
autoplay = "fly"
|
autoplay = "fly"
|
||||||
anims/fly = SubResource( 3 )
|
anims/fly = SubResource( 3 )
|
||||||
|
|
||||||
|
[node name="Camera2D" type="Camera2D" parent="."]
|
||||||
|
current = true
|
||||||
|
limit_top = 0
|
||||||
|
limit_bottom = 0
|
||||||
[connection signal="body_entered" from="." to="." method="_on_Player_body_entered"]
|
[connection signal="body_entered" from="." to="." method="_on_Player_body_entered"]
|
||||||
|
|
5
Tower.gd
5
Tower.gd
|
@ -9,15 +9,10 @@ signal exit
|
||||||
func _ready():
|
func _ready():
|
||||||
pass # Replace with function body.
|
pass # Replace with function body.
|
||||||
|
|
||||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
|
||||||
#func _process(delta):
|
|
||||||
# pass
|
|
||||||
|
|
||||||
func _on_Tower_body_entered(body):
|
func _on_Tower_body_entered(body):
|
||||||
print("HIT HERE")
|
print("HIT HERE")
|
||||||
pass # Replace with function body.
|
pass # Replace with function body.
|
||||||
|
|
||||||
func _on_Visibility_screen_exited():
|
func _on_Visibility_screen_exited():
|
||||||
print("Leaving")
|
|
||||||
queue_free()
|
queue_free()
|
||||||
emit_signal("exit")
|
emit_signal("exit")
|
||||||
|
|
|
@ -23,6 +23,8 @@ config/icon="res://icon.png"
|
||||||
|
|
||||||
window/size/width=420
|
window/size/width=420
|
||||||
window/size/height=640
|
window/size/height=640
|
||||||
|
window/handheld/orientation="portrait"
|
||||||
|
window/stretch/mode="viewport"
|
||||||
|
|
||||||
[physics]
|
[physics]
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@ compress/hdr_mode=0
|
||||||
compress/bptc_ldr=0
|
compress/bptc_ldr=0
|
||||||
compress/normal_map=0
|
compress/normal_map=0
|
||||||
flags/repeat=0
|
flags/repeat=0
|
||||||
flags/filter=true
|
flags/filter=false
|
||||||
flags/mipmaps=false
|
flags/mipmaps=false
|
||||||
flags/anisotropic=false
|
flags/anisotropic=false
|
||||||
flags/srgb=2
|
flags/srgb=2
|
||||||
|
|
Loading…
Reference in a new issue