diff --git a/images/Asteroid 01.png b/images/Asteroid 01.png new file mode 100644 index 0000000..83793ec Binary files /dev/null and b/images/Asteroid 01.png differ diff --git a/images/Asteroid 01.png.import b/images/Asteroid 01.png.import new file mode 100644 index 0000000..28960a1 --- /dev/null +++ b/images/Asteroid 01.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/Asteroid 01.png-c78bce4ff3d472b9f49e822b59740b44.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://images/Asteroid 01.png" +dest_files=[ "res://.import/Asteroid 01.png-c78bce4ff3d472b9f49e822b59740b44.stex" ] + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +compress/hdr_mode=0 +compress/bptc_ldr=0 +compress/normal_map=0 +flags/repeat=0 +flags/filter=true +flags/mipmaps=false +flags/anisotropic=false +flags/srgb=2 +process/fix_alpha_border=true +process/premult_alpha=false +process/HDR_as_SRGB=false +process/invert_color=false +stream=false +size_limit=0 +detect_3d=true +svg/scale=1.0 diff --git a/images/Asteroid 02.png b/images/Asteroid 02.png new file mode 100644 index 0000000..006f1fa Binary files /dev/null and b/images/Asteroid 02.png differ diff --git a/images/Asteroid 02.png.import b/images/Asteroid 02.png.import new file mode 100644 index 0000000..3e84cca --- /dev/null +++ b/images/Asteroid 02.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/Asteroid 02.png-ed66d5bcac39bb2e4cff7b9558a5429b.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://images/Asteroid 02.png" +dest_files=[ "res://.import/Asteroid 02.png-ed66d5bcac39bb2e4cff7b9558a5429b.stex" ] + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +compress/hdr_mode=0 +compress/bptc_ldr=0 +compress/normal_map=0 +flags/repeat=0 +flags/filter=true +flags/mipmaps=false +flags/anisotropic=false +flags/srgb=2 +process/fix_alpha_border=true +process/premult_alpha=false +process/HDR_as_SRGB=false +process/invert_color=false +stream=false +size_limit=0 +detect_3d=true +svg/scale=1.0 diff --git a/images/Asteroid 03.png b/images/Asteroid 03.png new file mode 100644 index 0000000..0258ec1 Binary files /dev/null and b/images/Asteroid 03.png differ diff --git a/images/Asteroid 03.png.import b/images/Asteroid 03.png.import new file mode 100644 index 0000000..b2e9436 --- /dev/null +++ b/images/Asteroid 03.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/Asteroid 03.png-15eac417ed7b8251278ac7b932f9aba9.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://images/Asteroid 03.png" +dest_files=[ "res://.import/Asteroid 03.png-15eac417ed7b8251278ac7b932f9aba9.stex" ] + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +compress/hdr_mode=0 +compress/bptc_ldr=0 +compress/normal_map=0 +flags/repeat=0 +flags/filter=true +flags/mipmaps=false +flags/anisotropic=false +flags/srgb=2 +process/fix_alpha_border=true +process/premult_alpha=false +process/HDR_as_SRGB=false +process/invert_color=false +stream=false +size_limit=0 +detect_3d=true +svg/scale=1.0 diff --git a/images/Asteroid 04.png b/images/Asteroid 04.png new file mode 100644 index 0000000..74293da Binary files /dev/null and b/images/Asteroid 04.png differ diff --git a/images/Asteroid 04.png.import b/images/Asteroid 04.png.import new file mode 100644 index 0000000..95e3c64 --- /dev/null +++ b/images/Asteroid 04.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/Asteroid 04.png-ada08595c1d0e7345470a291b645880e.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://images/Asteroid 04.png" +dest_files=[ "res://.import/Asteroid 04.png-ada08595c1d0e7345470a291b645880e.stex" ] + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +compress/hdr_mode=0 +compress/bptc_ldr=0 +compress/normal_map=0 +flags/repeat=0 +flags/filter=true +flags/mipmaps=false +flags/anisotropic=false +flags/srgb=2 +process/fix_alpha_border=true +process/premult_alpha=false +process/HDR_as_SRGB=false +process/invert_color=false +stream=false +size_limit=0 +detect_3d=true +svg/scale=1.0 diff --git a/images/BG.png b/images/BG.png new file mode 100644 index 0000000..d17e7c4 Binary files /dev/null and b/images/BG.png differ diff --git a/images/BG.png.import b/images/BG.png.import new file mode 100644 index 0000000..7804b26 --- /dev/null +++ b/images/BG.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/BG.png-f26ac8c101decb151beda9632d276caa.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://images/BG.png" +dest_files=[ "res://.import/BG.png-f26ac8c101decb151beda9632d276caa.stex" ] + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +compress/hdr_mode=0 +compress/bptc_ldr=0 +compress/normal_map=0 +flags/repeat=0 +flags/filter=true +flags/mipmaps=false +flags/anisotropic=false +flags/srgb=2 +process/fix_alpha_border=true +process/premult_alpha=false +process/HDR_as_SRGB=false +process/invert_color=false +stream=false +size_limit=0 +detect_3d=true +svg/scale=1.0 diff --git a/project.godot b/project.godot index 77739a3..cba0c28 100644 --- a/project.godot +++ b/project.godot @@ -19,6 +19,14 @@ config/name="space_escape" run/main_scene="res://scenes/Main.tscn" config/icon="res://icon.png" +[display] + +window/size/width=480 +window/size/height=800 +window/handheld/orientation="portrait" +window/stretch/mode="2d" +window/stretch/aspect="keep" + [input] click={ diff --git a/scenes/Astroid1.tscn b/scenes/Astroid1.tscn new file mode 100644 index 0000000..8049a0b --- /dev/null +++ b/scenes/Astroid1.tscn @@ -0,0 +1,15 @@ +[gd_scene load_steps=2 format=2] + +[ext_resource path="res://images/Asteroid 01.png" type="Texture" id=1] + +[node name="Astroid1" type="RigidBody2D"] +gravity_scale = 0.0 +__meta__ = { +"_edit_group_": true +} + +[node name="Astroid" type="Sprite" parent="."] +texture = ExtResource( 1 ) + +[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="."] +polygon = PoolVector2Array( -16.6984, -30.7987, -2.89647, -34.4792, 10.3534, -35.9514, 16.6103, -35.3993, 22.3151, -29.1424, 32.0684, -22.1495, 35.3809, -13.8683, 37.0371, 2.14194, 35.3809, 6.37454, 29.6761, 12.2634, 29.4921, 19.0723, 22.131, 27.5375, 9.06521, 34.1624, 2.44028, 35.4506, -1.24023, 35.8187, -8.41724, 34.1624, -15.4102, 31.4021, -17.8026, 27.3535, -23.3233, 27.9056, -26.6358, 27.7215, -29.2122, 23.4889, -32.8927, 15.9439, -36.7572, 6.74259, -37.3093, 1.03779, -36.7572, -7.79545, -33.8128, -16.4447, -28.108, -23.8057, -20.5629, -30.2466 ) diff --git a/scenes/Astroid2.tscn b/scenes/Astroid2.tscn new file mode 100644 index 0000000..dce4896 --- /dev/null +++ b/scenes/Astroid2.tscn @@ -0,0 +1,19 @@ +[gd_scene load_steps=3 format=2] + +[ext_resource path="res://images/Asteroid 02.png" type="Texture" id=1] + +[sub_resource type="CircleShape2D" id=1] +radius = 20.4766 + +[node name="Astroid2" type="RigidBody2D"] +gravity_scale = 0.0 +__meta__ = { +"_edit_group_": true +} + +[node name="Astroid" type="Sprite" parent="."] +texture = ExtResource( 1 ) +offset = Vector2( 4.41662, -6.80896 ) + +[node name="CollisionShape2D" type="CollisionShape2D" parent="."] +shape = SubResource( 1 ) diff --git a/scenes/Astroid3.tscn b/scenes/Astroid3.tscn new file mode 100644 index 0000000..e851ab6 --- /dev/null +++ b/scenes/Astroid3.tscn @@ -0,0 +1,16 @@ +[gd_scene load_steps=2 format=2] + +[ext_resource path="res://images/Asteroid 03.png" type="Texture" id=1] + +[node name="Astroid3" type="RigidBody2D"] +gravity_scale = 0.0 +__meta__ = { +"_edit_group_": true +} + +[node name="Astroid" type="Sprite" parent="."] +texture = ExtResource( 1 ) +offset = Vector2( 1.65623, -1.65623 ) + +[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="."] +polygon = PoolVector2Array( -18.5387, -29.1424, 6.1208, -33.5591, 15.5061, -34.1111, 20.1068, -31.3508, 34.6448, -5.58714, 32.9886, 0.48571, 25.2595, 25.3292, 14.2179, 29.9298, -11.9137, 35.0826, -18.7227, 33.6104, -21.4831, 31.9541, -33.6288, 8.9509, -34.917, -5.40311, -30.6844, -14.7884, -22.9553, -25.4619 ) diff --git a/scenes/Astroid4.tscn b/scenes/Astroid4.tscn new file mode 100644 index 0000000..ac64d5a --- /dev/null +++ b/scenes/Astroid4.tscn @@ -0,0 +1,20 @@ +[gd_scene load_steps=2 format=2] + +[ext_resource path="res://images/Asteroid 04.png" type="Texture" id=1] + +[node name="Astroid4" type="RigidBody2D"] +gravity_scale = 0.0 +__meta__ = { +"_edit_group_": true, +"_edit_horizontal_guides_": [ -34.5036, -5.13305, 31.5801 ], +"_edit_vertical_guides_": [ -21.0072, 23.9227, -85.8672 ] +} + +[node name="Astroid" type="Sprite" parent="."] +texture = ExtResource( 1 ) +offset = Vector2( 1.3986, -0.524475 ) + +[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="."] +polygon = PoolVector2Array( -10, -34.5036, -1.25207, -32.7553, 3.29337, -30.3078, 10.8108, -24.1889, 20.7758, -18.5945, 37.2094, -8.62954, 41.4051, -2.6855, 43.8527, 2.20959, 42.9786, 9.90187, 38.9576, 17.4193, 27.4192, 29.1326, 22.8737, 32.6291, 18.3283, 31.7549, 9.76189, 28.0836, 3.29337, 24.0627, 0.32135, 22.4892, -4.57374, 24.2375, -12.6157, 28.4333, -18.0352, 31.2305, -21.1821, 31.5801, -25.203, 30.5312, -30.7974, 24.2375, -34.6436, 18.1186, -39.3638, 8.6781, -41.9862, -0.587605, -41.4617, -5.83234, -36.3918, -13.5246, -27.4758, -22.9652, -20.6576, -29.2588, -16.9863, -33.105, -13.315, -35.0281 ) + +[node name="VisibilityNotifier2D" type="VisibilityNotifier2D" parent="."] diff --git a/scenes/BigAstroid.tscn b/scenes/BigAstroid.tscn deleted file mode 100644 index ccdb757..0000000 --- a/scenes/BigAstroid.tscn +++ /dev/null @@ -1,34 +0,0 @@ -[gd_scene load_steps=5 format=2] - -[ext_resource path="res://images/pixel_asteroid.png" type="Texture" id=1] -[ext_resource path="res://images/asteroid_grey.png" type="Texture" id=2] - -[sub_resource type="SpriteFrames" id=1] -animations = [ { -"frames": [ ExtResource( 1 ) ], -"loop": false, -"name": "yellow", -"speed": 5.0 -}, { -"frames": [ ExtResource( 2 ) ], -"loop": true, -"name": "grey", -"speed": 5.0 -} ] - -[sub_resource type="CircleShape2D" id=2] -radius = 30.0 - -[node name="BigAstroid" type="RigidBody2D"] -gravity_scale = 0.0 -__meta__ = { -"_edit_group_": true -} - -[node name="AnimatedSprite" type="AnimatedSprite" parent="."] -scale = Vector2( 0.75, 0.75 ) -frames = SubResource( 1 ) -animation = "grey" - -[node name="CollisionShape2D" type="CollisionShape2D" parent="."] -shape = SubResource( 2 ) diff --git a/scenes/Main.gd b/scenes/Main.gd new file mode 100644 index 0000000..0b2875e --- /dev/null +++ b/scenes/Main.gd @@ -0,0 +1,50 @@ +extends Node + +export (PackedScene) var Astroid1 +export (PackedScene) var Astroid2 +export (PackedScene) var Astroid3 +export (PackedScene) var Astroid4 +export (int) var astroid_min_speed = 100 +export (int) var astroid_max_speed = 400 + +var astroids = [] + +var score + +func _ready(): + # Sense are loaded now + astroids = [Astroid1, Astroid2, Astroid3, Astroid4] + new_game() + +func new_game(): + score = 0 + #$Music.play() + # $HUD.update_score(score) + # $HUD.show_message("Get Ready") + $Player.start($StartPosition.position) + $StartTimer.start() + $AstroidTimer.start() + + +func _on_AstroidTimer_timeout(): + # Choose a random location on Path2D. + $ScreenEadge/Follow.set_offset(randi()) + # Create an astroid instance and add it to the scene. + var astroid = astroids[randi() % 4].instance() + + add_child(astroid) + + #$HUD.connect("start_game", astroid, "_on_start_game") + + # Set the astroid's direction perpendicular to the path direction. + var direction = $ScreenEadge/Follow.rotation + PI / 2 + # Set the astroid's position to a random location. + astroid.position = $ScreenEadge/Follow.position + + # Add some randomness to the direction. + direction += rand_range(-PI / 4, PI / 4) + astroid.rotation = direction + + # Set the velocity (speed & direction). + astroid.linear_velocity = Vector2(rand_range(astroid_min_speed, astroid_max_speed), 0) + astroid.linear_velocity = astroid.linear_velocity.rotated(direction) diff --git a/scenes/Main.tscn b/scenes/Main.tscn index 8dec5a0..8cc9ef6 100644 --- a/scenes/Main.tscn +++ b/scenes/Main.tscn @@ -1,14 +1,47 @@ -[gd_scene load_steps=2 format=2] +[gd_scene load_steps=9 format=2] -[ext_resource path="res://scenes/Player.tscn" type="PackedScene" id=1] +[ext_resource path="res://scenes/Main.gd" type="Script" id=1] +[ext_resource path="res://scenes/Astroid1.tscn" type="PackedScene" id=2] +[ext_resource path="res://scenes/Astroid2.tscn" type="PackedScene" id=3] +[ext_resource path="res://scenes/Astroid3.tscn" type="PackedScene" id=4] +[ext_resource path="res://scenes/Astroid4.tscn" type="PackedScene" id=5] +[ext_resource path="res://images/BG.png" type="Texture" id=6] +[ext_resource path="res://scenes/Player.tscn" type="PackedScene" id=7] + +[sub_resource type="Curve2D" id=1] +_data = { +"points": PoolVector2Array( 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 480, 0, 0, 0, 0, 0, 480, 800, 0, 0, 0, 0, 0, 800, 0, 0, 0, 0, 0, 0 ) +} [node name="Main" type="Node"] +script = ExtResource( 1 ) +Astroid1 = ExtResource( 2 ) +Astroid2 = ExtResource( 3 ) +Astroid3 = ExtResource( 4 ) +Astroid4 = ExtResource( 5 ) [node name="background" type="ParallaxBackground" parent="."] [node name="ParallaxLayer" type="ParallaxLayer" parent="background"] -[node name="Player" parent="." instance=ExtResource( 1 )] -position = Vector2( 490, 190 ) +[node name="TextureRect" type="TextureRect" parent="background/ParallaxLayer"] +margin_left = -100.0 +margin_right = 600.0 +margin_bottom = 800.0 +texture = ExtResource( 6 ) + +[node name="Player" parent="." instance=ExtResource( 7 )] +position = Vector2( 160, 70 ) [node name="StartPosition" type="Position2D" parent="."] +position = Vector2( 240, 400 ) + +[node name="ScreenEadge" type="Path2D" parent="."] +curve = SubResource( 1 ) + +[node name="Follow" type="PathFollow2D" parent="ScreenEadge"] + +[node name="AstroidTimer" type="Timer" parent="."] + +[node name="StartTimer" type="Timer" parent="."] +[connection signal="timeout" from="AstroidTimer" to="." method="_on_AstroidTimer_timeout"] diff --git a/scenes/Player.gd b/scenes/Player.gd index b26ebb3..161158b 100644 --- a/scenes/Player.gd +++ b/scenes/Player.gd @@ -1,10 +1,10 @@ extends KinematicBody2D # How fast the player will move (pixels/sec). -export (int) var max_speed = 600 -export (float) var start_acceleration = 0.075 -export (float) var stop_friction = 0.03 - +export (int) var max_speed = 400 +export (float) var start_acceleration = 0.065 +export (float) var stop_friction = 0.02 +export (int) var touch_distance_limit = 30 # Size of the game window. var screen_size var speed = 0 @@ -54,8 +54,9 @@ func _input(event): released = true func _physics_process(delta): - rotation = velocity.angle() - velocity = move_and_slide(velocity) + if (touch_point - position).length() > touch_distance_limit: + rotation = velocity.angle() + velocity = move_and_slide(velocity) func _on_Player_body_entered(body): diff --git a/scenes/Player.tscn b/scenes/Player.tscn index a227209..126e8d3 100644 --- a/scenes/Player.tscn +++ b/scenes/Player.tscn @@ -31,17 +31,16 @@ animations = [ { } ] [sub_resource type="ConvexPolygonShape2D" id=2] -points = PoolVector2Array( -20, -5, -15, -20, -5, -20, 20, 0, -5, 20, -15, 20, -20, 5 ) +points = PoolVector2Array( -25, -4, -18, -25, -9, -28, 33, 0, -9, 28, -18, 25, -25, 4 ) [node name="Player" type="KinematicBody2D"] script = ExtResource( 1 ) __meta__ = { -"_edit_horizontal_guides_": [ -43.9838 ], -"_edit_vertical_guides_": [ -22.5089 ] +"_edit_horizontal_guides_": [ ], +"_edit_vertical_guides_": [ 33.5225 ] } [node name="Ship" type="AnimatedSprite" parent="."] -position = Vector2( 0, -1 ) rotation = 1.5708 scale = Vector2( 0.5, 0.5 ) frames = SubResource( 1 ) @@ -55,6 +54,5 @@ frames = SubResource( 3 ) animation = "burst" [node name="CollisionShape2D" type="CollisionShape2D" parent="."] -position = Vector2( 0, -1 ) shape = SubResource( 2 ) [connection signal="animation_finished" from="Burst" to="." method="_on_Burst_animation_finished"]