-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathConsole3D.cpp
More file actions
96 lines (72 loc) · 2.03 KB
/
Console3D.cpp
File metadata and controls
96 lines (72 loc) · 2.03 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
91
92
93
94
95
96
#include <iostream>
#include "Screen.h"
#include "Input.h"
#include "Camera.h"
#include "Graphics.h"
#include "Player.h"
#include "Scene.h"
#include "Time.h"
#include "SphereRender.h"
#include "PlaneRender.h"
bool GameCycle()
{
if (Input::GetKeyDown(Input::Key::Escape))
return false;
Scene::current->Update();
Screen::SetTitle("Console 3D - FPS: " + std::to_string(1 / Time::GetDeltaTime()));
Graphics::RenderOnScreen();
Time::Update();
return true;
}
int main()
{
Vector2i screenResolution = Vector2i(100, 30);
Screen::Set(screenResolution.x(), screenResolution.y());
Screen::SetTitle("Console 3D");
Screen::HideCursor();
Scene currentScene = Scene();
float aspectRatio = (float)Screen::GetPixelSize().x() / Screen::GetPixelSize().y();
Camera mainCamera = Camera(60, aspectRatio, 1000);
Player player(mainCamera);
player.SetPosition(Vector3f(0, 1, 0));
currentScene.Add(player);
Graphics::PathTracing::Material mat1 =
{
Vector3f(0.3f, 0.3f, 0),
Vector3f::Constant(0.5f),
0.5f
};
Graphics::PathTracing::Material mat2 =
{
Vector3f::Constant(0),
Vector3f(1, 1, 1),
1
};
Graphics::PathTracing::SphereRender sphere1(Vector3f(1.5f, 1, -3), 1, mat1);
Graphics::PathTracing::SphereRender sphere2(Vector3f(-1, 1, -3), 1, mat2);
currentScene.Add(sphere1);
currentScene.Add(sphere2);
Graphics::PathTracing::PlaneRender groundPlane(Vector3f::UnitY(), 0, mat1);
currentScene.Add(groundPlane);
Graphics::Init();
Input::Start();
Time::Start();
currentScene.Start();
bool gameIsRun = true;
while (gameIsRun)
{
gameIsRun = GameCycle();
if (gameIsRun == false)
break;
while (!_kbhit())
{
Input::Clear();
gameIsRun = GameCycle();
if (gameIsRun == false)
break;
}
Input::Update();
//std::cout << (int)Input::GetInput() << '\t';
}
return 0;
}