Add font assets, implement scoring feature

This commit is contained in:
maximus 2023-12-09 07:49:33 +00:00
parent 2405cdbcd9
commit 9d052b0489
28 changed files with 482 additions and 5 deletions

Binary file not shown.

View file

@ -0,0 +1,33 @@
[remap]
importer="font_data_dynamic"
type="FontFile"
uid="uid://ounnadoh8cse"
path="res://.godot/imported/Kenney Blocks.ttf-64632e973be3cbbb5de78d891890ee05.fontdata"
[deps]
source_file="res://assets/Fonts/Kenney Blocks.ttf"
dest_files=["res://.godot/imported/Kenney Blocks.ttf-64632e973be3cbbb5de78d891890ee05.fontdata"]
[params]
Rendering=null
antialiasing=1
generate_mipmaps=false
multichannel_signed_distance_field=false
msdf_pixel_range=8
msdf_size=48
allow_system_fallback=true
force_autohinter=false
hinting=1
subpixel_positioning=1
oversampling=0.0
Fallbacks=null
fallbacks=[]
Compress=null
compress=true
preload=[]
language_support={}
script_support={}
opentype_features={}

Binary file not shown.

View file

@ -0,0 +1,33 @@
[remap]
importer="font_data_dynamic"
type="FontFile"
uid="uid://dtpvg4lmre10g"
path="res://.godot/imported/Kenney Future Narrow.ttf-301df4fdb0f9e9f2e07ce3c0f461dccd.fontdata"
[deps]
source_file="res://assets/Fonts/Kenney Future Narrow.ttf"
dest_files=["res://.godot/imported/Kenney Future Narrow.ttf-301df4fdb0f9e9f2e07ce3c0f461dccd.fontdata"]
[params]
Rendering=null
antialiasing=1
generate_mipmaps=false
multichannel_signed_distance_field=false
msdf_pixel_range=8
msdf_size=48
allow_system_fallback=true
force_autohinter=false
hinting=1
subpixel_positioning=1
oversampling=0.0
Fallbacks=null
fallbacks=[]
Compress=null
compress=true
preload=[]
language_support={}
script_support={}
opentype_features={}

Binary file not shown.

View file

@ -0,0 +1,33 @@
[remap]
importer="font_data_dynamic"
type="FontFile"
uid="uid://vfataagjvmy0"
path="res://.godot/imported/Kenney Future.ttf-d046583541bdf2b4d8304d362a680449.fontdata"
[deps]
source_file="res://assets/Fonts/Kenney Future.ttf"
dest_files=["res://.godot/imported/Kenney Future.ttf-d046583541bdf2b4d8304d362a680449.fontdata"]
[params]
Rendering=null
antialiasing=1
generate_mipmaps=false
multichannel_signed_distance_field=false
msdf_pixel_range=8
msdf_size=48
allow_system_fallback=true
force_autohinter=false
hinting=1
subpixel_positioning=1
oversampling=0.0
Fallbacks=null
fallbacks=[]
Compress=null
compress=true
preload=[]
language_support={}
script_support={}
opentype_features={}

Binary file not shown.

View file

@ -0,0 +1,33 @@
[remap]
importer="font_data_dynamic"
type="FontFile"
uid="uid://csc0mglr25e78"
path="res://.godot/imported/Kenney High Square.ttf-31cf241a9e4b08ed1ede4c4ece8b8295.fontdata"
[deps]
source_file="res://assets/Fonts/Kenney High Square.ttf"
dest_files=["res://.godot/imported/Kenney High Square.ttf-31cf241a9e4b08ed1ede4c4ece8b8295.fontdata"]
[params]
Rendering=null
antialiasing=1
generate_mipmaps=false
multichannel_signed_distance_field=false
msdf_pixel_range=8
msdf_size=48
allow_system_fallback=true
force_autohinter=false
hinting=1
subpixel_positioning=1
oversampling=0.0
Fallbacks=null
fallbacks=[]
Compress=null
compress=true
preload=[]
language_support={}
script_support={}
opentype_features={}

Binary file not shown.

View file

@ -0,0 +1,33 @@
[remap]
importer="font_data_dynamic"
type="FontFile"
uid="uid://cwotp0tbjqvt8"
path="res://.godot/imported/Kenney High.ttf-e1cffc8feca349e3b2468c63a8225519.fontdata"
[deps]
source_file="res://assets/Fonts/Kenney High.ttf"
dest_files=["res://.godot/imported/Kenney High.ttf-e1cffc8feca349e3b2468c63a8225519.fontdata"]
[params]
Rendering=null
antialiasing=1
generate_mipmaps=false
multichannel_signed_distance_field=false
msdf_pixel_range=8
msdf_size=48
allow_system_fallback=true
force_autohinter=false
hinting=1
subpixel_positioning=1
oversampling=0.0
Fallbacks=null
fallbacks=[]
Compress=null
compress=true
preload=[]
language_support={}
script_support={}
opentype_features={}

Binary file not shown.

View file

@ -0,0 +1,33 @@
[remap]
importer="font_data_dynamic"
type="FontFile"
uid="uid://ck7kkvo78s2fu"
path="res://.godot/imported/Kenney Mini Square Mono.ttf-af2d7d93b948dc0c2735b6cdee649336.fontdata"
[deps]
source_file="res://assets/Fonts/Kenney Mini Square Mono.ttf"
dest_files=["res://.godot/imported/Kenney Mini Square Mono.ttf-af2d7d93b948dc0c2735b6cdee649336.fontdata"]
[params]
Rendering=null
antialiasing=1
generate_mipmaps=false
multichannel_signed_distance_field=false
msdf_pixel_range=8
msdf_size=48
allow_system_fallback=true
force_autohinter=false
hinting=1
subpixel_positioning=1
oversampling=0.0
Fallbacks=null
fallbacks=[]
Compress=null
compress=true
preload=[]
language_support={}
script_support={}
opentype_features={}

Binary file not shown.

View file

@ -0,0 +1,33 @@
[remap]
importer="font_data_dynamic"
type="FontFile"
uid="uid://ryhimaxr7tr4"
path="res://.godot/imported/Kenney Mini Square.ttf-c49f8ef1e49f69b3f8da5d1786aa5f74.fontdata"
[deps]
source_file="res://assets/Fonts/Kenney Mini Square.ttf"
dest_files=["res://.godot/imported/Kenney Mini Square.ttf-c49f8ef1e49f69b3f8da5d1786aa5f74.fontdata"]
[params]
Rendering=null
antialiasing=1
generate_mipmaps=false
multichannel_signed_distance_field=false
msdf_pixel_range=8
msdf_size=48
allow_system_fallback=true
force_autohinter=false
hinting=1
subpixel_positioning=1
oversampling=0.0
Fallbacks=null
fallbacks=[]
Compress=null
compress=true
preload=[]
language_support={}
script_support={}
opentype_features={}

Binary file not shown.

View file

@ -0,0 +1,33 @@
[remap]
importer="font_data_dynamic"
type="FontFile"
uid="uid://bwff4j1ko8iw"
path="res://.godot/imported/Kenney Mini.ttf-f6e816f8968c0ca76db18efbb448ca70.fontdata"
[deps]
source_file="res://assets/Fonts/Kenney Mini.ttf"
dest_files=["res://.godot/imported/Kenney Mini.ttf-f6e816f8968c0ca76db18efbb448ca70.fontdata"]
[params]
Rendering=null
antialiasing=1
generate_mipmaps=false
multichannel_signed_distance_field=false
msdf_pixel_range=8
msdf_size=48
allow_system_fallback=true
force_autohinter=false
hinting=1
subpixel_positioning=1
oversampling=0.0
Fallbacks=null
fallbacks=[]
Compress=null
compress=true
preload=[]
language_support={}
script_support={}
opentype_features={}

Binary file not shown.

View file

@ -0,0 +1,33 @@
[remap]
importer="font_data_dynamic"
type="FontFile"
uid="uid://be6xxaq8drt5q"
path="res://.godot/imported/Kenney Pixel Square.ttf-87d12b7133dcb0cab032f3d23f9126b0.fontdata"
[deps]
source_file="res://assets/Fonts/Kenney Pixel Square.ttf"
dest_files=["res://.godot/imported/Kenney Pixel Square.ttf-87d12b7133dcb0cab032f3d23f9126b0.fontdata"]
[params]
Rendering=null
antialiasing=1
generate_mipmaps=false
multichannel_signed_distance_field=false
msdf_pixel_range=8
msdf_size=48
allow_system_fallback=true
force_autohinter=false
hinting=1
subpixel_positioning=1
oversampling=0.0
Fallbacks=null
fallbacks=[]
Compress=null
compress=true
preload=[]
language_support={}
script_support={}
opentype_features={}

Binary file not shown.

View file

@ -0,0 +1,33 @@
[remap]
importer="font_data_dynamic"
type="FontFile"
uid="uid://csh34n3rsgqc7"
path="res://.godot/imported/Kenney Pixel.ttf-bfeee1b80514f0a82a1024eba2c5fa2a.fontdata"
[deps]
source_file="res://assets/Fonts/Kenney Pixel.ttf"
dest_files=["res://.godot/imported/Kenney Pixel.ttf-bfeee1b80514f0a82a1024eba2c5fa2a.fontdata"]
[params]
Rendering=null
antialiasing=1
generate_mipmaps=false
multichannel_signed_distance_field=false
msdf_pixel_range=8
msdf_size=48
allow_system_fallback=true
force_autohinter=false
hinting=1
subpixel_positioning=1
oversampling=0.0
Fallbacks=null
fallbacks=[]
Compress=null
compress=true
preload=[]
language_support={}
script_support={}
opentype_features={}

Binary file not shown.

View file

@ -0,0 +1,33 @@
[remap]
importer="font_data_dynamic"
type="FontFile"
uid="uid://c4adhqwiyrh1h"
path="res://.godot/imported/Kenney Rocket Square.ttf-dbb5f3f57e75b91a3303c7bab51670de.fontdata"
[deps]
source_file="res://assets/Fonts/Kenney Rocket Square.ttf"
dest_files=["res://.godot/imported/Kenney Rocket Square.ttf-dbb5f3f57e75b91a3303c7bab51670de.fontdata"]
[params]
Rendering=null
antialiasing=1
generate_mipmaps=false
multichannel_signed_distance_field=false
msdf_pixel_range=8
msdf_size=48
allow_system_fallback=true
force_autohinter=false
hinting=1
subpixel_positioning=1
oversampling=0.0
Fallbacks=null
fallbacks=[]
Compress=null
compress=true
preload=[]
language_support={}
script_support={}
opentype_features={}

Binary file not shown.

View file

@ -0,0 +1,33 @@
[remap]
importer="font_data_dynamic"
type="FontFile"
uid="uid://b7n886qnywthr"
path="res://.godot/imported/Kenney Rocket.ttf-068c6fea1b9afcff4c5cbda5ba66e00d.fontdata"
[deps]
source_file="res://assets/Fonts/Kenney Rocket.ttf"
dest_files=["res://.godot/imported/Kenney Rocket.ttf-068c6fea1b9afcff4c5cbda5ba66e00d.fontdata"]
[params]
Rendering=null
antialiasing=1
generate_mipmaps=false
multichannel_signed_distance_field=false
msdf_pixel_range=8
msdf_size=48
allow_system_fallback=true
force_autohinter=false
hinting=1
subpixel_positioning=1
oversampling=0.0
Fallbacks=null
fallbacks=[]
Compress=null
compress=true
preload=[]
language_support={}
script_support={}
opentype_features={}

View file

@ -1,15 +1,21 @@
[gd_scene load_steps=4 format=3 uid="uid://635xs5haibcn"]
[gd_scene load_steps=5 format=3 uid="uid://635xs5haibcn"]
[ext_resource type="PackedScene" uid="uid://ckh362yqjkpi0" path="res://scenes/player.tscn" id="1_1w06w"]
[ext_resource type="Script" path="res://script/game.cs" id="1_dukjm"]
[ext_resource type="PackedScene" uid="uid://b6myj160l6vf8" path="res://scenes/hud.tscn" id="2_xbhg5"]
[ext_resource type="PackedScene" uid="uid://dnvcics1ni4pa" path="res://scenes/asteroid.tscn" id="3_b8wlr"]
[node name="Game" type="Node2D"]
script = ExtResource("1_dukjm")
[node name="UI" type="CanvasLayer" parent="."]
[node name="HUD" parent="UI" instance=ExtResource("2_xbhg5")]
[node name="Player" parent="." instance=ExtResource("1_1w06w")]
position = Vector2(800, 450)
scale = Vector2(0.6, 0.6)
collision_layer = 8
[node name="Lasers" type="Node" parent="."]

24
MB_FYP/scenes/hud.tscn Normal file
View file

@ -0,0 +1,24 @@
[gd_scene load_steps=4 format=3 uid="uid://b6myj160l6vf8"]
[ext_resource type="Script" path="res://script/hud.cs" id="1_aksh1"]
[ext_resource type="FontFile" uid="uid://be6xxaq8drt5q" path="res://assets/Fonts/Kenney Pixel Square.ttf" id="2_2d36h"]
[sub_resource type="LabelSettings" id="LabelSettings_588nb"]
font = ExtResource("2_2d36h")
font_size = 48
[node name="HUD" type="Control"]
layout_mode = 3
anchors_preset = 0
offset_right = 40.0
offset_bottom = 40.0
script = ExtResource("1_aksh1")
[node name="Score" type="Label" parent="."]
layout_mode = 0
offset_left = 15.0
offset_top = 15.0
offset_right = 363.0
offset_bottom = 90.0
text = "SCORE: 9999"
label_settings = SubResource("LabelSettings_588nb")

View file

@ -7,10 +7,23 @@ public partial class game : Node2D
public CharacterBody2D Player = null;
public Node Asteroids = null;
public Control HUD = null;
public Label ScoreLabel = null;
public hud h;
private readonly PackedScene AsteroidScene = GD.Load<PackedScene>("res://scenes/asteroid.tscn");
public int Score = 0;
public override void _Ready()
{
HUD = GetNode<Control>("UI/HUD");
ScoreLabel = GetNode<Label>("UI/HUD/Score");
Asteroids = GetNode<Node>("Asteroids");
var a = new asteroid();
for (int i = 0; i == Asteroids.GetChildCount() - 1; i++){
@ -25,6 +38,14 @@ public partial class game : Node2D
}
public override void _Process(double delta)
{
if (Input.IsActionJustPressed("reset"))
{
GetTree().ReloadCurrentScene();
}
}
public void SpawnAsteroid(Vector2 position, int size)
{
var a = new asteroid();
@ -35,6 +56,16 @@ public partial class game : Node2D
Asteroids.CallDeferred("add_child", a);
}
public void UpdateScoreLabel(int score)
{
/*var h = new hud();
GD.Print(h.Score);
h.Score.Text = "SCORE: " + score.ToString();
GD.Print(h.Score.Text);*/
ScoreLabel.Text = "SCORE: " + score.ToString();
}
//Signals and Connections
public void OnPlayerLaserShot(Area2D Laser)
{
@ -45,18 +76,25 @@ public partial class game : Node2D
public void OnAsteroidExploded(Vector2 pos, int size)
{
GD.Print(size);
//score hardcoded for now, will make implementation of enemy scores easier later on
// score = score * 2 (for loop)
for(int i = 0; i < 2; i++){
if (size == 0){
SpawnAsteroid(pos, (int)asteroid.AsteroidSize.MEDIUM);
Score += 60;
}
else if (size == 1){
SpawnAsteroid(pos, (int)asteroid.AsteroidSize.SMALL);
Score += 40;
}
else if (size == 2)
{
Score += 20;
}
}
GD.Print(Score);
UpdateScoreLabel(Score);
}
}

13
MB_FYP/script/hud.cs Normal file
View file

@ -0,0 +1,13 @@
using Godot;
using System;
public partial class hud : Control
{
public Label Score = new();
public override void _Ready()
{
Score = GetNode<Label>("Score");
Score.Text = "SCORE: 0";
}
}