diff --git a/Nodes/Keys.png b/Nodes/Keys.png new file mode 100644 index 0000000..5d531bb Binary files /dev/null and b/Nodes/Keys.png differ diff --git a/Nodes/Keys.png.import b/Nodes/Keys.png.import new file mode 100644 index 0000000..d01b756 --- /dev/null +++ b/Nodes/Keys.png.import @@ -0,0 +1,36 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://7qppu15lvd1j" +path.s3tc="res://.godot/imported/Keys.png-cbe66c8e5c30f379fc899081aa9795b6.s3tc.ctex" +path.etc2="res://.godot/imported/Keys.png-cbe66c8e5c30f379fc899081aa9795b6.etc2.ctex" +metadata={ +"imported_formats": ["s3tc", "etc2"], +"vram_texture": true +} + +[deps] + +source_file="res://Nodes/Keys.png" +dest_files=["res://.godot/imported/Keys.png-cbe66c8e5c30f379fc899081aa9795b6.s3tc.ctex", "res://.godot/imported/Keys.png-cbe66c8e5c30f379fc899081aa9795b6.etc2.ctex"] + +[params] + +compress/mode=2 +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/bptc_ldr=0 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=true +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=0 diff --git a/Nodes/Player.tscn b/Nodes/Player.tscn index 6a99028..4927bd4 100644 --- a/Nodes/Player.tscn +++ b/Nodes/Player.tscn @@ -1,6 +1,7 @@ -[gd_scene load_steps=4 format=3 uid="uid://vwjd5od63jgh"] +[gd_scene load_steps=5 format=3 uid="uid://vwjd5od63jgh"] [ext_resource type="Script" path="res://scripts/Player.gd" id="1_dta8q"] +[ext_resource type="Texture2D" uid="uid://7qppu15lvd1j" path="res://Nodes/Keys.png" id="2_h1504"] [sub_resource type="CylinderShape3D" id="CylinderShape3D_h8ivv"] radius = 0.494048 @@ -21,3 +22,24 @@ shape = SubResource("CylinderShape3D_h8ivv") [node name="CollisionShape3D" type="CollisionShape3D" parent="HitBox"] transform = Transform3D(2.74062, 0, 0, 0, 2.24144, 0, 0, 0, 2.70992, 0, 0, 0) shape = SubResource("CylinderShape3D_8lrgm") + +[node name="MiniGameButton0" type="Sprite3D" parent="."] +transform = Transform3D(8, 0, 0, 0, -3.93403e-07, 1, 0, -9, -4.37114e-08, 0, 6, 0) +texture = ExtResource("2_h1504") +hframes = 5 +vframes = 8 +frame = 26 + +[node name="MiniGameButton1" type="Sprite3D" parent="."] +transform = Transform3D(8, 0, 0, 0, -3.93403e-07, 1, 0, -9, -4.37114e-08, 1.5, 6, 0) +texture = ExtResource("2_h1504") +hframes = 5 +vframes = 8 +frame = 26 + +[node name="MiniGameButton2" type="Sprite3D" parent="."] +transform = Transform3D(8, 0, 0, 0, -3.93403e-07, 1, 0, -9, -4.37114e-08, 3, 6, 0) +texture = ExtResource("2_h1504") +hframes = 5 +vframes = 8 +frame = 26 diff --git a/scripts/Player.gd b/scripts/Player.gd index d547757..66ef5fa 100644 --- a/scripts/Player.gd +++ b/scripts/Player.gd @@ -14,10 +14,68 @@ var idle enum TYPE {AMMO, GUNPOWDER, FUEL} +var P1inMiniGame = 0 +var P2inMiniGame = 0 +var MiniGame = [-1, -1, -1] +var MiniGamePos = 0 +var rng = RandomNumberGenerator.new() #---------------Methods--------------# func _ready(): walking = "walking" idle = "idle" + $MiniGameButton0.hide() + $MiniGameButton1.hide() + $MiniGameButton2.hide() + +func miniGameColor(input: int, red: int): + if(input == 0): + $MiniGameButton0.modulate = Color(1,1,red) + if(input == 1): + $MiniGameButton1.modulate = Color(1,1,red) + if(input == 2): + $MiniGameButton2.modulate = Color(1,1,red) + +func miniGameReset(): + MiniGamePos = 0 + miniGameColor(0,1) + miniGameColor(1,1) + miniGameColor(2,1) + MiniGame[0] = rng.randi_range(0, 3) + miniGameSetArrow(0) + MiniGame[1] = rng.randi_range(0, 3) + miniGameSetArrow(1) + MiniGame[2] = rng.randi_range(0, 3) + miniGameSetArrow(2) + +func miniGameSetArrow(buttonNr: int): + if(buttonNr == 0): + $MiniGameButton0.frame = 26 + MiniGame[0] + if(buttonNr == 1): + $MiniGameButton1.frame = 26 + MiniGame[1] + if(buttonNr == 2): + $MiniGameButton2.frame = 26 + MiniGame[2] + +func miniGameCheck(input : int): + if(input == MiniGame[MiniGamePos]): + miniGameColor(MiniGamePos, 0) + MiniGamePos = MiniGamePos +1 + else: + miniGameReset() + + if(MiniGamePos >= 3): + $MiniGameButton0.hide() + $MiniGameButton1.hide() + $MiniGameButton2.hide() + P1inMiniGame = 0 + miniGameReset() + +func _process(delta): + if Input.is_action_just_pressed("p1_extra"): + if(P1inMiniGame == 0): + P1inMiniGame = 1 + $MiniGameButton0.show() + $MiniGameButton1.show() + $MiniGameButton2.show() func _physics_process(delta): if(velocity.length() > 0): @@ -40,23 +98,43 @@ func _physics_process(delta): func check_input(): if is_player1: - if Input.is_action_pressed("p1_left"): - movement.x -= 1 - if Input.is_action_pressed("p1_right"): - movement.x += 1 - if Input.is_action_pressed("p1_up"): - movement.z -= 1 - if Input.is_action_pressed("p1_down"): - movement.z += 1 + if(!P1inMiniGame): + if Input.is_action_pressed("p1_left"): + movement.x -= 1 + if Input.is_action_pressed("p1_right"): + movement.x += 1 + if Input.is_action_pressed("p1_up"): + movement.z -= 1 + if Input.is_action_pressed("p1_down"): + movement.z += 1 + else: + if Input.is_action_just_pressed("p1_up"): + miniGameCheck(0) + if Input.is_action_just_pressed("p1_right"): + miniGameCheck(1) + if Input.is_action_just_pressed("p1_down"): + miniGameCheck(2) + if Input.is_action_just_pressed("p1_left"): + miniGameCheck(3) else: - if Input.is_action_pressed("p2_left"): - movement.x -= 1 - if Input.is_action_pressed("p2_right"): - movement.x += 1 - if Input.is_action_pressed("p2_up"): - movement.z -= 1 - if Input.is_action_pressed("p2_down"): - movement.z += 1 + if(!P2inMiniGame): + if Input.is_action_pressed("p2_left"): + movement.x -= 1 + if Input.is_action_pressed("p2_right"): + movement.x += 1 + if Input.is_action_pressed("p2_up"): + movement.z -= 1 + if Input.is_action_pressed("p2_down"): + movement.z += 1 + else: + if Input.is_action_just_pressed("p2_up"): + miniGameCheck(0) + if Input.is_action_just_pressed("p2_right"): + miniGameCheck(1) + if Input.is_action_just_pressed("p2_down"): + miniGameCheck(2) + if Input.is_action_just_pressed("p2_left"): + miniGameCheck(3) func check_interaction(): var action