correct camera offset for vertical movement, add basic main menu.
This commit is contained in:
parent
e90949a8d9
commit
f3b402b1fd
55
MB_FYP/scenes/main_menu.tscn
Normal file
55
MB_FYP/scenes/main_menu.tscn
Normal file
|
|
@ -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
|
||||||
|
|
@ -45,21 +45,21 @@ public partial class asteroid : Area2D
|
||||||
switch (size)
|
switch (size)
|
||||||
{
|
{
|
||||||
case AsteroidSize.LARGE:
|
case AsteroidSize.LARGE:
|
||||||
Speed = rand.Next(50, 100);
|
Speed = rand.Next(5, 15);
|
||||||
Sprite.Texture = GD.Load<Texture2D>(LargeAsteroidTexture[rand.Next(3)]);
|
Sprite.Texture = GD.Load<Texture2D>(LargeAsteroidTexture[rand.Next(3)]);
|
||||||
ColShapeL = GD.Load<CircleShape2D>("res://assets/CollisionShapes/asteroid_cshape_big.tres");
|
ColShapeL = GD.Load<CircleShape2D>("res://assets/CollisionShapes/asteroid_cshape_big.tres");
|
||||||
ColShape.SetDeferred("shape", ColShapeL);
|
ColShape.SetDeferred("shape", ColShapeL);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case AsteroidSize.MEDIUM:
|
case AsteroidSize.MEDIUM:
|
||||||
Speed = rand.Next(100, 150);
|
Speed = rand.Next(25, 50);
|
||||||
Sprite.Texture = GD.Load<Texture2D>(MediumAsteroidTexture[rand.Next(3)]);
|
Sprite.Texture = GD.Load<Texture2D>(MediumAsteroidTexture[rand.Next(3)]);
|
||||||
ColShapeL = GD.Load<CircleShape2D>("res://assets/CollisionShapes/asteroid_cshape_medcircle.tres");
|
ColShapeL = GD.Load<CircleShape2D>("res://assets/CollisionShapes/asteroid_cshape_medcircle.tres");
|
||||||
ColShape.SetDeferred("shape", ColShapeL);
|
ColShape.SetDeferred("shape", ColShapeL);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case AsteroidSize.SMALL:
|
case AsteroidSize.SMALL:
|
||||||
Speed = rand.Next(150, 200);
|
Speed = rand.Next(50, 75);
|
||||||
Sprite.Texture = GD.Load<Texture2D>(SmallAsteroidTexture[rand.Next(3)]);
|
Sprite.Texture = GD.Load<Texture2D>(SmallAsteroidTexture[rand.Next(3)]);
|
||||||
ColShapeL = GD.Load<CircleShape2D>("res://assets/CollisionShapes/asteroid_cshape_smallcircle.tres");
|
ColShapeL = GD.Load<CircleShape2D>("res://assets/CollisionShapes/asteroid_cshape_smallcircle.tres");
|
||||||
ColShape.SetDeferred("shape", ColShapeL);
|
ColShape.SetDeferred("shape", ColShapeL);
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,8 @@ using System;
|
||||||
|
|
||||||
public partial class camera : Camera2D
|
public partial class camera : Camera2D
|
||||||
{
|
{
|
||||||
[Export] public Vector2 OffsetAmount = new Vector2(100, 0);
|
[Export] public Vector2 OffsetAmount = new Vector2(50, 70);
|
||||||
[Export] public float SmoothingSpeed = 0.1f;
|
[Export] public float SmoothingSpeed = 0.05f;
|
||||||
// Called when the node enters the scene tree for the first time.
|
// Called when the node enters the scene tree for the first time.
|
||||||
|
|
||||||
public CharacterBody2D Player;
|
public CharacterBody2D Player;
|
||||||
|
|
@ -15,10 +15,8 @@ public partial class camera : Camera2D
|
||||||
Player = GetParent<CharacterBody2D>();
|
Player = GetParent<CharacterBody2D>();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Called every frame. 'delta' is the elapsed time since the previous frame.
|
|
||||||
public override void _Process(double delta)
|
public override void _Process(double delta)
|
||||||
{
|
{
|
||||||
|
|
||||||
Vector2 playerPos = Player.GlobalPosition;
|
Vector2 playerPos = Player.GlobalPosition;
|
||||||
Vector2 playerV = Player.Velocity;
|
Vector2 playerV = Player.Velocity;
|
||||||
Vector2 direction = playerV.Normalized();
|
Vector2 direction = playerV.Normalized();
|
||||||
|
|
|
||||||
28
MB_FYP/script/main_menu.cs
Normal file
28
MB_FYP/script/main_menu.cs
Normal file
|
|
@ -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<Button>("StartButton").Pressed += OnStartButtonPressed;
|
||||||
|
GetNode<Button>("ExitButton").Pressed += OnExitButtonPressed;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnStartButtonPressed()
|
||||||
|
{
|
||||||
|
GetTree().ChangeSceneToFile("res://scenes/game.tscn");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnExitButtonPressed()
|
||||||
|
{
|
||||||
|
GetTree().Quit();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||||
|
public override void _Process(double delta)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in a new issue