-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
90 lines (77 loc) · 3.56 KB
/
Copy pathProgram.cs
File metadata and controls
90 lines (77 loc) · 3.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
using System.Numerics;
using Raylib_cs;
using static Raylib_cs.Raylib;
using Geostorm.Core;
using Geostorm.Renderer;
namespace Geostorm
{
class Program
{
private static void InitializeWindow()
{
SetConfigFlags(ConfigFlags.FLAG_WINDOW_RESIZABLE);
InitWindow(1600, 900, "GeoStorm");
int monitor = GetCurrentMonitor();
SetWindowSize((int)(GetMonitorWidth(monitor) * 0.75f), (int)(GetMonitorHeight(monitor) * 0.75f));
SetWindowPosition((int)(GetMonitorWidth(monitor) * 0.1f), (int)(GetMonitorHeight(monitor) * 0.1f));
Image icon = LoadImage("Assets/GEOSTORM.png");
SetWindowIcon(icon);
SetTargetFPS(60);
SetMousePosition(GetScreenWidth() / 2, GetScreenHeight() / 2);
SetExitKey(0);
InitAudioDevice();
}
static void Main(string[] args)
{
// Initialization
//--------------------------------------------------------------------------------------
InitializeWindow();
var game = new Game();
game.LoadConfigFile();
var inputs = new GameInputs();
inputs.LocalSize = game.gameData.MapSize;
Shader bloomShader = LoadShader("", "Assets/Shaders/bloom.fs");
//--------------------------------------------------------------------------------------
RenderTexture2D renderTexture = LoadRenderTexture(GetScreenWidth(),GetScreenHeight());
// Main game loop
while (!WindowShouldClose() && !game.ShouldClose)
{
// Update
//----------------------------------------------------------------------------------
Vector2 size = new Vector2(GetScreenWidth(), GetScreenHeight());
if (size != inputs.ScreenSize)
{
UnloadRenderTexture(renderTexture);
renderTexture = LoadRenderTexture(GetScreenWidth(), GetScreenHeight());
}
if (game.gameData.scene != GameData.Scene.PAUSE)
inputs.Update(game.config, game.gameData.player.Position);
game.Update(inputs);
//----------------------------------------------------------------------------------
// Draw
//----------------------------------------------------------------------------------
// Draw Scene
BeginTextureMode(renderTexture);
ClearBackground(Color.BLACK);
game.Render(inputs);
EndTextureMode();
// Draw FrameBuffer Rect
BeginDrawing();
ClearBackground(Color.BLACK);
BeginShaderMode(bloomShader);
DrawTextureRec(renderTexture.texture, new Rectangle( 0, 0, (float)renderTexture.texture.width, (float)-renderTexture.texture.height), new Vector2(0, 0), Color.WHITE);
EndShaderMode();
EndDrawing();
//----------------------------------------------------------------------------------
}
// De-Initialization
//--------------------------------------------------------------------------------------
game.WriteConfigFile();
UnloadShader(bloomShader);
UnloadRenderTexture(renderTexture);
CloseAudioDevice();
CloseWindow();
//--------------------------------------------------------------------------------------
}
}
}