Skip to content

Commit

Permalink
fix (./FlappyBird): Main
Browse files Browse the repository at this point in the history
  • Loading branch information
PharaEthan committed Jan 8, 2024
1 parent 2ffcab0 commit 6f7f9f2
Show file tree
Hide file tree
Showing 15 changed files with 396 additions and 154 deletions.
5 changes: 3 additions & 2 deletions GameEngine/src/Exodia/EntryPoint.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@

extern Exodia::Application *Exodia::CreateApplication(ApplicationCommandLineArgs args);

int main(int ac, char **av) {
Exodia::Log::Init("R-Type");
int main(int ac, char **av)
{
Exodia::Log::Init("Exodia Application");

EXODIA_PROFILE_BEGIN_SESSION("Startup", "ExodiaProfile-Startup.json");
Exodia::Application *App = Exodia::CreateApplication({ac, av});
Expand Down
5 changes: 4 additions & 1 deletion flappybird/Assets/AssetRegistry.asset
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
AssetRegistry:
- Handle: 14815285158415
Path: Texture/Characters/SpaceShip.png
Type: AssetType::Texture2D
Type: AssetType::Texture2D
- Handle: 45120015123131
Path: Texture/Tiles/Obstacle.png
Type: AssetType::Texture2D
4 changes: 4 additions & 0 deletions flappybird/Assets/FlappyBird.proj
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Project:
Name: FlappyBird
AssetsDirectory: ""
AssetRegistryPath: "AssetRegistry.asset"
Binary file added flappybird/Assets/Font/OpenSans-Bold.ttf
Binary file not shown.
71 changes: 71 additions & 0 deletions flappybird/Assets/Shaders/Renderer2D_Circle.glsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
#type vertex
#version 450 core

layout(location = 0) in vec3 a_WorldPosition;
layout(location = 1) in vec3 a_LocalPosition;
layout(location = 2) in vec4 a_Color;
layout(location = 3) in float a_Thickness;
layout(location = 4) in float a_Fade;
layout(location = 6) in int a_EntityID;

layout(std140, binding = 0) uniform Camera
{
mat4 u_ViewProjection;
};

struct VertexOutput
{
vec3 LocalPosition;
vec4 Color;
float Thickness;
float Fade;
};

layout(location = 0) out VertexOutput Output;
layout(location = 4) out flat int v_EntityID;

void main()
{
Output.LocalPosition = a_LocalPosition;
Output.Color = a_Color;
Output.Thickness = a_Thickness;
Output.Fade = a_Fade;

v_EntityID = a_EntityID;

gl_Position = u_ViewProjection * vec4(a_WorldPosition, 1.0);
}

#type fragment
#version 450 core

layout(location = 0) out vec4 Color;
layout(location = 1) out int EntityID;

struct VertexOutput
{
vec3 LocalPosition;
vec4 Color;
float Thickness;
float Fade;
};

layout(location = 0) in VertexOutput Input;
layout(location = 4) in flat int v_EntityID;

void main()
{
// Calculate the distance and fill circle with white
float distance = 1.0 - length(Input.LocalPosition);
float circle = smoothstep(0.0, Input.Fade, distance);

circle *= smoothstep(Input.Thickness + Input.Fade, Input.Thickness, distance);

if (circle == 0.0)
discard;

Color = Input.Color;
Color *= circle;

EntityID = v_EntityID;
}
48 changes: 48 additions & 0 deletions flappybird/Assets/Shaders/Renderer2D_Line.glsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#type vertex
#version 450 core

layout(location = 0) in vec3 a_Position;
layout(location = 1) in vec4 a_Color;
layout(location = 2) in int a_EntityID;

layout(std140, binding = 0) uniform Camera
{
mat4 u_ViewProjection;
};

struct VertexOutput
{
vec4 Color;
};

layout(location = 0) out VertexOutput Output;
layout(location = 1) out flat int v_EntityID;

void main()
{
Output.Color = a_Color;

v_EntityID = a_EntityID;

gl_Position = u_ViewProjection * vec4(a_Position, 1.0);
}

#type fragment
#version 450 core

layout(location = 0) out vec4 o_Color;
layout(location = 1) out int o_EntityID;

struct VertexOutput
{
vec4 Color;
};

layout(location = 0) in VertexOutput Input;
layout(location = 1) in flat int v_EntityID;

void main()
{
o_Color = Input.Color;
o_EntityID = v_EntityID;
}
168 changes: 168 additions & 0 deletions flappybird/Assets/Shaders/Renderer2D_Quad.glsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,168 @@
// Basic Texture Shader
// Compatible with Exodia Game Engine

#type vertex
#version 450 core

layout(location = 0) in vec3 a_Position;
layout(location = 1) in vec4 a_Color;
layout(location = 2) in vec2 a_TexCoord;
layout(location = 3) in float a_TexIndex;
layout(location = 4) in float a_TilingFactor;
layout(location = 5) in int a_EntityID;

layout(std140, binding = 0) uniform Camera
{
mat4 u_ViewProjection;
};

struct VertexOutput
{
vec4 Color;
vec2 TexCoord;
float TilingFactor;
};

layout(location = 0) out VertexOutput Output;
layout(location = 3) out flat float v_TexIndex;
layout(location = 4) out flat int v_EntityID;

void main()
{
Output.Color = a_Color;
Output.TexCoord = a_TexCoord;
Output.TilingFactor = a_TilingFactor;

v_TexIndex = a_TexIndex;
v_EntityID = a_EntityID;

gl_Position = u_ViewProjection * vec4(a_Position, 1.0);
}

#type fragment
#version 450 core

layout(location = 0) out vec4 o_Color;
layout(location = 1) out int o_EntityID;

struct VertexOutput
{
vec4 Color;
vec2 TexCoord;
float TilingFactor;
};

layout(location = 0) in VertexOutput Input;
layout(location = 3) in flat float v_TexIndex;
layout(location = 4) in flat int v_EntityID;
layout(binding = 0) uniform sampler2D u_Textures[32];

void main()
{
vec4 texColor = Input.Color;

switch (int(v_TexIndex)) {
case 0:
texColor *= texture(u_Textures[ 0], Input.TexCoord * Input.TilingFactor);
break;
case 1:
texColor *= texture(u_Textures[ 1], Input.TexCoord * Input.TilingFactor);
break;
case 2:
texColor *= texture(u_Textures[ 2], Input.TexCoord * Input.TilingFactor);
break;
case 3:
texColor *= texture(u_Textures[ 3], Input.TexCoord * Input.TilingFactor);
break;
case 4:
texColor *= texture(u_Textures[ 4], Input.TexCoord * Input.TilingFactor);
break;
case 5:
texColor *= texture(u_Textures[ 5], Input.TexCoord * Input.TilingFactor);
break;
case 6:
texColor *= texture(u_Textures[ 6], Input.TexCoord * Input.TilingFactor);
break;
case 7:
texColor *= texture(u_Textures[ 7], Input.TexCoord * Input.TilingFactor);
break;
case 8:
texColor *= texture(u_Textures[ 8], Input.TexCoord * Input.TilingFactor);
break;
case 9:
texColor *= texture(u_Textures[ 9], Input.TexCoord * Input.TilingFactor);
break;
case 10:
texColor *= texture(u_Textures[10], Input.TexCoord * Input.TilingFactor);
break;
case 11:
texColor *= texture(u_Textures[11], Input.TexCoord * Input.TilingFactor);
break;
case 12:
texColor *= texture(u_Textures[12], Input.TexCoord * Input.TilingFactor);
break;
case 13:
texColor *= texture(u_Textures[13], Input.TexCoord * Input.TilingFactor);
break;
case 14:
texColor *= texture(u_Textures[14], Input.TexCoord * Input.TilingFactor);
break;
case 15:
texColor *= texture(u_Textures[15], Input.TexCoord * Input.TilingFactor);
break;
case 16:
texColor *= texture(u_Textures[16], Input.TexCoord * Input.TilingFactor);
break;
case 17:
texColor *= texture(u_Textures[17], Input.TexCoord * Input.TilingFactor);
break;
case 18:
texColor *= texture(u_Textures[18], Input.TexCoord * Input.TilingFactor);
break;
case 19:
texColor *= texture(u_Textures[19], Input.TexCoord * Input.TilingFactor);
break;
case 20:
texColor *= texture(u_Textures[20], Input.TexCoord * Input.TilingFactor);
break;
case 21:
texColor *= texture(u_Textures[21], Input.TexCoord * Input.TilingFactor);
break;
case 22:
texColor *= texture(u_Textures[22], Input.TexCoord * Input.TilingFactor);
break;
case 23:
texColor *= texture(u_Textures[23], Input.TexCoord * Input.TilingFactor);
break;
case 24:
texColor *= texture(u_Textures[24], Input.TexCoord * Input.TilingFactor);
break;
case 25:
texColor *= texture(u_Textures[25], Input.TexCoord * Input.TilingFactor);
break;
case 26:
texColor *= texture(u_Textures[26], Input.TexCoord * Input.TilingFactor);
break;
case 27:
texColor *= texture(u_Textures[27], Input.TexCoord * Input.TilingFactor);
break;
case 28:
texColor *= texture(u_Textures[28], Input.TexCoord * Input.TilingFactor);
break;
case 29:
texColor *= texture(u_Textures[29], Input.TexCoord * Input.TilingFactor);
break;
case 30:
texColor *= texture(u_Textures[30], Input.TexCoord * Input.TilingFactor);
break;
case 31:
texColor *= texture(u_Textures[31], Input.TexCoord * Input.TilingFactor);
break;
}

if (texColor.a == 0.0)
discard;

o_Color = texColor;
o_EntityID = v_EntityID;
}
43 changes: 0 additions & 43 deletions flappybird/Assets/Shaders/Texture.glsl

This file was deleted.

9 changes: 4 additions & 5 deletions flappybird/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ set(GAME_ENGINE_DIR ${CMAKE_SOURCE_DIR}/GameEngine)

# Set source files for the SandBoxGames
set(SOURCES
src/Main.cpp
src/FlappyBird.cpp

src/Layer/GameLayer.cpp
src/Particles/Particles.cpp
Expand All @@ -32,10 +32,9 @@ set(SOURCES

# Set include directories for the SandBoxGames
set(INCLUDE_DIRS
# SandBox include directories
${CMAKE_SOURCE_DIR}
${CMAKE_SOURCE_DIR}/src
${CMAKE_SOURCE_DIR}/src/ECS/Event

# Flappy include directories
src/

# GameEngine include directories
${GAME_ENGINE_DIR}/Tools
Expand Down
Loading

0 comments on commit 6f7f9f2

Please sign in to comment.