Skip to content

Commit

Permalink
World setup
Browse files Browse the repository at this point in the history
  • Loading branch information
AbhijnanVegi committed Feb 20, 2022
1 parent 16e9d69 commit 4312eef
Show file tree
Hide file tree
Showing 15 changed files with 876 additions and 131 deletions.
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,5 +81,6 @@
"typeinfo": "cpp",
"valarray": "cpp",
"variant": "cpp"
}
},
"C_Cpp.errorSquiggles": "Enabled"
}
Binary file added fonts/gameplay.ttf
Binary file not shown.
4 changes: 3 additions & 1 deletion include/camera.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class Camera
glm::vec3 Up;
glm::vec3 Right;
glm::vec3 WorldUp;
glm::vec3 Look;
// euler Angles
float Yaw;
float Pitch;
Expand All @@ -49,6 +50,7 @@ class Camera
Yaw = yaw;
Pitch = pitch;
updateCameraVectors();
Look = glm::vec3(0.0f, 0.0f, -2.0f);
}
// constructor with scalar values
Camera(float posX, float posY, float posZ, float upX, float upY, float upZ, float yaw, float pitch) : Front(glm::vec3(0.0f, 0.0f, -1.0f)), MovementSpeed(SPEED), MouseSensitivity(SENSITIVITY), Zoom(ZOOM)
Expand All @@ -63,7 +65,7 @@ class Camera
// returns the view matrix calculated using Euler Angles and the LookAt Matrix
glm::mat4 GetViewMatrix()
{
return glm::lookAt(Position, Position + Front, Up);
return glm::lookAt(Position, Look, Up);
}

// processes input received from any keyboard-like input system. Accepts input parameter in the form of camera defined ENUM (to abstract it from windowing systems)
Expand Down
7 changes: 7 additions & 0 deletions include/game.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
#include <glad/glad.h>
#include <GLFW/glfw3.h>

#include "camera.h"
#include "game_object.h"

enum GameState
{
GAME_MENU,
Expand All @@ -21,6 +24,10 @@ class Game
bool Keys[1024];
unsigned int Width, Height;
unsigned int Score;
Camera Cam;
std::vector<GameObject> Enemies;
std::vector<GameObject> Projectiles;
std::vector<GameObject> Collectibles;

Game(unsigned int width, unsigned int height);
~Game();
Expand Down
13 changes: 10 additions & 3 deletions include/game_object.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,22 @@ class GameObject
{
public:
// object state
glm::vec3 Position, Scale, Rotation;
glm::vec3 Position, Scale;
float Rotation;
Model ObjectModel;
bool Destroyed;
// constructor(s)
GameObject(glm::vec3 Postion, glm::vec3 Scale, glm::vec3 Rotation, string const &path): Position(Position), Scale(Scale), Rotation(Rotation), ObjectModel(path)
GameObject(const glm::vec3 &Position,const glm::vec3 &Scale,const float Rotation, string const &path): ObjectModel(path), Destroyed(false)
{
this->Position = Position;
this->Scale = Scale;
this->Rotation = Rotation;
}
// draw sprite
void Draw(Renderer &renderer);
void Draw(Renderer &renderer, Camera &camera)
{
renderer.Draw(camera,ObjectModel, this->Position, this->Scale, this->Rotation);
}
};

#endif
5 changes: 3 additions & 2 deletions include/renderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,15 @@
#include "shader.h"
#include "camera.h"

extern const unsigned int SCR_WIDTH;
extern const unsigned int SCR_HEIGHT;

class Renderer
{
public:
Renderer(const Shader &shader);
~Renderer();
void Draw(Model &model, glm::vec3(position), glm::vec3(scale), float angle);
void UpdateCamera(const Camera cam);
void Draw(Camera &camera, Model &model, glm::vec3 &position, glm::vec3 &scale, float angle);

private:
Shader shader;
Expand Down
12 changes: 12 additions & 0 deletions models/water.mtl
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Blender MTL File: 'None'
# Material Count: 1

newmtl Water
Ns 323.999994
Ka 0.243902 0.243902 0.243902
Kd 0.106039 0.689349 0.800000
Ks 0.500000 0.500000 0.500000
Ke 0.000000 0.000000 0.000000
Ni 1.450000
d 1.000000
illum 3
37 changes: 37 additions & 0 deletions models/water.obj
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Blender v3.0.1 OBJ File: ''
# www.blender.org
mtllib water.mtl
o Cube
v 10.000000 0.000000 -10.000000
v 10.000000 0.000000 -10.000000
v 10.000000 0.000000 10.000000
v 10.000000 0.000000 10.000000
v -10.000000 0.000000 -10.000000
v -10.000000 0.000000 -10.000000
v -10.000000 0.000000 10.000000
v -10.000000 0.000000 10.000000
vt 0.625000 0.500000
vt 0.875000 0.500000
vt 0.875000 0.750000
vt 0.625000 0.750000
vt 0.375000 0.750000
vt 0.625000 1.000000
vt 0.375000 1.000000
vt 0.375000 0.000000
vt 0.625000 0.000000
vt 0.625000 0.250000
vt 0.375000 0.250000
vt 0.125000 0.500000
vt 0.375000 0.500000
vt 0.125000 0.750000
vn 0.0000 1.0000 0.0000
vn 0.0000 0.0000 1.0000
vn 0.0000 -1.0000 0.0000
usemtl Water
s off
f 1/1/1 5/2/1 7/3/1 3/4/1
f 4/5/2 3/4/2 7/6/2 8/7/2
f 8/8/2 7/9/2 5/10/2 6/11/2
f 6/12/3 2/13/3 4/5/3 8/14/3
f 2/13/2 1/1/2 3/4/2 4/5/2
f 6/11/2 5/10/2 1/1/2 2/13/2
12 changes: 12 additions & 0 deletions models/water2.mtl
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Blender MTL File: 'circle.blend'
# Material Count: 1

newmtl Default_OBJ
Ns 225.000000
Ka 1.000000 1.000000 1.000000
Kd 0.070741 0.474744 0.800000
Ks 0.500000 0.500000 0.500000
Ke 0.000000 0.000000 0.000000
Ni 1.450000
d 1.000000
illum 2
Loading

0 comments on commit 4312eef

Please sign in to comment.