location class header

This commit is contained in:
Frank DeMarco 2019-04-22 20:21:52 -04:00
parent 0c2b22017e
commit f5ace066ba
2 changed files with 11 additions and 81 deletions

View File

@ -1,6 +1,6 @@
SDLCONFIG = /home/frank/local/sdl/bin/sdl2-config
INC = -I$(PROJECTHOME)/glm -I$(PROJECTHOME)/sdl2-gfx -I$(PROJECTHOME)/glew
CFLAGS = $(shell $(SDLCONFIG) --cflags) -Wall -O2 -c $(INC)
CFLAGS = -std=c++17 $(shell $(SDLCONFIG) --cflags) -Wall -O2 -c $(INC)
LFLAGS = $(shell $(SDLCONFIG) --libs)
export ANDROID_HOME = /home/frank/ext/software/android-sdk
export ANDROID_NDK_HOME = /home/frank/ext/software/android-ndk-r8d
@ -25,18 +25,21 @@ CC_LINUX = clang-7
CPPC_LINUX = clang++-7
SDL2_gfxPrimitives.o : sdl2-gfx/SDL2_gfxPrimitives.c
$(CC_LINUX) $(CFLAGS) $^
$(CC_LINUX) $(CFLAGS) $<
SDL2_rotozoom.o : sdl2-gfx/SDL2_rotozoom.c
$(CC_LINUX) $(CFLAGS) $^
$(CC_LINUX) $(CFLAGS) $<
glew.o : glew/glew.c
$(CC_LINUX) $(CFLAGS) $^
$(CC_LINUX) $(CFLAGS) $<
main.o : main.cpp
$(CPPC_LINUX) $(CFLAGS) --std=c++17 $^
Location.o : Location.cpp Location.hpp
$(CPPC_LINUX) $(CFLAGS) $<
linux : main.o glew.o SDL2_rotozoom.o SDL2_gfxPrimitives.o
main.o : main.cpp main.hpp Location.hpp
$(CPPC_LINUX) $(CFLAGS) $<
linux : main.o Location.o glew.o SDL2_rotozoom.o SDL2_gfxPrimitives.o
$(CPPC_LINUX) $(LFLAGS) -D__LINUX__ $^ -lGL -lSDL2_image -lSDL2_ttf -lSDL2_mixer -lstdc++fs -o main
android :

View File

@ -1,50 +1,6 @@
// reset, pause, auto reset
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <vector>
#include <array>
#include <list>
#include <cstdlib>
#include <algorithm>
#include <string>
#if defined(__MINGW32__)
#include <experimental/filesystem>
namespace fs = std::experimental::filesystem;
#else
#include <filesystem>
namespace fs = std::filesystem;
#endif
#define SDL_MAIN_HANDLED
#include <SDL.h>
#include <SDL_image.h>
#include <SDL_ttf.h>
#include <SDL2_gfxPrimitives.h>
#include <SDL_mixer.h>
// #if defined(__LINUX__) or defined(__MINGW32__)
// #define GL_GLEXT_PROTOTYPES
// #include <GL/gl.h>
// #elif defined(__ANDROID__)
// #include <GLES/gl.h>
// #elif defined(__EMSCRIPTEN__)
// #include <GLES2/gl2.h>
// #elif defined(__APPLE__)
// #include <OpenGL/gl3.h>
// #endif
#define GL_GLEXT_PROTOTYPES
#define GLEW_STATIC
#include <glew.h>
#define GLM_ENABLE_EXPERIMENTAL
#include <glm/gtx/string_cast.hpp>
#include <glm/gtx/transform.hpp>
#include <glm/gtc/matrix_transform.hpp>
#include <SDL2_rotozoom.h>
#include "main.hpp"
char* file_to_buf(const char *path)
{
@ -195,35 +151,6 @@ void set_framerate_indicator(int frame_count, GLuint id)
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
}
struct Location
{
SDL_Rect rect = {0, 0, 0, 0};
glm::vec2 overflow;
Location() { };
template<typename T1, typename T2 = int>
void move_ip(T1 dx, T2 dy = 0)
{
overflow += glm::vec2(dx, dy);
glm::vec2 motion = glm::floor(overflow);
overflow -= motion;
rect.x += motion[0];
rect.y += motion[1];
}
int get_x()
{
return rect.x;
}
int get_y()
{
return rect.y;
}
};
struct Game;
struct Node