Skip to content

Commit

Permalink
blocks and colors
Browse files Browse the repository at this point in the history
  • Loading branch information
Crystallized21 committed Dec 2, 2024
1 parent ed3a296 commit 72bc9b9
Show file tree
Hide file tree
Showing 8 changed files with 98 additions and 15 deletions.
5 changes: 5 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ add_executable(${PROJECT_NAME} ${PROJECT_SOURCES}
src/main.cpp
src/grid.h
src/grid.cpp
src/block.h
src/position.h
src/position.cpp
src/colors.h
src/colors.cpp
)
target_sources(${PROJECT_NAME} PRIVATE ${PROJECT_SOURCES})
target_include_directories(${PROJECT_NAME} PRIVATE ${PROJECT_INCLUDE})
Expand Down
23 changes: 23 additions & 0 deletions src/block.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
//
// Created by Michael Bui on 12/2/24.
//

#ifndef BLOCK_H
#define BLOCK_H

#pragma once
#include <vector>
#include <map>
#include "position.h"

class Block {
public:
Block();
int id;
std::map<int, std::vector<Position>> cells;
private:
int cellSize;
int roationState;
};

#endif //BLOCK_H
20 changes: 20 additions & 0 deletions src/colors.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
//
// Created by Michael Bui on 12/2/24.
//

#include "colors.h"

#include <vector>

const Color darkGray = {26, 31, 40, 255};
const Color green = {47, 230, 23, 255};
const Color red = {232, 18, 18, 255};
const Color orange = {226, 116, 17, 255};
const Color yellow = {237, 234, 4, 255};
const Color purple = {166, 0, 247, 255};
const Color cyan = {21, 204, 209, 255};
const Color blue = {13, 64, 216, 255};

std::vector<Color> GetCellColors() {
return {darkGray, green, red, orange, yellow, purple, cyan, blue};
}
23 changes: 23 additions & 0 deletions src/colors.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
//
// Created by Michael Bui on 12/2/24.
//

#ifndef COLOURS_H
#define COLOURS_H

#pragma once
#include <raylib.h>
#include <vector>

extern const Color darkGray;
extern const Color green;
extern const Color red;
extern const Color orange;
extern const Color yellow;
extern const Color purple;
extern const Color cyan;
extern const Color blue;

std::vector<Color> GetCellColors();

#endif //COLOURS_H
14 changes: 1 addition & 13 deletions src/grid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

#include "grid.h"
#include <iostream>
#include "colors.h"

Grid::Grid() {
numRows = 20;
Expand All @@ -30,19 +31,6 @@ void Grid::print() {
}
}

std::vector<Color> Grid::GetCellColors() {
Color darkGrey = {26, 31, 40, 255};
Color green = {47, 230, 23, 255};
Color red = {232, 18, 18, 255};
Color orange = {226, 116, 17, 255};
Color yellow = {237, 234, 4, 255};
Color purple = {166, 0, 247, 255};
Color cyan = {21, 204, 209, 255};
Color blue = {13, 64, 216, 255};

return {darkGrey, green, red, orange, yellow, purple, cyan, blue};
}

void Grid::Draw() {
for (int row = 0; row < numRows; ++row) {
for (int column = 0; column < numCols; ++column) {
Expand Down
2 changes: 0 additions & 2 deletions src/grid.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ class Grid {
void Draw();
int grid[20][10];
private:
std::vector<Color> GetCellColors();

int numRows;
int numCols;
int cellSize;
Expand Down
10 changes: 10 additions & 0 deletions src/position.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
//
// Created by Michael Bui on 12/2/24.
//

#include "position.h"

Position::Position(int row, int column) {
this -> row = row;
this -> column = column;
}
16 changes: 16 additions & 0 deletions src/position.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//
// Created by Michael Bui on 12/2/24.
//

#ifndef POSITION_H
#define POSITION_H

#pragma once
class Position {
public:
Position(int row, int column);
int row;
int column;
};

#endif //POSITION_H

0 comments on commit 72bc9b9

Please sign in to comment.