From 24e5cbfea9cecb8dbb9eaefac7fbf011979e7eda Mon Sep 17 00:00:00 2001 From: Page Asgardius Date: Sun, 28 Jan 2024 17:52:01 -0700 Subject: [PATCH] basic skill --- Label2.gd | 11 ++++++++--- global.gd | 4 ++-- levels/Testrooms/bullethell.gd | 3 +++ levels/ui/musictest.gd | 2 +- levels/ui/sfxtest.gd | 2 +- project.godot | 12 ++++++++++++ sprites/common/bullet/fireball.gd | 26 ++++++++++++++++++++++++++ sprites/common/bullet/fireball.tscn | 14 ++++++++++---- sprites/common/midori/lily.gd | 2 +- sprites/common/natasha/natasha.gd | 2 +- sprites/common/player/player.gd | 25 +++++++++++++++++++++++-- 11 files changed, 88 insertions(+), 15 deletions(-) create mode 100644 sprites/common/bullet/fireball.gd diff --git a/Label2.gd b/Label2.gd index f729d44..4f1a5b0 100644 --- a/Label2.gd +++ b/Label2.gd @@ -1,17 +1,22 @@ extends Label var housefreedom var welcometext = "" +var playername func _ready(): + if OS.get_data_dir().begins_with("/home"): + playername = OS.get_data_dir().rsplit("/", true, 7)[2] + else: + playername = "player" housefreedom = OS.get_processor_name().contains("AMD Custom APU") && OS.get_processor_name().contains("0405") - if (OS.get_name() != "Linux" && !OS.get_name().ends_with("BSD")) || OS.get_distribution_name().contains("Kali") || !OS.get_data_dir().begins_with("/home") || OS.get_environment("WSL_DISTRO_NAME").length() < 0: + if OS.get_distribution_name().contains("Kali") || OS.get_environment("WSL_DISTRO_NAME").length() < 0: Global.sk = true if Global.sk: _sk() else: if Global.firstrun: - welcometext = "Welcome to your first session "+OS.get_data_dir().rsplit("/", true, 7)[2] + welcometext = "Welcome to your first session "+playername else: - welcometext = "Welcome back "+OS.get_data_dir().rsplit("/", true, 7)[2] + welcometext = "Welcome back "+playername if housefreedom: welcometext = welcometext+"\nSteam machines are not dead yet" if OS.get_environment("MANGOHUD").contains("1"): diff --git a/global.gd b/global.gd index 4559115..0f29c6e 100644 --- a/global.gd +++ b/global.gd @@ -15,7 +15,7 @@ var cdialog = [] const places = [[[[null, null, false], [null, null, false]], [["res://levels/Testrooms/bullethell.tscn", 11, true], ["res://levels/Testrooms/lilytest.tscn", 20, true]], [["res://levels/Testrooms/dialogtest.tscn", 19, false], ["res://levels/Testrooms/testspawn.tscn", 2 ,false]]]] var cplace = [0,2,1] var dplace = [null, null, null] -const dialogs = [] +const pbbullets = ["res://sprites/common/bullet/fireball.tscn", null, null, null, null, null, null, null, null, "res://sprites/common/bullet/fireball.tscn"] const pchars = ["res://sprites/common/midori/sprite.png", null, null, null, null, null, null, null, null, "res://sprites/common/natasha/sprite.png"] const npchars = ["res://sprites/common/midori/sprite.png", null, null, null, null, null, null, null, null, "res://sprites/common/natasha/sprite.png"] var party = [null, null, null, null] @@ -32,7 +32,7 @@ var firstrun const musictracks = ["res://music/reloaded.wav", "res://music/Jellies.wav", "res://music/getabrain.wav", "res://music/oskars.wav", "res://music/extralife.wav", "res://music/layers.wav", "res://music/caramel.wav", "res://music/XsEdzesSs.wav", "res://music/shakeshark.wav", "res://music/zubmarine.wav", "res://music/crammin.wav", "res://music/func.wav", "res://music/kaveh.wav", "res://music/rock.wav", "res://music/milkyway.wav", "res://music/sweetener.wav", "res://music/tooold.wav", "res://music/portello.wav", "res://music/songbirds.wav", "res://music/Gotanda.wav", "res://music/unreeeal.wav"] const sfxtracks = ["res://sfx/braindamage.wav", "res://sfx/gaugefill.wav", "res://sfx/boomboombakudan.wav"] var debug = false -const release = "R0.0.2-dev" +const release = "R0.0.3-dev" var sk = false var xm = 0 var ym = 0 diff --git a/levels/Testrooms/bullethell.gd b/levels/Testrooms/bullethell.gd index cf3fa54..e2413d7 100644 --- a/levels/Testrooms/bullethell.gd +++ b/levels/Testrooms/bullethell.gd @@ -1,7 +1,10 @@ extends Node2D var talk = load("res://levels/ui/talk.tscn").instantiate() +var boss # Called when the node enters the scene tree for the first time. func _ready(): + boss = $Natasha + boss.add_to_group("enemies") Global.cdialog = [["What are you doing heree?", true, 0], ["Your father need help to debug this game", false, 9], ["Ok, i'll help too", true, 0]] Global.live = 0 get_tree().root.add_child.call(talk) diff --git a/levels/ui/musictest.gd b/levels/ui/musictest.gd index 495418e..8ac3091 100644 --- a/levels/ui/musictest.gd +++ b/levels/ui/musictest.gd @@ -34,7 +34,7 @@ func _input(event): # Mouse in viewport coordinates. if Input.is_action_just_pressed("ui_cancel"): _on_back_pressed() - if Input.is_key_pressed(KEY_X) || Input.is_joy_button_pressed(0,JOY_BUTTON_X): + if Input.is_action_just_pressed("stopmusic"): infobox.set_text("") player.stop() #print("Mouse Click/Unclick at: ", event.position) diff --git a/levels/ui/sfxtest.gd b/levels/ui/sfxtest.gd index 5a9e8be..f50998b 100644 --- a/levels/ui/sfxtest.gd +++ b/levels/ui/sfxtest.gd @@ -32,7 +32,7 @@ func _input(event): # Mouse in viewport coordinates. if Input.is_action_just_pressed("ui_cancel"): _on_back_pressed() - if Input.is_key_pressed(KEY_X) || Input.is_joy_button_pressed(0,JOY_BUTTON_X): + if Input.is_action_just_pressed("stopmusic"): player.stop() #print("Mouse Click/Unclick at: ", event.position) # if highlighted == 1: diff --git a/project.godot b/project.godot index e237767..ff77d7d 100644 --- a/project.godot +++ b/project.godot @@ -42,6 +42,18 @@ ui_cancel={ , Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":0,"pressure":0.0,"pressed":false,"script":null) ] } +shoot={ +"deadzone": 0.5, +"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":90,"key_label":0,"unicode":0,"echo":false,"script":null) +, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":0,"pressure":0.0,"pressed":false,"script":null) +] +} +stopmusic={ +"deadzone": 0.5, +"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":88,"key_label":0,"unicode":0,"echo":false,"script":null) +, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":2,"pressure":0.0,"pressed":false,"script":null) +] +} [physics] diff --git a/sprites/common/bullet/fireball.gd b/sprites/common/bullet/fireball.gd new file mode 100644 index 0000000..505d734 --- /dev/null +++ b/sprites/common/bullet/fireball.gd @@ -0,0 +1,26 @@ +extends Area2D +var velocity: Vector2 = Vector2() + +# Called when the node enters the scene tree for the first time. +func _ready(): + pass # Replace with function body. + + +# Called every frame. 'delta' is the elapsed time since the previous frame. +func _process(delta): + pass + +func _physics_process(delta): + position += velocity * delta + + +func _on_body_entered(body): + #if body.is_in_group("players"): + # Global.live = 2 + #elif body.is_in_group("enemies"): + # Global.live = 3 + queue_free() + + +func _on_screen_exited(): + queue_free() diff --git a/sprites/common/bullet/fireball.tscn b/sprites/common/bullet/fireball.tscn index 500e245..ded6f3a 100644 --- a/sprites/common/bullet/fireball.tscn +++ b/sprites/common/bullet/fireball.tscn @@ -1,15 +1,21 @@ -[gd_scene load_steps=3 format=3 uid="uid://b2gxwerkgrbp7"] +[gd_scene load_steps=4 format=3 uid="uid://dibpmnnxefgi2"] +[ext_resource type="Script" path="res://sprites/common/bullet/fireball.gd" id="1_o7kcl"] [ext_resource type="Texture2D" uid="uid://cfqxhmvjstwcd" path="res://sprites/common/bullet/fireball.png" id="1_ues2l"] -[sub_resource type="RectangleShape2D" id="RectangleShape2D_tqfch"] +[sub_resource type="RectangleShape2D" id="RectangleShape2D_g125y"] size = Vector2(47, 60) -[node name="Fireball" type="RigidBody2D"] +[node name="Fireball" type="Area2D"] +script = ExtResource("1_o7kcl") [node name="Sprite2D" type="Sprite2D" parent="."] texture = ExtResource("1_ues2l") [node name="CollisionShape2D" type="CollisionShape2D" parent="."] position = Vector2(0.5, 0) -shape = SubResource("RectangleShape2D_tqfch") +shape = SubResource("RectangleShape2D_g125y") + +[node name="VisibleOnScreenEnabler2D" type="VisibleOnScreenEnabler2D" parent="."] + +[connection signal="body_entered" from="." to="." method="_on_body_entered"] diff --git a/sprites/common/midori/lily.gd b/sprites/common/midori/lily.gd index 3c1b9bf..57d7a05 100644 --- a/sprites/common/midori/lily.gd +++ b/sprites/common/midori/lily.gd @@ -48,4 +48,4 @@ func _physics_process(delta): anim.play("widle") else: anim.play("sidle") - move_and_slide() + #move_and_slide() diff --git a/sprites/common/natasha/natasha.gd b/sprites/common/natasha/natasha.gd index 3c1b9bf..57d7a05 100644 --- a/sprites/common/natasha/natasha.gd +++ b/sprites/common/natasha/natasha.gd @@ -48,4 +48,4 @@ func _physics_process(delta): anim.play("widle") else: anim.play("sidle") - move_and_slide() + #move_and_slide() diff --git a/sprites/common/player/player.gd b/sprites/common/player/player.gd index e1e79b3..b6b541e 100644 --- a/sprites/common/player/player.gd +++ b/sprites/common/player/player.gd @@ -7,11 +7,12 @@ var angle = 2 var sprite var anim var csprite - +var bpress = false # Get the gravity from the project settings to be synced with RigidBody nodes. var gravity = ProjectSettings.get_setting("physics/2d/default_gravity") func _ready(): + add_to_group("players") anim = $AnimationPlayer sprite = $Sprite2D if Global.debug: @@ -20,7 +21,6 @@ func _ready(): else: csprite = Global.cpchar sprite.texture = load(Global.pchars[Global.party[Global.cpchar]]) - csprite func _physics_process(delta): # Add the gravity. @@ -66,3 +66,24 @@ func _physics_process(delta): else: anim.play("sidle") move_and_slide() + +func _input(event): + if Global.live == 1: + if Input.is_action_just_pressed("shoot") && !bpress && Global.live == 1: + bpress = true + var bullet + if Global.debug: + bullet = load(Global.pbbullets[Global.dparty[Global.dcpchar]]) + else: + bullet = load(Global.pbbullets[Global.party[Global.cpchar]]) + var new_bullet = bullet.instantiate() + new_bullet.velocity = Vector2(0, -500).rotated(deg_to_rad(angle * 90)) + var rposition = Vector2(0, -96).rotated(deg_to_rad(angle * 90)) + if angle == 2: + new_bullet.position = Vector2(position.x + rposition.x, position.y + rposition.y + 98) + else: + new_bullet.position = Vector2(position.x + rposition.x, position.y + rposition.y) + if new_bullet.position.x > 0 && new_bullet.position.y > 0 && new_bullet.position.x < 1280 && new_bullet.position.y < 720: + get_parent().add_child(new_bullet) + elif Input.is_action_just_released("shoot") && bpress: + bpress = false