better joystick, slightly optimize
23 files changed, 218 insertions, 239 deletions
diff --git a/bullets/scripts/Laser.gd b/bullets/scripts/Laser.gd index 8006ea9..96dc24a 100644 --- a/bullets/scripts/Laser.gd +++ b/bullets/scripts/Laser.gd @@ -82,12 +82,12 @@ func _on_VisibilityNotifier2D_screen_exited(): func _physics_process(delta): - if light.enabled: - light.color.a -= modulate_amount * delta - if light.color.a < 0: - light.enabled = false - set_physics_process(false) + light.color.a -= modulate_amount * delta + if light.color.a < 0: + light.enabled = false + set_physics_process(false) func set_lights(enabled: bool) -> void: light.enabled = enabled + set_physics_process(enabled) diff --git a/effects/Game.gd b/effects/Game.gd index 3f04590..37b9b67 100644 --- a/effects/Game.gd +++ b/effects/Game.gd @@ -21,26 +21,16 @@ func transition(to = null): $transitionAnimation.stop(true) $transitionAnimation.play("fadeinout") if to: - yield(self, "transition_halfway") get_tree().change_scene(to) - set_keyboard(keyboard) - if OS.has_touchscreen_ui_hint(): - turn_off() + yield(self, "transition_halfway") + set_input_prompts() get_tree().paused = false just_called = false func _ready(): - if OS.has_touchscreen_ui_hint(): - turn_off() - - -var title = "spaceshooty" - - -func _process(_delta): - if Engine.get_physics_frames() % 30 == 0: - OS.set_window_title(title + " | fps: " + str(Engine.get_frames_per_second())) + set_input_prompts() + set_process_input(not USE_TOUCH) func turn_off(): @@ -50,20 +40,32 @@ func turn_off(): func _input(event: InputEvent) -> void: - if not USE_TOUCH: - if event is InputEventJoypadButton or event is InputEventJoypadMotion and keyboard == true: - self.keyboard = false - elif event is InputEventKey and keyboard == false: - self.keyboard = true + if event is InputEventJoypadButton or event is InputEventJoypadMotion and keyboard == true: + self.keyboard = false + elif event is InputEventKey and keyboard == false: + self.keyboard = true func set_keyboard(new_keyboard): keyboard = new_keyboard - if new_keyboard == true: + set_input_prompts() + + +func set_input_prompts(): + if USE_TOUCH: + get_tree().call_group("not_mobile", "hide") + get_tree().call_group("mobile", "show") + get_tree().call_group("keyboard", "hide") + get_tree().call_group("gamepad", "hide") + elif keyboard == true: + get_tree().call_group("not_mobile", "show") get_tree().call_group("gamepad", "hide") + get_tree().call_group("mobile", "hide") get_tree().call_group("keyboard", "show") - elif new_keyboard == false: + elif keyboard == false: + get_tree().call_group("not_mobile", "show") get_tree().call_group("keyboard", "hide") + get_tree().call_group("mobile", "hide") get_tree().call_group("gamepad", "show") diff --git a/effects/shake.gd b/effects/shake.gd index 8492628..7474674 100644 --- a/effects/shake.gd +++ b/effects/shake.gd @@ -10,6 +10,7 @@ var noise: OpenSimplexNoise func _ready(): + set_process(false) # Generate noise for noise shake # # This is only generated once when the game starts @@ -37,6 +38,7 @@ func shake(intensity, duration, type = Type.Random): camera_shake_intensity = intensity camera_shake_duration = duration camera_shake_type = type + set_process(true) func _process(delta): @@ -54,6 +56,7 @@ func _process(delta): camera.offset = Vector2.ZERO camera_shake_intensity = 0.0 camera_shake_duration = 0.0 + set_process(false) return # Subtract the elapsed time from the camera_shake_duration diff --git a/enemy/scenes/EnemySpawner.tscn b/enemy/scenes/EnemySpawner.tscn index b329333..5ecad77 100644 --- a/enemy/scenes/EnemySpawner.tscn +++ b/enemy/scenes/EnemySpawner.tscn @@ -6,7 +6,7 @@ [ext_resource path="res://sprites/squid.png" type="Texture" id=4] [ext_resource path="res://sprites/UFO-export.png" type="Texture" id=5] [ext_resource path="res://sprites/boss2.png" type="Texture" id=6] -[ext_resource path="res://fonts/fonty.tres" type="DynamicFont" id=7] +[ext_resource path="res://fonts/04b-19.tres" type="DynamicFont" id=7] [ext_resource path="res://sprites/HardEnemy.png" type="Texture" id=8] [ext_resource path="res://sprites/bossfinal.png" type="Texture" id=9] @@ -29,58 +29,55 @@ position = Vector2( -19, -33 ) [node name="octopus" type="Sprite" parent="Sprite Holders"] visible = false -position = Vector2( -24, 176 ) +position = Vector2( -21, 197 ) rotation = -1.5708 texture = ExtResource( 2 ) hframes = 2 [node name="basicenemy" type="Sprite" parent="Sprite Holders"] visible = false -position = Vector2( -24, 176 ) +position = Vector2( -23, 197 ) texture = ExtResource( 3 ) [node name="squid" type="Sprite" parent="Sprite Holders"] visible = false -position = Vector2( -24, 176 ) +position = Vector2( -21, 197 ) texture = ExtResource( 4 ) vframes = 2 [node name="ufo" type="Sprite" parent="Sprite Holders"] visible = false -position = Vector2( 2, 176 ) +position = Vector2( -20, 197 ) texture = ExtResource( 5 ) [node name="boss" type="Sprite" parent="Sprite Holders"] visible = false -position = Vector2( -16, 176 ) +position = Vector2( -20, 197 ) texture = ExtResource( 6 ) [node name="hardy" type="Sprite" parent="Sprite Holders"] visible = false -position = Vector2( -16, 176 ) +position = Vector2( -20, 197 ) rotation = -1.5708 texture = ExtResource( 8 ) hframes = 2 [node name="finale" type="Sprite" parent="Sprite Holders"] visible = false -position = Vector2( -16, 176 ) +position = Vector2( -20, 197 ) rotation = -1.5708 texture = ExtResource( 9 ) [node name="Label" type="Label" parent="Sprite Holders"] visible = false margin_left = -344.0 -margin_top = 168.0 +margin_top = 189.0 margin_right = -32.0 -margin_bottom = 185.0 +margin_bottom = 206.0 custom_fonts/font = ExtResource( 7 ) text = "Beware of the" align = 2 valign = 1 -__meta__ = { -"_edit_use_anchors_": false -} [node name="Timer" type="Timer" parent="."] wait_time = 0.5 diff --git a/enemy/scripts/EnemySpawner.gd b/enemy/scripts/EnemySpawner.gd index 033b351..f33495d 100644 --- a/enemy/scripts/EnemySpawner.gd +++ b/enemy/scripts/EnemySpawner.gd @@ -31,6 +31,8 @@ onready var spawnPoints = $SpawnPoints var difficulty_levels: Array var current_difficulty_level onready var main = get_node("../../../EnemyHolder") +onready var world = get_tree().current_scene +var last_score: int = -1 func _ready(): @@ -66,7 +68,9 @@ func get_spawn_position(): func _physics_process(_delta): - var world = get_tree().current_scene + if world.score == last_score: + last_score = world.score + return for i in score_ranges.size(): if world.score in range(score_ranges[i][0], score_ranges[i][1], 1): #set your dificulty to score_ranges[i][2] diff --git a/player/scenes/Ship.tscn b/player/scenes/Ship.tscn index ba2e288..f7e69ae 100644 --- a/player/scenes/Ship.tscn +++ b/player/scenes/Ship.tscn @@ -1,6 +1,6 @@ [gd_scene load_steps=35 format=2] -[ext_resource path="res://ui/scenes/MobileControls.tscn" type="PackedScene" id=1] +[ext_resource path="res://ui/scenes/mobile/MobileControls.tscn" type="PackedScene" id=1] [ext_resource path="res://sounds/thrust.wav" type="AudioStream" id=2] [ext_resource path="res://effects/Trail.tscn" type="PackedScene" id=3] [ext_resource path="res://sprites/ship.png" type="Texture" id=4] @@ -8,7 +8,7 @@ [ext_resource path="res://sounds/thrust_end.wav" type="AudioStream" id=6] [ext_resource path="res://player/scripts/ShipArea2d.gd" type="Script" id=7] [ext_resource path="res://sounds/ShipHit.wav" type="AudioStream" id=8] -[ext_resource path="res://ui/scenes/MobileJoystick.tscn" type="PackedScene" id=9] +[ext_resource path="res://ui/scenes/mobile/MobileJoystick.tscn" type="PackedScene" id=9] [ext_resource path="res://effects/Fire.tscn" type="PackedScene" id=10] [ext_resource path="res://player/scripts/Ship.gd" type="Script" id=11] [ext_resource path="res://sprites/spot.png" type="Texture" id=12] @@ -229,7 +229,7 @@ start_node = "Idle" [sub_resource type="CircleShape2D" id=39] radius = 374.065 -[node name="KinematicBody2D" type="KinematicBody2D" groups=["Player"]] +[node name="Ship" type="KinematicBody2D" groups=["Player"]] z_index = 2 z_as_relative = false collision_layer = 17 @@ -325,12 +325,11 @@ scale_amount_random = 0.2 stream = ExtResource( 8 ) volume_db = -20.0 -[node name="MobileJoystick" parent="." instance=ExtResource( 9 )] +[node name="MobileControls" type="CanvasLayer" parent="."] -[node name="MobileControls" parent="MobileJoystick" instance=ExtResource( 1 )] +[node name="MobileButtons" parent="MobileControls" instance=ExtResource( 1 )] -[node name="Change gun" parent="MobileJoystick/MobileControls" index="1"] -action = "change_gun_1" +[node name="MobileJoystick" parent="MobileControls" groups=["mobile"] instance=ExtResource( 9 )] [node name="damage" type="Area2D" parent="." groups=["Player", "player"]] @@ -385,6 +384,3 @@ position = Vector2( 5, 0 ) [connection signal="area_entered" from="damage" to="." method="_on_Ship_area_entered"] [connection signal="body_entered" from="damage" to="." method="_on_Ship_body_entered"] [connection signal="target" from="target_getter" to="." method="_on_target_getter_target"] - -[editable path="MobileJoystick"] -[editable path="MobileJoystick/MobileControls"] diff --git a/player/scripts/Ship.gd b/player/scripts/Ship.gd index 9973944..d3b969b 100644 --- a/player/scripts/Ship.gd +++ b/player/scripts/Ship.gd @@ -28,6 +28,12 @@ onready var lasersu onready var flaku onready var beamu onready var fire = $Fire +onready var joystick = $MobileControls/MobileJoystick +onready var thrustsfxin = $thrustsfxin +onready var thrustsfxend = $thrustsfxend +onready var thrustsfxloop = $thrustsfxloop +onready var animation_tree = $AnimationTree + var amount = 1 var target = null var firing = false @@ -39,10 +45,7 @@ var shake_duration = .2 func _ready(): playerstats.gun = "lasers" - $MobileJoystick/TouchScreenButton.visible = USE_TOUCH - $MobileJoystick/MobileControls/Attack.visible = USE_TOUCH - $"MobileJoystick/MobileControls/Change gun".visible = USE_TOUCH - $AnimationTree.active = true + animation_tree.active = true lasersu = playerstats.lasers rocketsu = playerstats.rockets splitshotu = playerstats.splitshot @@ -59,8 +62,8 @@ func _physics_process(delta): input_vector.y = Input.get_axis("up_%s" % id, "down_%s" % id) if Game.keyboard: input_vector = input_vector.normalized() - if $MobileJoystick/TouchScreenButton.in_use: - input_vector = $MobileJoystick/TouchScreenButton.force + if joystick.in_use: + input_vector = joystick.force #makes a input vector based off of inputs, and supports controllers # fire particle code var fire_dir = input_vector * -1 @@ -74,24 +77,24 @@ func _physics_process(delta): if input_vector != Vector2.ZERO: if not thrusting_last_frame: - $thrustsfxin.playing = true + thrustsfxin.playing = true - if not $thrustsfxloop.playing: - $thrustsfxloop.playing = true + if not thrustsfxloop.playing: + thrustsfxloop.playing = true thrusting_last_frame = true else: if thrusting_last_frame: - $thrustsfxloop.playing = false - $thrustsfxend.playing = true + thrustsfxloop.playing = false + thrustsfxend.playing = true - if $thrustsfxin.playing: - $thrustsfxin.playing = false + if thrustsfxin.playing: + thrustsfxin.playing = false thrusting_last_frame = false if input_vector != Vector2.ZERO: #moves ya velocity = velocity.move_toward(input_vector * SPEED, ACCELERATION * delta) - $AnimationTree.set("parameters/Turn/blend_position", input_vector) + animation_tree.set("parameters/Turn/blend_position", input_vector) animationState.travel("Turn") else: #stops you @@ -217,6 +220,10 @@ func splitshot(): playerstats.gun = "splitshot" +onready var rocket_muzzles = $Muzzles/RocketMuzzle.get_children() +onready var laser_muzzles = $Muzzles/LaserMuzzle.get_children() + + func shoot(): #shoot _go_into_cooldown() if !firing: @@ -224,21 +231,11 @@ func shoot(): #shoot Shake.shake(shake_intensity, shake_duration) match playerstats.gun: "rockets": - var muzzles = $Muzzles/RocketMuzzle.get_children() - for muzzle in muzzles: + for muzzle in rocket_muzzles: var bullet = fire(muzzle.global_position, attack) bullet.start(target) "lasers": - var muzzles = $Muzzles/LaserMuzzle.get_children() - for muzzle in muzzles: - fire(muzzle.global_position, attack) - "splitshot": - var muzzles = $Muzzles/SplitMuzzle.get_children() - for muzzle in muzzles: - fire(muzzle.global_position, attack) - "flak": - var muzzles = $Muzzles/FlakMuzzle.get_children() - for muzzle in muzzles: + for muzzle in laser_muzzles: fire(muzzle.global_position, attack) diff --git a/project.godot b/project.godot index 6814394..fc31629 100644 --- a/project.godot +++ b/project.godot @@ -282,6 +282,10 @@ x={ ] } +[input_devices] + +pointing/emulate_mouse_from_touch=false + [layer_names] 2d_render/layer_1="player" diff --git a/sprites/handle.png b/sprites/handle.png Binary files differnew file mode 100644 index 0000000..00d3af4 --- /dev/null +++ b/sprites/handle.png diff --git a/sprites/innercircle.png.import b/sprites/handle.png.import index 2b4fd57..449a2fe 100644 --- a/sprites/innercircle.png.import +++ b/sprites/handle.png.import @@ -2,15 +2,15 @@ importer="texture" type="StreamTexture" -path="res://.import/innercircle.png-084617e048c3f7b9d2d702f198da4990.stex" +path="res://.import/handle.png-83e7e65f503b40896ada2cfc7afeaf51.stex" metadata={ "vram_texture": false } [deps] -source_file="res://sprites/innercircle.png" -dest_files=[ "res://.import/innercircle.png-084617e048c3f7b9d2d702f198da4990.stex" ] +source_file="res://sprites/handle.png" +dest_files=[ "res://.import/handle.png-83e7e65f503b40896ada2cfc7afeaf51.stex" ] [params] @@ -19,7 +19,7 @@ compress/lossy_quality=0.7 compress/hdr_mode=0 compress/bptc_ldr=0 compress/normal_map=0 -flags/repeat=1 +flags/repeat=0 flags/filter=false flags/mipmaps=false flags/anisotropic=false diff --git a/sprites/innercircle.png b/sprites/innercircle.png Binary files differdeleted file mode 100644 index 2166c1c..0000000 --- a/sprites/innercircle.png +++ /dev/null diff --git a/sprites/touchbg.png b/sprites/touchbg.png Binary files differnew file mode 100644 index 0000000..18e29ab --- /dev/null +++ b/sprites/touchbg.png diff --git a/sprites/touchbuttonthing.png.import b/sprites/touchbg.png.import index 1b80b95..99136ef 100644 --- a/sprites/touchbuttonthing.png.import +++ b/sprites/touchbg.png.import @@ -2,15 +2,15 @@ importer="texture" type="StreamTexture" -path="res://.import/touchbuttonthing.png-0af972ae6ca601611463fec0d93a9968.stex" +path="res://.import/touchbg.png-63355816cf232acd398781f30cf347b9.stex" metadata={ "vram_texture": false } [deps] -source_file="res://sprites/touchbuttonthing.png" -dest_files=[ "res://.import/touchbuttonthing.png-0af972ae6ca601611463fec0d93a9968.stex" ] +source_file="res://sprites/touchbg.png" +dest_files=[ "res://.import/touchbg.png-63355816cf232acd398781f30cf347b9.stex" ] [params] @@ -19,7 +19,7 @@ compress/lossy_quality=0.7 compress/hdr_mode=0 compress/bptc_ldr=0 compress/normal_map=0 -flags/repeat=1 +flags/repeat=0 flags/filter=false flags/mipmaps=false flags/anisotropic=false diff --git a/sprites/touchbuttonthing.png b/sprites/touchbuttonthing.png Binary files differdeleted file mode 100644 index 7307734..0000000 --- a/sprites/touchbuttonthing.png +++ /dev/null diff --git a/ui/scenes/MobileJoystick.tscn b/ui/scenes/MobileJoystick.tscn deleted file mode 100644 index b1a94ed..0000000 --- a/ui/scenes/MobileJoystick.tscn +++ /dev/null @@ -1,22 +0,0 @@ -[gd_scene load_steps=5 format=2] - -[ext_resource path="res://sprites/touchbuttonthing.png" type="Texture" id=1] -[ext_resource path="res://sprites/innercircle.png" type="Texture" id=3] -[ext_resource path="res://ui/scripts/Joystick.gd" type="Script" id=4] - -[sub_resource type="CircleShape2D" id=1] -radius = 32.0 - -[node name="MobileJoystick" type="CanvasLayer"] - -[node name="TouchScreenButton" type="TouchScreenButton" parent="."] -modulate = Color( 1, 1, 1, 0.392157 ) -position = Vector2( 8, 104 ) -normal = ExtResource( 1 ) -shape = SubResource( 1 ) -passby_press = true -script = ExtResource( 4 ) - -[node name="Button" type="Sprite" parent="TouchScreenButton"] -position = Vector2( 32, 32 ) -texture = ExtResource( 3 ) diff --git a/ui/scenes/StartMenu.tscn b/ui/scenes/StartMenu.tscn index 276840e..c36a4fd 100644 --- a/ui/scenes/StartMenu.tscn +++ b/ui/scenes/StartMenu.tscn @@ -1,15 +1,15 @@ [gd_scene load_steps=414 format=2] -[ext_resource path="res://fonts/fonty.tres" type="DynamicFont" id=1] [ext_resource path="res://ui/scripts/StartMenu.gd" type="Script" id=2] [ext_resource path="res://effects/Stars.tscn" type="PackedScene" id=3] -[ext_resource path="res://ui/scenes/MobileControls.tscn" type="PackedScene" id=4] +[ext_resource path="res://ui/scenes/mobile/MobileControls.tscn" type="PackedScene" id=4] [ext_resource path="res://sprites/blackhoole.png" type="Texture" id=5] [ext_resource path="res://fonts/Paskowy.ttf" type="DynamicFontData" id=6] [ext_resource path="res://ui/buttontheme.tres" type="Theme" id=7] [ext_resource path="res://ui/scenes/pause.tscn" type="PackedScene" id=8] [ext_resource path="res://sprites/inputs.png" type="Texture" id=9] [ext_resource path="res://fonts/tiny.tres" type="DynamicFont" id=10] +[ext_resource path="res://fonts/04b-19.tres" type="DynamicFont" id=11] [sub_resource type="ShaderMaterial" id=403] @@ -2043,82 +2043,87 @@ position = Vector2( 42, 138 ) frames = SubResource( 401 ) flip_h = true -[node name="label center" type="Label" parent="." groups=["not_mobile"]] -margin_left = 90.0 -margin_top = 51.0 -margin_right = 290.0 -margin_bottom = 68.0 -custom_colors/font_color_shadow = Color( 0.760784, 0.760784, 0.760784, 0.560784 ) -custom_fonts/font = ExtResource( 1 ) -text = "press " +[node name="start" type="Label" parent="." groups=["not_mobile"]] +margin_left = 66.0 +margin_top = 69.0 +margin_right = 224.0 +margin_bottom = 86.0 +custom_fonts/font = ExtResource( 11 ) +text = "press to play" align = 1 valign = 1 -[node name="space" type="Sprite" parent="label center" groups=["keyboard"]] -position = Vector2( 154, 9 ) +[node name="space" type="Sprite" parent="start" groups=["keyboard"]] +position = Vector2( 70, 8 ) texture = ExtResource( 9 ) region_enabled = true region_rect = Rect2( 0, 64, 48, 16 ) +__meta__ = { +"_edit_group_": true +} -[node name="x" type="Sprite" parent="label center" groups=["gamepad"]] -visible = false -position = Vector2( 139, 9 ) -texture = ExtResource( 9 ) -region_enabled = true -region_rect = Rect2( 32, 112, 16, 16 ) - -[node name="space2" type="Label" parent="label center" groups=["keyboard"]] -margin_left = 131.0 -margin_top = 6.0 -margin_right = 177.0 -margin_bottom = 19.0 +[node name="label" type="Label" parent="start/space"] +anchor_right = 1.0 +anchor_bottom = 1.0 +margin_left = -24.0 +margin_top = -6.0 +margin_right = -24.0 +margin_bottom = -6.0 custom_colors/font_color = Color( 0, 0, 0, 1 ) custom_fonts/font = ExtResource( 10 ) text = "space " align = 1 -valign = 1 +valign = 2 + +[node name="x" type="Sprite" parent="start" groups=["gamepad"]] +visible = false +position = Vector2( 67, 8 ) +texture = ExtResource( 9 ) +region_enabled = true +region_rect = Rect2( 32, 112, 16, 16 ) [node name="escape" type="Label" parent="." groups=["not_mobile"]] -margin_left = 90.0 -margin_top = 72.0 -margin_right = 290.0 -margin_bottom = 109.0 -custom_colors/font_color_shadow = Color( 0.760784, 0.760784, 0.760784, 0.560784 ) -custom_fonts/font = ExtResource( 1 ) -text = " -press " +anchor_left = 0.5 +anchor_top = 0.5 +anchor_right = 0.5 +anchor_bottom = 0.5 +margin_left = -50.0 +margin_top = 22.0 +margin_right = 70.0 +margin_bottom = 36.0 +custom_fonts/font = ExtResource( 11 ) +text = "press to quit" valign = 1 -__meta__ = { -"_edit_use_anchors_": false -} [node name="esc" type="Sprite" parent="escape" groups=["keyboard"]] -position = Vector2( 84, 30 ) +position = Vector2( 55, 7 ) texture = ExtResource( 9 ) region_enabled = true region_rect = Rect2( 0, 16, 23, 16 ) +__meta__ = { +"_edit_group_": true +} -[node name="b" type="Sprite" parent="escape" groups=["gamepad"]] -visible = false -position = Vector2( 83, 31 ) -texture = ExtResource( 9 ) -region_enabled = true -region_rect = Rect2( 16, 112, 16, 16 ) - -[node name="esc2" type="Label" parent="escape" groups=["keyboard"]] -margin_left = 75.0 -margin_top = 23.0 -margin_right = 93.0 -margin_bottom = 36.0 +[node name="label" type="Label" parent="escape/esc"] +anchor_right = 1.0 +anchor_bottom = 1.0 +margin_left = -12.0 +margin_top = -8.0 +margin_right = -12.0 +margin_bottom = -8.0 custom_colors/font_color = Color( 0, 0, 0, 1 ) custom_fonts/font = ExtResource( 10 ) text = "esc" align = 1 valign = 1 -__meta__ = { -"_edit_use_anchors_": false -} + +[node name="b" type="Sprite" parent="escape" groups=["gamepad"]] +visible = false +position = Vector2( 54, 24 ) +texture = ExtResource( 9 ) +region_enabled = true +region_rect = Rect2( 16, 112, 16, 16 ) [node name="Stars" parent="." instance=ExtResource( 3 )] @@ -2127,11 +2132,8 @@ anchor_right = 1.0 margin_left = 8.0 margin_top = 15.0 margin_bottom = 32.0 -custom_fonts/font = ExtResource( 1 ) +custom_fonts/font = ExtResource( 11 ) text = "highscore = " -__meta__ = { -"_edit_use_anchors_": false -} [node name="MobileControls" parent="." instance=ExtResource( 4 )] @@ -2157,35 +2159,35 @@ anchor_left = 0.5 anchor_top = 1.0 anchor_right = 0.5 anchor_bottom = 1.0 -margin_left = -56.0 +margin_left = -27.0 margin_top = -28.0 -margin_right = 88.0 +margin_right = 137.0 margin_bottom = -11.0 theme = ExtResource( 7 ) -text = "options = " +text = "press for options" align = 1 valign = 2 -[node name="Inputs" type="Sprite" parent="settings"] -position = Vector2( 119, 10 ) +[node name="keyboard" type="Sprite" parent="settings" groups=["keyboard"]] +position = Vector2( 60, 10 ) texture = ExtResource( 9 ) region_enabled = true region_rect = Rect2( 0, 48, 32, 16 ) +__meta__ = { +"_edit_group_": true +} -[node name="backspace" type="Label" parent="settings"] -margin_left = 104.0 -margin_top = 3.0 -margin_right = 134.0 -margin_bottom = 16.0 +[node name="label" type="Label" parent="settings/keyboard"] +margin_left = -15.0 +margin_top = -7.0 +margin_right = 15.0 +margin_bottom = 6.0 custom_colors/font_color = Color( 0, 0, 0, 1 ) custom_colors/font_color_shadow = Color( 0, 0, 0, 0 ) custom_fonts/font = ExtResource( 10 ) text = "back _" align = 1 valign = 1 -__meta__ = { -"_edit_use_anchors_": false -} [node name="pause" parent="." instance=ExtResource( 8 )] visible = false diff --git a/ui/scenes/WeaponUi.tscn b/ui/scenes/WeaponUi.tscn index 99b52c5..6a45e0a 100644 --- a/ui/scenes/WeaponUi.tscn +++ b/ui/scenes/WeaponUi.tscn @@ -14,9 +14,6 @@ anchor_bottom = 1.0 margin_right = -300.0 margin_bottom = -164.0 script = ExtResource( 4 ) -__meta__ = { -"_edit_use_anchors_": false -} [node name="Rocket" type="TextureRect" parent="."] visible = false @@ -62,19 +59,18 @@ texture = ExtResource( 7 ) region_enabled = true region_rect = Rect2( 0, 16, 23, 16 ) -[node name="Label" type="Label" parent="tab" groups=["keyboard"]] -margin_left = -11.0 -margin_top = -7.0 -margin_right = 11.0 -margin_bottom = 7.0 +[node name="Label" type="Label" parent="tab"] +anchor_right = 1.0 +anchor_bottom = 1.0 +margin_left = -12.0 +margin_top = -8.0 +margin_right = -12.0 +margin_bottom = -8.0 custom_colors/font_color = Color( 0, 0, 0, 1 ) custom_fonts/font = ExtResource( 8 ) text = "tab" align = 1 valign = 1 -__meta__ = { -"_edit_use_anchors_": false -} [node name="y" type="Sprite" parent="." groups=["gamepad"]] visible = false diff --git a/ui/scenes/MobileControls.tscn b/ui/scenes/mobile/MobileControls.tscn index 03592f9..f0b94b7 100644 --- a/ui/scenes/MobileControls.tscn +++ b/ui/scenes/mobile/MobileControls.tscn @@ -1,18 +1,16 @@ -[gd_scene load_steps=5 format=2] +[gd_scene load_steps=4 format=2] -[ext_resource path="res://ui/scripts/MobileControls.gd" type="Script" id=1] [ext_resource path="res://sprites/attakbutton.png" type="Texture" id=2] [ext_resource path="res://sprites/changegun.png" type="Texture" id=3] [sub_resource type="CircleShape2D" id=1] -radius = 24.0 +radius = 40.0 -[node name="MobileControls" type="CanvasLayer"] -script = ExtResource( 1 ) +[node name="MobileButtons" type="Node2D"] [node name="Attack" type="TouchScreenButton" parent="."] modulate = Color( 1, 1, 1, 0.392157 ) -position = Vector2( 280, 144 ) +position = Vector2( 268, 128 ) normal = ExtResource( 2 ) shape = SubResource( 1 ) passby_press = true diff --git a/ui/scenes/mobile/MobileJoystick.tscn b/ui/scenes/mobile/MobileJoystick.tscn new file mode 100644 index 0000000..162c417 --- /dev/null +++ b/ui/scenes/mobile/MobileJoystick.tscn @@ -0,0 +1,27 @@ +[gd_scene load_steps=5 format=2] + +[ext_resource path="res://sprites/handle.png" type="Texture" id=1] +[ext_resource path="res://sprites/touchbg.png" type="Texture" id=2] +[ext_resource path="res://ui/scripts/Joystick.gd" type="Script" id=4] + +[sub_resource type="CircleShape2D" id=1] +radius = 20.0 + +[node name="TouchButton" type="TouchScreenButton"] +self_modulate = Color( 1, 1, 1, 0.588235 ) +position = Vector2( 10, 115 ) +scale = Vector2( 0.302198, 0.302198 ) +normal = ExtResource( 2 ) +shape = SubResource( 1 ) +shape_visible = false +passby_press = true +script = ExtResource( 4 ) +__meta__ = { +"_edit_group_": true +} + +[node name="Handle" type="Sprite" parent="."] +unique_name_in_owner = true +position = Vector2( 87.2464, 84.7536 ) +scale = Vector2( 0.705991, 0.705991 ) +texture = ExtResource( 1 ) diff --git a/ui/scripts/Joystick.gd b/ui/scripts/Joystick.gd index c31ec98..19d64a9 100644 --- a/ui/scripts/Joystick.gd +++ b/ui/scripts/Joystick.gd @@ -14,12 +14,14 @@ var center: Vector2 var event_index = -1 var in_use: bool = false var force: Vector2 = Vector2() -onready var FRICTION = 400 +const FRICTION = 400 +onready var handle = $"%Handle" func _ready(): radius = normal.get_width() * global_scale.x / 2 center = global_position + Vector2(radius, radius) + handle.global_position = center func _input(event): @@ -35,7 +37,7 @@ func _input(event): force = angle_to_vec(angle) * clamped_dist / radius - $Button.global_position = center + force.normalized() * clamped_dist + handle.global_position = center + force.normalized() * clamped_dist if event is InputEventScreenTouch and !event.is_pressed() and event.get_index() == event_index: event_index = -1 @@ -45,5 +47,5 @@ func _input(event): func _process(delta): # Return the button to the center of the joystick if !in_use: - $Button.global_position = weighted_average($Button.global_position, center, 0.7) + handle.global_position = weighted_average(handle.global_position, center, 0.8) force = force.move_toward(Vector2.ZERO, FRICTION * delta) diff --git a/ui/scripts/MobileControls.gd b/ui/scripts/MobileControls.gd deleted file mode 100644 index 53faa5e..0000000 --- a/ui/scripts/MobileControls.gd +++ /dev/null @@ -1 +0,0 @@ -extends CanvasLayer diff --git a/ui/scripts/WeaponUi.gd b/ui/scripts/WeaponUi.gd index dbcb7cc..b3705b8 100644 --- a/ui/scripts/WeaponUi.gd +++ b/ui/scripts/WeaponUi.gd @@ -1,8 +1,13 @@ extends Control +onready var laser := $Laser +onready var rocket := $Rocket +onready var split := $Split +onready var flak := $Flak + func _process(_delta) -> void: - $Laser.visible = playerstats.gun == "lasers" - $Flak.visible = playerstats.gun == "flak" - $Split.visible = playerstats.gun == "splitshot" - $Rocket.visible = playerstats.gun == "rockets" + laser.visible = playerstats.gun == "lasers" + flak.visible = playerstats.gun == "flak" + split.visible = playerstats.gun == "splitshot" + rocket.visible = playerstats.gun == "rockets" diff --git a/world/World.tscn b/world/World.tscn index 69c5e9c..88a61af 100644 --- a/world/World.tscn +++ b/world/World.tscn @@ -11,6 +11,7 @@ [ext_resource path="res://fonts/fonty.tres" type="DynamicFont" id=9] [ext_resource path="res://ui/buttontheme.tres" type="Theme" id=10] [ext_resource path="res://PowerUp.tscn" type="PackedScene" id=11] +[ext_resource path="res://fonts/04b-19.tres" type="DynamicFont" id=12] [sub_resource type="Shader" id=6] code = "shader_type canvas_item; @@ -44,30 +45,6 @@ shader_param/vignette_rgb = Color( 0, 0, 0, 1 ) [sub_resource type="RectangleShape2D" id=4] extents = Vector2( 19.125, 183 ) -[sub_resource type="TileSet" id=5] -0/name = "bitmaskexample.png 0" -0/tex_offset = Vector2( 0, 0 ) -0/modulate = Color( 1, 1, 1, 1 ) -0/region = Rect2( 0, 0, 9, 9 ) -0/tile_mode = 1 -0/autotile/bitmask_mode = 1 -0/autotile/bitmask_flags = [ Vector2( 0, 0 ), 176, Vector2( 0, 1 ), 146, Vector2( 0, 2 ), 50, Vector2( 1, 0 ), 56, Vector2( 1, 2 ), 56, Vector2( 2, 0 ), 152, Vector2( 2, 1 ), 146, Vector2( 2, 2 ), 26 ] -0/autotile/icon_coordinate = Vector2( 0, 0 ) -0/autotile/tile_size = Vector2( 3, 3 ) -0/autotile/spacing = 0 -0/autotile/occluder_map = [ ] -0/autotile/navpoly_map = [ ] -0/autotile/priority_map = [ ] -0/autotile/z_index_map = [ ] -0/occluder_offset = Vector2( 0, 0 ) -0/navigation_offset = Vector2( 0, 0 ) -0/shape_offset = Vector2( 0, 0 ) -0/shape_transform = Transform2D( 1, 0, 0, 1, 0, 0 ) -0/shape_one_way = false -0/shape_one_way_margin = 0.0 -0/shapes = [ ] -0/z_index = 0 - [node name="World" type="Node" groups=["World"]] script = ExtResource( 1 ) @@ -113,18 +90,16 @@ margin_right = -11.0 margin_bottom = -164.0 [node name="ScoreLabel" type="Label" parent="CanvasLayer2/Background"] -anchor_right = 1.0 -margin_left = 57.0 -margin_top = 5.0 -margin_right = -80.0 -margin_bottom = 22.0 -custom_fonts/font = ExtResource( 9 ) +anchor_left = 0.5 +anchor_right = 0.5 +margin_left = -91.5 +margin_top = 7.0 +margin_right = 91.5 +margin_bottom = 24.0 +custom_fonts/font = ExtResource( 12 ) text = "Score = 0" align = 1 autowrap = true -__meta__ = { -"_edit_use_anchors_": false -} [node name="powerup" type="Label" parent="CanvasLayer2/Background"] visible = false @@ -208,12 +183,6 @@ hue_variation_random = 1.0 position = Vector2( 25, 77 ) z_index = 1 -[node name="TileMap" type="TileMap" parent="."] -tile_set = SubResource( 5 ) -cell_size = Vector2( 3, 3 ) -format = 1 -tile_data = PoolIntArray( 5177420, 0, 0, 5177421, 0, 0, 5177422, 0, 0, 5177423, 0, 0, 5177424, 0, 0, 5242956, 0, 0, 5242960, 0, 0, 5308492, 0, 0, 5308496, 0, 0, 5374028, 0, 0, 5374029, 0, 0, 5374030, 0, 0, 5374031, 0, 0, 5374032, 0, 0 ) - [node name="PowerUp" parent="." instance=ExtResource( 11 )] position = Vector2( 226, 57 ) |