From f3b402b1fd1410936df3dc8246ec398b25314396 Mon Sep 17 00:00:00 2001 From: rsxri Date: Thu, 15 Aug 2024 14:15:33 +0100 Subject: [PATCH] correct camera offset for vertical movement, add basic main menu. --- MB_FYP/scenes/main_menu.tscn | 55 ++++++++++++++++++++++++++++++++++++ MB_FYP/script/asteroid.cs | 6 ++-- MB_FYP/script/camera.cs | 6 ++-- MB_FYP/script/main_menu.cs | 28 ++++++++++++++++++ 4 files changed, 88 insertions(+), 7 deletions(-) create mode 100644 MB_FYP/scenes/main_menu.tscn create mode 100644 MB_FYP/script/main_menu.cs diff --git a/MB_FYP/scenes/main_menu.tscn b/MB_FYP/scenes/main_menu.tscn new file mode 100644 index 0000000..93c3741 --- /dev/null +++ b/MB_FYP/scenes/main_menu.tscn @@ -0,0 +1,55 @@ +[gd_scene load_steps=2 format=3 uid="uid://bh3heupvlc1ok"] + +[ext_resource type="Script" path="res://script/main_menu.cs" id="1_wxwq5"] + +[node name="MainMenu" type="Control"] +layout_mode = 3 +anchors_preset = 0 +offset_right = 40.0 +offset_bottom = 40.0 +script = ExtResource("1_wxwq5") + +[node name="StartButton" type="Button" parent="."] +layout_mode = 0 +offset_right = 8.0 +offset_bottom = 8.0 +text = "Start Game +" + +[node name="ExitButton" type="Button" parent="."] +layout_mode = 1 +anchors_preset = -1 +anchor_left = -1.52 +anchor_top = 0.5 +anchor_right = -1.52 +anchor_bottom = 0.5 +offset_left = 61.8 +offset_top = 13.0 +offset_right = 157.8 +offset_bottom = 44.0 +text = "Exit Game +" + +[node name="OptionButton" type="Button" parent="."] +offset_top = 68.0 +offset_right = 96.0 +offset_bottom = 99.0 +text = "Options +" + +[node name="Label" type="Label" parent="."] +layout_mode = 1 +anchors_preset = -1 +anchor_left = 16.1 +anchor_top = 5.7 +anchor_right = 33.175 +anchor_bottom = 10.4 +offset_left = -2.0 +offset_top = 2.99998 +offset_right = -2.00012 +offset_bottom = 2.99997 +grow_horizontal = 0 +grow_vertical = 0 +theme_override_font_sizes/font_size = 80 +text = "Name in Progress" +horizontal_alignment = 1 diff --git a/MB_FYP/script/asteroid.cs b/MB_FYP/script/asteroid.cs index cd92ba4..dddd3be 100644 --- a/MB_FYP/script/asteroid.cs +++ b/MB_FYP/script/asteroid.cs @@ -45,21 +45,21 @@ public partial class asteroid : Area2D switch (size) { case AsteroidSize.LARGE: - Speed = rand.Next(50, 100); + Speed = rand.Next(5, 15); Sprite.Texture = GD.Load(LargeAsteroidTexture[rand.Next(3)]); ColShapeL = GD.Load("res://assets/CollisionShapes/asteroid_cshape_big.tres"); ColShape.SetDeferred("shape", ColShapeL); break; case AsteroidSize.MEDIUM: - Speed = rand.Next(100, 150); + Speed = rand.Next(25, 50); Sprite.Texture = GD.Load(MediumAsteroidTexture[rand.Next(3)]); ColShapeL = GD.Load("res://assets/CollisionShapes/asteroid_cshape_medcircle.tres"); ColShape.SetDeferred("shape", ColShapeL); break; case AsteroidSize.SMALL: - Speed = rand.Next(150, 200); + Speed = rand.Next(50, 75); Sprite.Texture = GD.Load(SmallAsteroidTexture[rand.Next(3)]); ColShapeL = GD.Load("res://assets/CollisionShapes/asteroid_cshape_smallcircle.tres"); ColShape.SetDeferred("shape", ColShapeL); diff --git a/MB_FYP/script/camera.cs b/MB_FYP/script/camera.cs index 281aa51..9cfa625 100644 --- a/MB_FYP/script/camera.cs +++ b/MB_FYP/script/camera.cs @@ -3,8 +3,8 @@ using System; public partial class camera : Camera2D { - [Export] public Vector2 OffsetAmount = new Vector2(100, 0); - [Export] public float SmoothingSpeed = 0.1f; + [Export] public Vector2 OffsetAmount = new Vector2(50, 70); + [Export] public float SmoothingSpeed = 0.05f; // Called when the node enters the scene tree for the first time. public CharacterBody2D Player; @@ -15,10 +15,8 @@ public partial class camera : Camera2D Player = GetParent(); } - // Called every frame. 'delta' is the elapsed time since the previous frame. public override void _Process(double delta) { - Vector2 playerPos = Player.GlobalPosition; Vector2 playerV = Player.Velocity; Vector2 direction = playerV.Normalized(); diff --git a/MB_FYP/script/main_menu.cs b/MB_FYP/script/main_menu.cs new file mode 100644 index 0000000..6d0bf2f --- /dev/null +++ b/MB_FYP/script/main_menu.cs @@ -0,0 +1,28 @@ +using Godot; +using System; + +public partial class main_menu : Control +{ + // Called when the node enters the scene tree for the first time. + public override void _Ready() + { + //Connecting Buttons + GetNode