diff --git a/2d/dodge_the_creeps/Button.gd b/2d/dodge_the_creeps/Button.gd deleted file mode 100644 index f8716d73..00000000 --- a/2d/dodge_the_creeps/Button.gd +++ /dev/null @@ -1,7 +0,0 @@ -extends Button - -func _on_Button_pressed() -> void: - if Input.is_mouse_button_pressed(BUTTON_LEFT): - print("Left mouse button") - if Input.is_mouse_button_pressed(BUTTON_RIGHT): - print("Right mouse button") diff --git a/2d/dodge_the_creeps/HUD.gd b/2d/dodge_the_creeps/HUD.gd index 95036689..e817a4bc 100644 --- a/2d/dodge_the_creeps/HUD.gd +++ b/2d/dodge_the_creeps/HUD.gd @@ -7,6 +7,7 @@ func show_message(text): $MessageLabel.show() $MessageTimer.start() + func show_game_over(): show_message("Game Over") yield($MessageTimer, "timeout") @@ -15,12 +16,15 @@ func show_game_over(): yield(get_tree().create_timer(1), 'timeout') $StartButton.show() + func update_score(score): $ScoreLabel.text = str(score) + func _on_StartButton_pressed(): $StartButton.hide() emit_signal("start_game") + func _on_MessageTimer_timeout(): - $MessageLabel.hide() \ No newline at end of file + $MessageLabel.hide() diff --git a/2d/dodge_the_creeps/HUD.tscn b/2d/dodge_the_creeps/HUD.tscn index 76538603..fc641e95 100644 --- a/2d/dodge_the_creeps/HUD.tscn +++ b/2d/dodge_the_creeps/HUD.tscn @@ -4,21 +4,17 @@ [ext_resource path="res://fonts/Xolonium-Regular.ttf" type="DynamicFontData" id=2] [sub_resource type="DynamicFont" id=1] - size = 64 font_data = ExtResource( 2 ) [sub_resource type="DynamicFont" id=2] - size = 64 font_data = ExtResource( 2 ) [sub_resource type="InputEventAction" id=3] - action = "ui_select" [sub_resource type="ShortCut" id=4] - shortcut = SubResource( 3 ) [node name="HUD" type="CanvasLayer"] @@ -57,6 +53,5 @@ text = "Start" [node name="MessageTimer" type="Timer" parent="."] one_shot = true - [connection signal="pressed" from="StartButton" to="." method="_on_StartButton_pressed"] [connection signal="timeout" from="MessageTimer" to="." method="_on_MessageTimer_timeout"] diff --git a/2d/dodge_the_creeps/Main.gd b/2d/dodge_the_creeps/Main.gd index 766660d6..ceea43d6 100644 --- a/2d/dodge_the_creeps/Main.gd +++ b/2d/dodge_the_creeps/Main.gd @@ -6,6 +6,7 @@ var score func _ready(): randomize() + func game_over(): $ScoreTimer.stop() $MobTimer.stop() @@ -13,6 +14,7 @@ func game_over(): $Music.stop() $DeathSound.play() + func new_game(): score = 0 $Player.start($StartPosition.position) @@ -21,20 +23,23 @@ func new_game(): $HUD.show_message("Get Ready") $Music.play() + func _on_MobTimer_timeout(): $MobPath/MobSpawnLocation.offset = randi() var mob = Mob.instance() add_child(mob) - var direction = $MobPath/MobSpawnLocation.rotation + PI/2 + var direction = $MobPath/MobSpawnLocation.rotation + PI / 2 mob.position = $MobPath/MobSpawnLocation.position - direction += rand_range(-PI/4, PI/4) + direction += rand_range(-PI / 4, PI / 4) mob.rotation = direction mob.linear_velocity = Vector2(rand_range(mob.min_speed, mob.max_speed), 0).rotated(direction) + func _on_ScoreTimer_timeout(): score += 1 $HUD.update_score(score) + func _on_StartTimer_timeout(): $MobTimer.start() - $ScoreTimer.start() \ No newline at end of file + $ScoreTimer.start() diff --git a/2d/dodge_the_creeps/Main.tscn b/2d/dodge_the_creeps/Main.tscn index 8ee9a5c2..54d0a238 100644 --- a/2d/dodge_the_creeps/Main.tscn +++ b/2d/dodge_the_creeps/Main.tscn @@ -9,7 +9,7 @@ [sub_resource type="Curve2D" id=1] _data = { -"points": PoolVector2Array( 0, 0, 0, 0, -0.901337, 0.225891, 0, 0, 0, 0, 480.262, 1.29041, 0, 0, 0, 0, 481.327, 700.681, 0, 0, 0, 0, 0.163177, 698.552, 0, 0, 0, 0, -0.901337, 0.225891 ) +"points": PoolVector2Array( 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 480, 0, 0, 0, 0, 0, 480, 720, 0, 0, 0, 0, 0, 720, 0, 0, 0, 0, 0, 0 ) } [node name="Main" type="Node"] @@ -19,7 +19,7 @@ Mob = ExtResource( 2 ) [node name="ColorRect" type="ColorRect" parent="."] anchor_right = 1.0 anchor_bottom = 1.0 -color = Color( 0.223529, 0.317647, 0.368627, 1 ) +color = Color( 0.219608, 0.372549, 0.380392, 1 ) [node name="Player" parent="." instance=ExtResource( 3 )] @@ -39,8 +39,6 @@ position = Vector2( 240, 450 ) curve = SubResource( 1 ) [node name="MobSpawnLocation" type="PathFollow2D" parent="MobPath"] -position = Vector2( -0.901337, 0.225891 ) -rotation = 0.00221238 [node name="HUD" parent="." instance=ExtResource( 4 )] @@ -49,7 +47,6 @@ stream = ExtResource( 5 ) [node name="DeathSound" type="AudioStreamPlayer" parent="."] stream = ExtResource( 6 ) - [connection signal="hit" from="Player" to="." method="game_over"] [connection signal="timeout" from="MobTimer" to="." method="_on_MobTimer_timeout"] [connection signal="timeout" from="ScoreTimer" to="." method="_on_ScoreTimer_timeout"] diff --git a/2d/dodge_the_creeps/Mob.gd b/2d/dodge_the_creeps/Mob.gd index f9dc4aa4..b8ad51cf 100644 --- a/2d/dodge_the_creeps/Mob.gd +++ b/2d/dodge_the_creeps/Mob.gd @@ -1,5 +1,6 @@ extends RigidBody2D +#warning-ignore-all:unused_class_variable export var min_speed = 150 export var max_speed = 250 var mob_types = ["walk", "swim", "fly"] @@ -7,5 +8,6 @@ var mob_types = ["walk", "swim", "fly"] func _ready(): $AnimatedSprite.animation = mob_types[randi() % mob_types.size()] + func _on_VisibilityNotifier2D_screen_exited(): - queue_free() \ No newline at end of file + queue_free() diff --git a/2d/dodge_the_creeps/Mob.tscn b/2d/dodge_the_creeps/Mob.tscn index e34054d8..7d1dc4f9 100644 --- a/2d/dodge_the_creeps/Mob.tscn +++ b/2d/dodge_the_creeps/Mob.tscn @@ -1,20 +1,19 @@ [gd_scene load_steps=10 format=2] [ext_resource path="res://Mob.gd" type="Script" id=1] -[ext_resource path="res://art/enemySwimming_1.png" type="Texture" id=2] -[ext_resource path="res://art/enemySwimming_2.png" type="Texture" id=3] +[ext_resource path="res://art/enemyFlyingAlt_1.png" type="Texture" id=2] +[ext_resource path="res://art/enemyFlyingAlt_2.png" type="Texture" id=3] [ext_resource path="res://art/enemyWalking_1.png" type="Texture" id=4] [ext_resource path="res://art/enemyWalking_2.png" type="Texture" id=5] -[ext_resource path="res://art/enemyFlyingAlt_1.png" type="Texture" id=6] -[ext_resource path="res://art/enemyFlyingAlt_2.png" type="Texture" id=7] +[ext_resource path="res://art/enemySwimming_1.png" type="Texture" id=6] +[ext_resource path="res://art/enemySwimming_2.png" type="Texture" id=7] [sub_resource type="SpriteFrames" id=1] - animations = [ { "frames": [ ExtResource( 2 ), ExtResource( 3 ) ], "loop": true, -"name": "swim", -"speed": 4.0 +"name": "fly", +"speed": 3.0 }, { "frames": [ ExtResource( 4 ), ExtResource( 5 ) ], "loop": true, @@ -23,12 +22,11 @@ animations = [ { }, { "frames": [ ExtResource( 6 ), ExtResource( 7 ) ], "loop": true, -"name": "fly", -"speed": 3.0 +"name": "swim", +"speed": 4.0 } ] [sub_resource type="CapsuleShape2D" id=2] - radius = 35.2706 height = 23.3281 @@ -44,6 +42,7 @@ __meta__ = { scale = Vector2( 0.75, 0.75 ) frames = SubResource( 1 ) animation = "walk" +frame = 1 playing = true [node name="CollisionShape2D" type="CollisionShape2D" parent="."] @@ -51,5 +50,4 @@ rotation = 1.5708 shape = SubResource( 2 ) [node name="VisibilityNotifier2D" type="VisibilityNotifier2D" parent="."] - [connection signal="screen_exited" from="VisibilityNotifier2D" to="." method="_on_VisibilityNotifier2D_screen_exited"] diff --git a/2d/dodge_the_creeps/Player.gd b/2d/dodge_the_creeps/Player.gd index 455d0df6..5ac4f1f7 100644 --- a/2d/dodge_the_creeps/Player.gd +++ b/2d/dodge_the_creeps/Player.gd @@ -3,23 +3,18 @@ extends Area2D signal hit export var speed = 400 -var extents var screen_size func _ready(): screen_size = get_viewport_rect().size hide() + func _process(delta): var velocity = Vector2() - if Input.is_action_pressed("ui_right"): - velocity.x += 1 - if Input.is_action_pressed("ui_left"): - velocity.x -= 1 - if Input.is_action_pressed("ui_up"): - velocity.y -= 1 - if Input.is_action_pressed("ui_down"): - velocity.y += 1 + velocity.x = Input.get_action_strength("move_right") - Input.get_action_strength("move_left") + velocity.y = Input.get_action_strength("move_down") - Input.get_action_strength("move_up") + if velocity.length() > 0: velocity = velocity.normalized() * speed $AnimatedSprite.play() @@ -37,12 +32,14 @@ func _process(delta): $AnimatedSprite.animation = "up" $AnimatedSprite.flip_v = velocity.y > 0 -func _on_Player_body_entered(body): - hide() - emit_signal("hit") - $CollisionShape2D.set_deferred("disabled", true) func start(pos): position = pos show() $CollisionShape2D.disabled = false + + +func _on_Player_body_entered(_body): + hide() + emit_signal("hit") + $CollisionShape2D.set_deferred("disabled", true) diff --git a/2d/dodge_the_creeps/Player.tscn b/2d/dodge_the_creeps/Player.tscn index 89fac8a4..6f541542 100644 --- a/2d/dodge_the_creeps/Player.tscn +++ b/2d/dodge_the_creeps/Player.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=8 format=2] +[gd_scene load_steps=13 format=2] [ext_resource path="res://Player.gd" type="Script" id=1] [ext_resource path="res://art/playerGrey_walk1.png" type="Texture" id=2] @@ -23,7 +23,30 @@ animations = [ { radius = 26.1701 height = 14.822 +[sub_resource type="Gradient" id=3] +colors = PoolColorArray( 1, 1, 1, 0.501961, 1, 1, 1, 0 ) + +[sub_resource type="GradientTexture" id=4] +gradient = SubResource( 3 ) + +[sub_resource type="Curve" id=5] +_data = [ Vector2( 0.00501098, 0.5 ), 0.0, 0.0, 0, 0, Vector2( 0.994989, 0.324 ), 0.0, 0.0, 0, 0 ] + +[sub_resource type="CurveTexture" id=6] +curve = SubResource( 5 ) + +[sub_resource type="ParticlesMaterial" id=7] +flag_disable_z = true +gravity = Vector3( 0, 0, 0 ) +initial_velocity = 1.0 +orbit_velocity = 0.0 +orbit_velocity_random = 0.0 +scale = 0.75 +scale_curve = SubResource( 6 ) +color_ramp = SubResource( 4 ) + [node name="Player" type="Area2D"] +z_index = 10 script = ExtResource( 1 ) __meta__ = { "_edit_group_": true @@ -37,4 +60,11 @@ animation = "right" [node name="CollisionShape2D" type="CollisionShape2D" parent="."] shape = SubResource( 2 ) +[node name="Trail" type="Particles2D" parent="."] +z_index = -1 +amount = 10 +speed_scale = 2.0 +local_coords = false +process_material = SubResource( 7 ) +texture = ExtResource( 2 ) [connection signal="body_entered" from="." to="." method="_on_Player_body_entered"] diff --git a/2d/dodge_the_creeps/default_env.tres b/2d/dodge_the_creeps/default_env.tres index bed47996..20207a4a 100644 --- a/2d/dodge_the_creeps/default_env.tres +++ b/2d/dodge_the_creeps/default_env.tres @@ -5,4 +5,3 @@ [resource] background_mode = 2 background_sky = SubResource( 1 ) - diff --git a/2d/dodge_the_creeps/icon.png b/2d/dodge_the_creeps/icon.png index b6644648..6664a7b1 100644 Binary files a/2d/dodge_the_creeps/icon.png and b/2d/dodge_the_creeps/icon.png differ diff --git a/2d/dodge_the_creeps/project.godot b/2d/dodge_the_creeps/project.godot index 3a38fdf1..bfc532ff 100644 --- a/2d/dodge_the_creeps/project.godot +++ b/2d/dodge_the_creeps/project.godot @@ -24,6 +24,41 @@ config/icon="res://icon.png" window/size/width=480 window/size/height=720 +[input] + +move_left={ +"deadzone": 0.5, +"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777231,"unicode":0,"echo":false,"script":null) +, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":65,"unicode":0,"echo":false,"script":null) +, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":14,"pressure":0.0,"pressed":false,"script":null) +, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":0,"axis":0,"axis_value":-1.0,"script":null) + ] +} +move_right={ +"deadzone": 0.5, +"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777233,"unicode":0,"echo":false,"script":null) +, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":68,"unicode":0,"echo":false,"script":null) +, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":15,"pressure":0.0,"pressed":false,"script":null) +, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":0,"axis":0,"axis_value":1.0,"script":null) + ] +} +move_up={ +"deadzone": 0.5, +"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777232,"unicode":0,"echo":false,"script":null) +, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":87,"unicode":0,"echo":false,"script":null) +, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":12,"pressure":0.0,"pressed":false,"script":null) +, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":0,"axis":1,"axis_value":-1.0,"script":null) + ] +} +move_down={ +"deadzone": 0.5, +"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777234,"unicode":0,"echo":false,"script":null) +, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":83,"unicode":0,"echo":false,"script":null) +, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":13,"pressure":0.0,"pressed":false,"script":null) +, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":0,"axis":1,"axis_value":1.0,"script":null) + ] +} + [rendering] environment/default_environment="res://default_env.tres"