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"
|
||||
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 bg = get_node("Background")
|
||||
|
||||
export var tower_density = 200
|
||||
var last_built = 300
|
||||
export var tower_density = 250
|
||||
var last_built = 500
|
||||
|
||||
func build_tower():
|
||||
var tower = Tower.instance()
|
||||
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
|
||||
|
||||
add_child(tower)
|
||||
|
@ -29,14 +31,10 @@ func update_view():
|
|||
|
||||
func _ready():
|
||||
randomize()
|
||||
update_view()
|
||||
|
||||
print(screen_size)
|
||||
while last_built < screen_size.x * 2:
|
||||
while last_built < screen_size.x * 3:
|
||||
build_tower()
|
||||
|
||||
func _on_Player_move():
|
||||
update_view()
|
||||
|
||||
func _on_Tower_exit():
|
||||
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://icon.png" type="Texture" id=2]
|
||||
[ext_resource path="res://Player.tscn" type="PackedScene" id=3]
|
||||
[ext_resource path="res://Player.tscn" type="PackedScene" id=2]
|
||||
[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 )
|
||||
|
||||
[node name="Background" type="Sprite" parent="."]
|
||||
position = Vector2( 774.747, 318.138 )
|
||||
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 )
|
||||
[node name="Player" parent="." instance=ExtResource( 2 )]
|
||||
position = Vector2( 210, 320 )
|
||||
gravity = 0.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"]
|
||||
|
|
|
@ -34,12 +34,10 @@ func _process(delta):
|
|||
|
||||
position += Vector2(speed, speed_y * speed)
|
||||
|
||||
emit_signal("move")
|
||||
|
||||
# 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")
|
||||
print(position)
|
||||
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://res/sprites.png" type="Texture" id=2]
|
||||
|
||||
[sub_resource type="CapsuleShape2D" id=2]
|
||||
[sub_resource type="CapsuleShape2D" id=1]
|
||||
radius = 12.8837
|
||||
height = 4.07484
|
||||
|
||||
[sub_resource type="AtlasTexture" id=2]
|
||||
atlas = ExtResource( 2 )
|
||||
region = Rect2( -4, 488, 84, 16 )
|
||||
|
||||
[sub_resource type="Animation" id=3]
|
||||
resource_name = "fly"
|
||||
length = 0.4
|
||||
length = 0.8
|
||||
loop = true
|
||||
step = 0.2
|
||||
tracks/0/type = "value"
|
||||
tracks/0/path = NodePath("Sprite1:frame")
|
||||
tracks/0/path = NodePath("Node2D/Sprite1:frame")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/keys = {
|
||||
"times": PoolRealArray( 0 ),
|
||||
"transitions": PoolRealArray( 1 ),
|
||||
"times": PoolRealArray( 0, 0.2, 0.4, 0.6 ),
|
||||
"transitions": PoolRealArray( 1, 1, 1, 1 ),
|
||||
"update": 1,
|
||||
"values": [ 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 ]
|
||||
"values": [ 1, 2, 1, 0 ]
|
||||
}
|
||||
|
||||
[node name="Player" type="Area2D"]
|
||||
|
@ -57,28 +37,23 @@ __meta__ = {
|
|||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||
rotation = 1.5708
|
||||
shape = SubResource( 2 )
|
||||
shape = SubResource( 1 )
|
||||
|
||||
[node name="Node2D" type="Node2D" parent="."]
|
||||
scale = Vector2( 2, 2 )
|
||||
|
||||
[node name="Sprite1" type="Sprite" parent="Node2D"]
|
||||
texture = ExtResource( 2 )
|
||||
region_enabled = true
|
||||
region_rect = Rect2( 3, 491, 17, 12 )
|
||||
|
||||
[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 )
|
||||
texture = SubResource( 2 )
|
||||
hframes = 3
|
||||
frame = 1
|
||||
|
||||
[node name="AnimationPlayer" type="AnimationPlayer" parent="Node2D"]
|
||||
root_node = NodePath("../..")
|
||||
autoplay = "fly"
|
||||
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"]
|
||||
|
|
5
Tower.gd
5
Tower.gd
|
@ -9,15 +9,10 @@ signal exit
|
|||
func _ready():
|
||||
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):
|
||||
print("HIT HERE")
|
||||
pass # Replace with function body.
|
||||
|
||||
func _on_Visibility_screen_exited():
|
||||
print("Leaving")
|
||||
queue_free()
|
||||
emit_signal("exit")
|
||||
|
|
|
@ -23,6 +23,8 @@ config/icon="res://icon.png"
|
|||
|
||||
window/size/width=420
|
||||
window/size/height=640
|
||||
window/handheld/orientation="portrait"
|
||||
window/stretch/mode="viewport"
|
||||
|
||||
[physics]
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ compress/hdr_mode=0
|
|||
compress/bptc_ldr=0
|
||||
compress/normal_map=0
|
||||
flags/repeat=0
|
||||
flags/filter=true
|
||||
flags/filter=false
|
||||
flags/mipmaps=false
|
||||
flags/anisotropic=false
|
||||
flags/srgb=2
|
||||
|
|
Loading…
Reference in a new issue