Random astroid generation has been done
This commit is contained in:
parent
2f2da423d2
commit
ca6edf47ee
Binary file not shown.
After Width: | Height: | Size: 11 KiB |
|
@ -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
|
Binary file not shown.
After Width: | Height: | Size: 5.5 KiB |
|
@ -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
|
Binary file not shown.
After Width: | Height: | Size: 9.1 KiB |
|
@ -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
|
Binary file not shown.
After Width: | Height: | Size: 20 KiB |
|
@ -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
|
Binary file not shown.
After Width: | Height: | Size: 304 KiB |
|
@ -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
|
|
@ -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={
|
||||
|
|
|
@ -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 )
|
|
@ -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 )
|
|
@ -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 )
|
|
@ -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="."]
|
|
@ -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 )
|
|
@ -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)
|
|
@ -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"]
|
||||
|
|
|
@ -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):
|
||||
|
|
|
@ -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"]
|
||||
|
|
Loading…
Reference in New Issue