diff --git a/.gitignore b/.gitignore index 774f008..3ee1a83 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ *.exe *.o +Source/LibMultiSpacc +Source/LibMultiSpacc/* diff --git a/Makefile b/Makefile index dc1906d..44c8af4 100644 --- a/Makefile +++ b/Makefile @@ -2,27 +2,43 @@ AppName = BloccSpacc ExeSuffix = .exe Sources = $(wildcard Source/*.c) -Objects = $(Sources:.c=.o) - -Defines = -DTarget_PC CFlags = -O2 -LdFlags = -lSDL -lSDL_gfx -lSDL_image -lSDL_mixer -lSDL_ttf - CC = gcc $(Defines) +ifndef Target + Target = PC +endif + ifdef Target - ifeq ($(Target), PocketGo) + ifeq ($(Target), PC) + Defines = -DTarget_PC + MultiSpacc_Target = SDL12 + else ifeq ($(Target), PocketGo) ExeSuffix = .PocketGo.exe PathPrefix = /opt/miyoo/bin/arm-miyoo-linux-uclibcgnueabi + MultiSpacc_Target = SDL12 Defines = -DTarget_PocketGo CC = $(PathPrefix)-gcc $(Defines) endif endif +ifeq ($(MultiSpacc_Target), SDL12) + Defines += -DMultiSpacc_Target_SDL12 + LdFlags += -lSDL -lSDL_image -lSDL_mixer -lSDL_ttf + Sources += $(wildcard Source/LibMultiSpacc/*.c Source/LibMultiSpacc/SDL12/*.c) +else ifeq ($(MultiSpacc_Target), SDL20) + Defines += -DMultiSpacc_Target_SDL20 + LdFlags += -lSDL2 -lSDL2_image -lSDL2_mixer -lSDL2_ttf + Sources += $(wildcard Source/LibMultiSpacc/*.c Source/LibMultiSpacc/SDL20/*.c) +endif + +Objects = $(Sources:.c=.o) + all: $(AppName) $(AppName): $(Objects) $(CC) $^ $(CFlags) $(LdFlags) -o $(AppName)$(ExeSuffix) clean: - rm -f Source/*.o $(AppName)$(ExeSuffix) $(AppName).*$(ExeSuffix) + find -L . -name "*.o" -type f -delete + rm -f $(AppName)$(ExeSuffix) $(AppName).*$(ExeSuffix) diff --git a/README.md b/README.md index 2325355..4bca8dd 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ The game is still in heavy development. Edges are rough, stuff might break from - [x] Moving cursor in all 3 axis (camera needs a fix to keep the cursor centered when it moves on Y) - [ ] Rotating view - [ ] HUD for selected blocks, view options, ... -- [ ] Inventory +- [x] Inventory - [ ] "Layer view" (showing and moving only on 2 axis at a time, hiding other layers) for complex buildings - [ ] Saving+Loading maps - [ ] Zooming in/out on the map @@ -35,6 +35,8 @@ The game is still in heavy development. Edges are rough, stuff might break from ### Current and planned platforms +_Note: This project, and its portability, depend on [LibMultiSpacc](https://gitlab.com/octospacc/LibMultiSpacc)._ + - [x] Desktop GNU+Linux (main development platform) - [x] Miyoo CFW Linux (tested on PocketGo) - [ ] Android diff --git a/Source/Blocks.h b/Source/Blocks.h index 131d717..92c69d7 100644 --- a/Source/Blocks.h +++ b/Source/Blocks.h @@ -1,5 +1,6 @@ #pragma once -#include "SDL/SDL.h" +#include "LibMultiSpacc/MultiSpacc.h" +//#include "SDL/SDL.h" #define BlocksetNum 6 #define BlockSize 32 diff --git a/Source/Main.c b/Source/Main.c index 06b8869..2a2eeea 100644 --- a/Source/Main.c +++ b/Source/Main.c @@ -1,9 +1,10 @@ #include #include #include -#include "SDL/SDL.h" -#include "SDL/SDL_image.h" -#include "SDL/SDL_ttf.h" +#include "LibMultiSpacc/MultiSpacc.h" +//#include "SDL/SDL.h" +//#include "SDL/SDL_image.h" +//#include "SDL/SDL_ttf.h" #include "TargetsConfigs.h" #include "Blocks.h" #include "Keys.h" @@ -74,21 +75,22 @@ bool SysInit() { printf("[E] Error initializing SDL_TTF.\n"); return false; } - SDL_WM_SetCaption ( AppName, "Assets/Icon.png" ); + MultiSpacc_SetAppTitle( Screen, AppName ); + MultiSpacc_SetAppIcon( Screen, LoadImage( "Assets/Cursorset.png" ) ); return true; } bool LoadAssets() { bool Error = false; - Cursorset = LoadImage ( "Assets/Cursorset.png" ); + Cursorset = LoadImage( "Assets/Cursorset.png" ); if ( Cursorset == NULL ) { Error = true; } - BlocksImg = LoadImage ( "Assets/Blocks.png" ); + BlocksImg = LoadImage( "Assets/Blocks.png" ); if ( BlocksImg == NULL ) { Error = true; } - DebugFont = TTF_OpenFont ( "Assets/LiberationMono-Regular.ttf", 12 ); + DebugFont = TTF_OpenFont( "Assets/LiberationMono-Regular.ttf", 12 ); if ( DebugFont == NULL ) { Error = true; } @@ -99,7 +101,7 @@ bool LoadAssets() { return true; } -void MoveCursor (int Direction) { +void MoveCursor( int Direction ) { if ( Direction == 0 && CursorPos.z > 0 ) { // Up CursorPos.z -= BlockSize; } diff --git a/Source/Util.c b/Source/Util.c index c623a27..d8fe96f 100644 --- a/Source/Util.c +++ b/Source/Util.c @@ -1,11 +1,12 @@ #include -#include "SDL/SDL.h" -#include "SDL/SDL_image.h" +#include "LibMultiSpacc/MultiSpacc.h" +//#include "SDL/SDL.h" +//#include "SDL/SDL_image.h" SDL_Surface * LoadImage ( char * FilePath ) { SDL_Surface * a = NULL; SDL_Surface * b = NULL; - a = IMG_Load ( FilePath ); + a = IMG_Load ( FilePath );///* if ( a == NULL ) { printf("[E] Error reading image %s.\n", FilePath); } else { @@ -15,10 +16,10 @@ SDL_Surface * LoadImage ( char * FilePath ) { printf("[E] Error adapting image %s.\n", FilePath); } else { Uint32 ColorKey = SDL_MapRGB( b->format, 0xFF, 0x00, 0xFF ); // Magenta - SDL_SetColorKey( b, SDL_SRCCOLORKEY, ColorKey ); + MultiSpacc_SetColorKey( b, true, ColorKey ); } } - return b; + return b;//*/return a; } void DrawSurf ( int x, int y, SDL_Surface * Src, SDL_Rect * Clip, SDL_Surface * Dst ) { @@ -59,10 +60,10 @@ SDL_Surface * ScreenSet ( int Width, int Height, int Bits, SDL_Surface * Screen #ifdef Target_PocketGo SDL_HWSURFACE #else - //SDL_SWSURFACE //| - SDL_HWSURFACE | - SDL_DOUBLEBUF | - SDL_RESIZABLE //| + SDL_SWSURFACE //| + //SDL_HWSURFACE | + //SDL_DOUBLEBUF | + //SDL_RESIZABLE //| //SDL_FULLSCREEN //| #endif ); diff --git a/Source/Util.h b/Source/Util.h index f006d22..dcfd01b 100644 --- a/Source/Util.h +++ b/Source/Util.h @@ -1,5 +1,6 @@ #pragma once #include +#include "LibMultiSpacc/MultiSpacc.h" SDL_Surface * LoadImage ( char * FilePath ); void DrawSurf ( int x, int y, SDL_Surface * Src, SDL_Rect * Clip, SDL_Surface * Dst );