Default Constructors required for template classes

Co-authored-by: sigonasr2 <sigonasr2@gmail.com>
master
sigonasr2 2 years ago
parent 06a0ac20f5
commit dba7479803
  1. 8
      Block.cpp
  2. 14
      Block.h
  3. BIN
      C++ProjectTemplate
  4. 9
      main.cpp

@ -0,0 +1,8 @@
#include "Block.h"
Block::Block(int x, int y, int R, int B, int G)
{
X = x;
Y = y;
color = std::make_tuple(R, G, B);
}

@ -0,0 +1,14 @@
#pragma once
#include <tuple>
class Block
{
public:
Block(){};
Block(int x, int y, int R, int B, int G);
void display(float CameraX, float CameraY, float Zoom);
private:
int X;
int Y;
std::tuple<int, int, int> color;
};

Binary file not shown.

@ -1,5 +1,7 @@
#define OLC_PGE_APPLICATION #define OLC_PGE_APPLICATION
#include "pixelGameEngine.h" #include "pixelGameEngine.h"
#include <unordered_map>
#include "Block.h"
class Example : public olc::PixelGameEngine class Example : public olc::PixelGameEngine
{ {
@ -10,19 +12,16 @@ public:
} }
public: public:
std::unordered_map<int,Block> Blocks;
bool OnUserCreate() override bool OnUserCreate() override
{ {
// Called once at the start, so create things here // Called once at the start, so create things here
Blocks[126]=Block(25,10,255,255,255);
return true; return true;
} }
bool OnUserUpdate(float fElapsedTime) override bool OnUserUpdate(float fElapsedTime) override
{ {
ConsoleShow(olc::ESCAPE,false);
// called once per frame
for (int x = 0; x < ScreenWidth(); x++)
for (int y = 0; y < ScreenHeight(); y++)
Draw(x, y, olc::Pixel(rand() % 255, rand() % 255, rand()% 255));
return true; return true;
} }
}; };

Loading…
Cancel
Save