Skip to content

Commit

Permalink
img 90 rot +
Browse files Browse the repository at this point in the history
  • Loading branch information
Nikita-str committed Feb 19, 2021
1 parent bc246af commit a9d72a4
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 12 deletions.
16 changes: 16 additions & 0 deletions GameMap.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
#ifndef MAIN_Gmap_H
#define MAIN_Gmap_H

#include<vector>

enum class E_TileType
{
Floor,
Wall,
Empty
};

struct GameMap
{
GameMap();

private:
std::vector<std::vector<E_TileType>> now_wall;
};

#endif
11 changes: 11 additions & 0 deletions Image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,17 @@ Image::Image(Image&& a) noexcept : width(a.width), height(a.height), size(a.size
a.data = nullptr;
}

Image::Image(const Image &copy, E_ImgRotation rot) : width(copy.height), height(copy.width), size(copy.size), channels(copy.channels)
{
data = new Pixel[width * (size_t)height];
for (int y = 0; y < height; y++)
for (int x = 0; x < width; x++)
SetPixel(x, y, copy.GetPixel(height - 1 - y, x));

self_allocated = true;
return;
}


int Image::Save(const std::string &a_path)
{
Expand Down
4 changes: 4 additions & 0 deletions Image.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ inline bool operator< (const Pixel a, const Pixel b)

constexpr Pixel backgroundColor{0, 0, 0, 0};

enum class E_ImgRotation { Rot_90 };

struct Image
{
explicit Image(const std::string &a_path);
Expand All @@ -58,6 +60,8 @@ struct Image
Image(const Image &copy, int scale);
Image(const Image &copy, int scale_x, int scale_y);

Image(const Image &copy, E_ImgRotation rot);

Image(const Image &copy);
Image(Image && a) noexcept;

Expand Down
9 changes: 6 additions & 3 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,8 @@ int main(int argc, char** argv)
glViewport(0, 0, WINDOW_WIDTH, WINDOW_HEIGHT); GL_CHECK_ERRORS;
glClearColor(0.0f, 0.0f, 0.0f, 1.0f); GL_CHECK_ERRORS;


Image img90 {img, E_ImgRotation::Rot_90};
//game loop
while (!glfwWindowShouldClose(window)) {
//GLfloat currentFrame = glfwGetTime();
Expand All @@ -174,9 +176,10 @@ int main(int argc, char** argv)
glfwPollEvents();

img.Draw(screenBuffer, {64 * 0,0});
img.Draw(screenBuffer, {64 * 1,0}, true);
img.Draw(screenBuffer, {64 * 2,0}, false, true);
img.Draw(screenBuffer, {64 * 3,0}, true, true);
img90.Draw(screenBuffer, {64 * 1,0});
//img.Draw(screenBuffer, {64 * 1,0}, true);
//img.Draw(screenBuffer, {64 * 2,0}, false, true);
//img.Draw(screenBuffer, {64 * 3,0}, true, true);

processPlayerMovement(player);
player.Draw(screenBuffer);
Expand Down
18 changes: 9 additions & 9 deletions maps/F.txt
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
z+
####################.####################
#.................#...#.................#
#.................#...#.................#
#....G............#...#.................#
#.................#...#.................#
#.................#.....................#
#.................#...#.................#
#.................#...#.................#
#.................#...#.................#
#.................#...#.................#
#.................#...#.................#
#.............. ..#...#.................#
#....G......... #...#.................#
#........... ..#...#.................#
#........... .....#.....................#
#.... .. . .....#...#.................#
# ... . .....#...#.................#
# .. ... ........#...#.................#
#. .. ... ........#...#.................#
#. . ............#...#.................#
#.................#...#.................#
#.................#...#.................#
#...............###...###...............#
Expand Down

0 comments on commit a9d72a4

Please sign in to comment.