checkout Gameplay

Gameplay
Sascha 2024-12-19 09:50:10 +07:00
parent 0dc7e3da4e
commit eb51df06d2
12 changed files with 67 additions and 60 deletions

@ -0,0 +1,10 @@
<component name="libraryTable">
<library name="GdSdk Master" type="GdScript">
<properties path="$USER_HOME$/.cache/JetBrains/Rider2024.3/projects/.idea.godot-space shooter.9ec0b472/sdk/GdSdk Master" version="Master" date="2024-06-01T15:14:16.000+02:00" />
<CLASSES />
<JAVADOC />
<SOURCES>
<root url="file://$USER_HOME$/.cache/JetBrains/Rider2024.3/projects/.idea.godot-space shooter.9ec0b472/sdk/GdSdk Master" />
</SOURCES>
</library>
</component>

@ -1,6 +0,0 @@
<Project Sdk="Godot.NET.Sdk/4.2.0-dev.5">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<EnableDynamicLoading>true</EnableDynamicLoading>
</PropertyGroup>
</Project>

@ -1,6 +0,0 @@
<Project Sdk="Godot.NET.Sdk/4.2.0-dev.6">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<EnableDynamicLoading>true</EnableDynamicLoading>
</PropertyGroup>
</Project>

@ -1,6 +0,0 @@
<Project Sdk="Godot.NET.Sdk/4.2.0-dev.6">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<EnableDynamicLoading>true</EnableDynamicLoading>
</PropertyGroup>
</Project>

@ -1,6 +0,0 @@
<Project Sdk="Godot.NET.Sdk/4.2.0-dev.6">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<EnableDynamicLoading>true</EnableDynamicLoading>
</PropertyGroup>
</Project>

@ -1,6 +0,0 @@
<Project Sdk="Godot.NET.Sdk/4.2.0-dev.6">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<EnableDynamicLoading>true</EnableDynamicLoading>
</PropertyGroup>
</Project>

@ -1,10 +0,0 @@
<Project Sdk="Godot.NET.Sdk/4.3.0-dev.2">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<EnableDynamicLoading>true</EnableDynamicLoading>
<RootNamespace>GodotspaceShooter</RootNamespace>
</PropertyGroup>
<ItemGroup>
<Folder Include="Scenes\" />
</ItemGroup>
</Project>

@ -1,6 +1,6 @@
[gd_scene load_steps=9 format=3 uid="uid://tlr55u0gn20l"]
[ext_resource type="Script" path="res://Scripts/PlayerShip.cs" id="1_cpbf1"]
[ext_resource type="Script" uid="uid://caqvdf3pfr3d" path="res://Scripts/PlayerShip.cs" id="1_cpbf1"]
[ext_resource type="PackedScene" uid="uid://d0bi42b1tkjre" path="res://Packed-Scenes/PlayerShipExplosion.tscn" id="2_13dyf"]
[ext_resource type="ArrayMesh" uid="uid://68qoj4h2xh77" path="res://Meshes/PlayerShip.mesh" id="3_716so"]
[ext_resource type="Texture2D" uid="uid://dd4f3mkovliof" path="res://Textures/part_jet_flare_dff.png" id="4_87x8f"]
@ -26,6 +26,7 @@ gravity_scale = 0.0
[node name="CollisionShape3D" type="CollisionShape3D" parent="RigidBody3D"]
shape = SubResource("SphereShape3D_330dr")
debug_color = Color(0, 0.6, 0.7, 0.42)
[node name="PlayerShipMesh" type="MeshInstance3D" parent="RigidBody3D"]
transform = Transform3D(0.01, 0, 0, 0, 0, -0.01, 0, 0.01, 0, 0, -0.0836085, 0)

@ -1,2 +1,37 @@
# Godot-SpaceShooter
#### Video Demo: https://youtu.be/K4u77W67QLk
#### Description: CS50 Final Project: Godot-SpaceShooter
- classical space shooter game made with Godot in C#
- you start with the request to start a countdown with a key stroke
- then a countdown starts from 3 and let the game start
- from the top of the game window there are dropping asteroids towards your space ship and you have to destroy them
- when an asteroid leaves the game window and the bottom or hits the space ship, you loose a life
- if you have no lives left, the game is over and you get a highscore
- after finishing some asteroids you raise the level and the asteroids are getting fast and more of them are spawning
- the asteroids are containing rigidbodies and are physically calculating, so that they are bouncing at each other or when they have been shot
## Main Script description
### InputManager
- the input is got by a const string description of the input from Godot
- It is checked if the game is in countdown, pause or gaming mode
- If in countdown mode, the counting is started
- If in pause mode, the pause mode is beeing switched
- If in gamemode the direction and rotation of the spaceship is set and after normalization written to the playership script
- Also the shooting boolean of the playership script is set whether eh fire button is hold or not
## PlayShip
- different public parameters for the direction, shooting, lives and so on
- inside the physics processing method it is checked whether the spaceship should move or not
- if the length of the direction vector is above zero, the jet is visible and the collision is checked for MoveAndCollide
- if there is the GameArea boundary box hitted, the ship is not moving any further
- if there is an asteroid hitted an explosion at the ship is triggered via an event and also the asteroid will be destroyed as the event of the asteroid script is called
- the spaceship explosion method instantiate an explosion from a packed-scene as a GPU particle system and set it to the right position and starts the emit
## Asteroid
- the asteroid have random starting position and a random size in a definitive range
- the mesh, rigidbody and collisionshape are adjusted due to the actual size
- the speed and rotation of the new asteroids are also a little bit random
- the asteroids are checking by themself if there colide with something
- it also triggers the explosion (maybe therefore I have them doubled -> bug found by writing this Readme ;))
- they also cannot leave the gamearea
- the hit a laser beam and will be destroyed by them (by calling the Explode method)
- the Explode method plays a sound via the SoundManager, instantiate the particle system
- the number of asteroids of the GameManager is updated and the asteroid is been destroyed.

@ -155,6 +155,7 @@ process_mode = 1
script = ExtResource("9_rsrr5")
asteroids = Array[PackedScene]([ExtResource("5_do6ba"), ExtResource("6_tqoe7"), ExtResource("7_v6ul2")])
asteroidsContainer = NodePath("../Asteroids")
Debug = null
[node name="InputManager" type="Node" parent="."]
process_mode = 3

@ -5,12 +5,12 @@ namespace GodotspaceShooter.Scripts;
public partial class InputManager : Node
{
private const string GAME_PAUSE = "Game_Pause";
private const string PLAYER_MOVE_FORWARD = "Player_Move_Forward";
private const string PLAYER_MOVE_BACKWARDS = "Player_Move_Backwards";
private const string PLAYER_MOVE_LEFT = "Player_Move_Left";
private const string PLAYER_MOVE_RIGHT = "Player_Move_Right";
private const string PLAYER_FIRE = "Player_Fire";
private const string gamePause = "Game_Pause";
private const string playerMoveForward = "Player_Move_Forward";
private const string playerMoveBackwards = "Player_Move_Backwards";
private const string playerMoveLeft = "Player_Move_Left";
private const string playerMoveRight = "Player_Move_Right";
private const string playerFire = "Player_Fire";
private float speed;
private Vector3 moveDirection = Vector3.Zero;
@ -29,46 +29,46 @@ public partial class InputManager : Node
if (GameManager.Instance.Countdown && Input.IsAnythingPressed()) StartCountdown?.Invoke(this,EventArgs.Empty);
//Pause
if (Input.IsActionJustReleased(GAME_PAUSE)) GameManager.Instance.GamePaused = GameManager.Instance.GamePaused switch { true => false, false => true };
if (Input.IsActionJustReleased(gamePause)) GameManager.Instance.GamePaused = GameManager.Instance.GamePaused switch { true => false, false => true };
if (GameManager.Instance.GamePaused || GameManager.Instance.Countdown || GameManager.Instance.GameOver) return;
//Movement
if (Input.IsActionPressed(PLAYER_MOVE_FORWARD)) {
if (Input.IsActionPressed(playerMoveForward)) {
moveDirection.Z = -1;
speed += acceleration;
rotationDirection.X = -1;
}
if (Input.IsActionJustReleased(PLAYER_MOVE_FORWARD)) {
if (Input.IsActionJustReleased(playerMoveForward)) {
moveDirection.Z = 0f;
rotationDirection.X = 0f;
}
if (Input.IsActionPressed(PLAYER_MOVE_BACKWARDS)) {
if (Input.IsActionPressed(playerMoveBackwards)) {
moveDirection.Z = 1;
speed += acceleration;
rotationDirection.X = 1;
}
if (Input.IsActionJustReleased(PLAYER_MOVE_BACKWARDS)) {
if (Input.IsActionJustReleased(playerMoveBackwards)) {
moveDirection.Z = 0f;
rotationDirection.X = 0f;
}
if (Input.IsActionPressed(PLAYER_MOVE_LEFT)) {
if (Input.IsActionPressed(playerMoveLeft)) {
moveDirection.X = -1;
speed += acceleration;
rotationDirection.Z = -1;
}
if (Input.IsActionJustReleased(PLAYER_MOVE_LEFT)) {
if (Input.IsActionJustReleased(playerMoveLeft)) {
moveDirection.X = 0f;
rotationDirection.Z = 0f;
}
if (Input.IsActionPressed(PLAYER_MOVE_RIGHT)) {
if (Input.IsActionPressed(playerMoveRight)) {
moveDirection.X = 1;
speed += acceleration;
rotationDirection.Z = 1;
}
if (Input.IsActionJustReleased(PLAYER_MOVE_RIGHT)) {
if (Input.IsActionJustReleased(playerMoveRight)) {
moveDirection.X = 0f;
rotationDirection.Z = 0f;
}
@ -84,7 +84,7 @@ public partial class InputManager : Node
PlayerShip.Instance.Speed = speed;
//Shooting
if (Input.IsActionJustPressed(PLAYER_FIRE)) PlayerShip.Instance.Shooting = true;
if (Input.IsActionJustPressed(playerFire)) PlayerShip.Instance.Shooting = true;
// if (Input.IsActionJustReleased(PLAYER_FIRE)) PlayerShip.Instance.Shooting = false;
}
}

@ -15,7 +15,7 @@ public partial class PlayerShip : Node3D {
private float jetTimer = jetTimerMax;
private float maxSpeed = 5f;
private float speed;
public float Acceleration { get; private set; } = .5f;
public float Acceleration { get; private set; } = 1f;
public float Speed {
get => speed;
@ -48,7 +48,7 @@ public partial class PlayerShip : Node3D {
public override void _PhysicsProcess(double delta) {
//Movement
GD.Print($"Move {MoveDirection.X}, {MoveDirection.Z}, Speed {Speed}, Rot {RotationDirection.X}, {RotationDirection.Z}");
// GD.Print($"Move {MoveDirection.X}, {MoveDirection.Z}, Speed {Speed}, Rot {RotationDirection.X}, {RotationDirection.Z}");
if (Speed > 0f) Speed -= Acceleration * (float)delta * 10f;
if (MoveDirection.Length() > 0) {
@ -73,7 +73,7 @@ public partial class PlayerShip : Node3D {
}
//Rotation
rbPlayer.RotationDegrees = RotationDirection;
rbPlayer.RotationDegrees = RotationDirection * 30f;
}
public void Explode(Vector3 collisionPosition) {