Compare commits

..

No commits in common. "3c4dc154b1749dad6057653eff245a5e1761dce5" and "c609d5ccb0c0e3da25c0247af4a5d95b620c6935" have entirely different histories.

22 changed files with 82 additions and 90 deletions

View File

@ -9,12 +9,11 @@ endif ()
find_package(SDL2 CONFIG REQUIRED)
find_package(SDL2_ttf CONFIG REQUIRED)
find_package(SDL2_image CONFIG REQUIRED)
find_package(CURL REQUIRED)
file(GLOB KULLE_SOURCES src/data/kulle_*_png.cpp)
file(GLOB KULLE_HEADERS src/data/kulle_*_png.hpp)
file(GLOB KULLE_SRC src/data/kulle_*_png.cpp)
file(GLOB KULLE_HEADER src/data/kulle_*_png.hpp)
add_executable(hang_man src/main.cpp
src/Game.cpp
@ -27,17 +26,15 @@ add_executable(hang_man src/main.cpp
src/GuessCorrector.hpp
src/default_font.cpp
src/default_font.hpp
${KULLE_SOURCES}
${KULLE_HEADERS}
${KULLE_SRC}
${KULLE_HEADER}
src/data/hills.cpp
src/data/hills.hpp
src/utils.cpp
)
target_link_libraries(hang_man PRIVATE
SDL2::SDL2
SDL2::SDL2main
SDL2_ttf::SDL2_ttf
SDL2_image::SDL2_image
CURL::libcurl
)

View File

@ -1,13 +1,21 @@
#include "hills.hpp"
#include "kulle_0_png.hpp"
#include "kulle_1_png.hpp"
#include "kulle_2_png.hpp"
#include "kulle_3_png.hpp"
#include "kulle_4_png.hpp"
#include "kulle_5_png.hpp"
#include "kulle_6_png.hpp"
#include "kulle_7_png.hpp"
const HillData hills[] = {
{kulle_0_png, kulle_0_png_length},
{kulle_1_png, kulle_1_png_length},
{kulle_2_png, kulle_2_png_length},
{kulle_3_png, kulle_3_png_length},
{kulle_4_png, kulle_4_png_length},
{kulle_5_png, kulle_5_png_length},
{kulle_6_png, kulle_6_png_length},
{kulle_7_png, kulle_7_png_length},
unsigned const char *hills[] = {
kulle_0_png,
kulle_1_png,
kulle_2_png,
kulle_3_png,
kulle_4_png,
kulle_5_png,
kulle_6_png,
kulle_7_png,
};
extern const size_t hills_length = 8;

View File

@ -1,37 +1,3 @@
#pragma once
#include <cstddef>
extern const unsigned char kulle_0_png[];
extern const size_t kulle_0_png_length;
extern const unsigned char kulle_1_png[];
extern const size_t kulle_1_png_length;
extern const unsigned char kulle_2_png[];
extern const size_t kulle_2_png_length;
extern const unsigned char kulle_3_png[];
extern const size_t kulle_3_png_length;
extern const unsigned char kulle_4_png[];
extern const size_t kulle_4_png_length;
extern const unsigned char kulle_5_png[];
extern const size_t kulle_5_png_length;
extern const unsigned char kulle_6_png[];
extern const size_t kulle_6_png_length;
extern const unsigned char kulle_7_png[];
extern const size_t kulle_7_png_length;
struct HillData {
unsigned const char *data;
const size_t length;
};
extern const HillData hills[];
extern const size_t hills_length;
extern unsigned const char *hills[];

View File

@ -1,4 +1,4 @@
#include "hills.hpp"
#include "kulle_0_png.hpp"
const unsigned char kulle_0_png[] = {
0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 0x0d, 0x49, 0x48, 0x44, 0x52,

6
src/data/kulle_0_png.hpp Normal file
View File

@ -0,0 +1,6 @@
#pragma once
#include <cstddef>
extern const unsigned char kulle_0_png[];
extern const size_t kulle_0_png_length;

View File

@ -1,4 +1,4 @@
#include "hills.hpp"
#include "kulle_1_png.hpp"
const unsigned char kulle_1_png[] = {
0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 0x0d, 0x49, 0x48, 0x44, 0x52,

6
src/data/kulle_1_png.hpp Normal file
View File

@ -0,0 +1,6 @@
#pragma once
#include <cstddef>
extern const unsigned char kulle_1_png[];
extern const size_t kulle_1_png_length;

View File

@ -1,4 +1,4 @@
#include "hills.hpp"
#include "kulle_2_png.hpp"
const unsigned char kulle_2_png[] = {
0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 0x0d, 0x49, 0x48, 0x44, 0x52,

6
src/data/kulle_2_png.hpp Normal file
View File

@ -0,0 +1,6 @@
#pragma once
#include <cstddef>
extern const unsigned char kulle_2_png[];
extern const size_t kulle_2_png_length;

View File

@ -1,4 +1,5 @@
#include "hills.hpp"
// This is the bytes of .\Kulle3.png
#include "kulle_3_png.hpp"
const unsigned char kulle_3_png[] = {
0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 0x0d, 0x49, 0x48, 0x44, 0x52,

6
src/data/kulle_3_png.hpp Normal file
View File

@ -0,0 +1,6 @@
#pragma once
#include <cstddef>
extern const unsigned char kulle_3_png[];
extern const size_t kulle_3_png_length;

View File

@ -1,4 +1,4 @@
#include "hills.hpp"
#include "kulle_4_png.hpp"
const unsigned char kulle_4_png[] = {
0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 0x0d, 0x49, 0x48, 0x44, 0x52,

6
src/data/kulle_4_png.hpp Normal file
View File

@ -0,0 +1,6 @@
#pragma once
#include <cstddef>
extern const unsigned char kulle_4_png[];
extern const size_t kulle_4_png_length;

View File

@ -1,4 +1,4 @@
#include "hills.hpp"
#include "kulle_5_png.hpp"
const unsigned char kulle_5_png[] = {
0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 0x0d, 0x49, 0x48, 0x44, 0x52,

6
src/data/kulle_5_png.hpp Normal file
View File

@ -0,0 +1,6 @@
#pragma once
#include <cstddef>
extern const unsigned char kulle_5_png[];
extern const size_t kulle_5_png_length;

View File

@ -1,4 +1,4 @@
#include "hills.hpp"
#include "kulle_6_png.hpp"
const unsigned char kulle_6_png[] = {
0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 0x0d, 0x49, 0x48, 0x44, 0x52,

6
src/data/kulle_6_png.hpp Normal file
View File

@ -0,0 +1,6 @@
#pragma once
#include <cstddef>
extern const unsigned char kulle_6_png[];
extern const size_t kulle_6_png_length;

View File

@ -1,4 +1,4 @@
#include "hills.hpp"
#include "kulle_7_png.hpp"
const unsigned char kulle_7_png[] = {
0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 0x0d, 0x49, 0x48, 0x44, 0x52,

6
src/data/kulle_7_png.hpp Normal file
View File

@ -0,0 +1,6 @@
#pragma once
#include <cstddef>
extern const unsigned char kulle_7_png[];
extern const size_t kulle_7_png_length;

View File

@ -1,25 +0,0 @@
#include <stdexcept>
#include "utils.hpp"
#include "SDL_image.h"
#include "data/hills.hpp"
std::vector<SDL_Surface *> get_hills() {
std::vector<SDL_Surface *> surfaces;
for (int i = 0; i < hills_length; i++) {
HillData png = hills[i];
SDL_RWops *rw = SDL_RWFromMem(const_cast<unsigned char *>(png.data), png.length);
if (!rw)
throw std::runtime_error("Failed to create RWops from memory");
SDL_Surface *surface = IMG_Load_RW(rw, 1);
if (!surface) {
SDL_RWclose(rw);
throw std::runtime_error("Failed to load image from memory: " + std::string(IMG_GetError()));
}
surfaces.push_back(surface);
}
return surfaces;
}

View File

@ -1,7 +1,7 @@
#pragma once
#include <vector>
#include "SDL_surface.h"
#include <cstddef>
template<typename T>
constexpr size_t array_len(T *array[]) {
@ -10,5 +10,3 @@ constexpr size_t array_len(T *array[]) {
i++;
return i;
}
std::vector<SDL_Surface*> get_hills();

View File

@ -12,7 +12,6 @@
"version>=": "2.0.20"
},
"sdl2-ttf",
"sdl2-image",
"curl"
]
}