Start porting code to work with LibMultiSpacc

This commit is contained in:
octospacc 2022-08-06 20:35:56 +02:00
parent 4b55257b4f
commit 8fff7d7a4e
7 changed files with 51 additions and 26 deletions

2
.gitignore vendored
View File

@ -1,2 +1,4 @@
*.exe *.exe
*.o *.o
Source/LibMultiSpacc
Source/LibMultiSpacc/*

View File

@ -2,27 +2,43 @@ AppName = BloccSpacc
ExeSuffix = .exe ExeSuffix = .exe
Sources = $(wildcard Source/*.c) Sources = $(wildcard Source/*.c)
Objects = $(Sources:.c=.o)
Defines = -DTarget_PC
CFlags = -O2 CFlags = -O2
LdFlags = -lSDL -lSDL_gfx -lSDL_image -lSDL_mixer -lSDL_ttf
CC = gcc $(Defines) CC = gcc $(Defines)
ifndef Target
Target = PC
endif
ifdef Target ifdef Target
ifeq ($(Target), PocketGo) ifeq ($(Target), PC)
Defines = -DTarget_PC
MultiSpacc_Target = SDL12
else ifeq ($(Target), PocketGo)
ExeSuffix = .PocketGo.exe ExeSuffix = .PocketGo.exe
PathPrefix = /opt/miyoo/bin/arm-miyoo-linux-uclibcgnueabi PathPrefix = /opt/miyoo/bin/arm-miyoo-linux-uclibcgnueabi
MultiSpacc_Target = SDL12
Defines = -DTarget_PocketGo Defines = -DTarget_PocketGo
CC = $(PathPrefix)-gcc $(Defines) CC = $(PathPrefix)-gcc $(Defines)
endif endif
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) all: $(AppName)
$(AppName): $(Objects) $(AppName): $(Objects)
$(CC) $^ $(CFlags) $(LdFlags) -o $(AppName)$(ExeSuffix) $(CC) $^ $(CFlags) $(LdFlags) -o $(AppName)$(ExeSuffix)
clean: clean:
rm -f Source/*.o $(AppName)$(ExeSuffix) $(AppName).*$(ExeSuffix) find -L . -name "*.o" -type f -delete
rm -f $(AppName)$(ExeSuffix) $(AppName).*$(ExeSuffix)

View File

@ -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) - [x] Moving cursor in all 3 axis (camera needs a fix to keep the cursor centered when it moves on Y)
- [ ] Rotating view - [ ] Rotating view
- [ ] HUD for selected blocks, view options, ... - [ ] 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 - [ ] "Layer view" (showing and moving only on 2 axis at a time, hiding other layers) for complex buildings
- [ ] Saving+Loading maps - [ ] Saving+Loading maps
- [ ] Zooming in/out on the map - [ ] 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 ### 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] Desktop GNU+Linux (main development platform)
- [x] Miyoo CFW Linux (tested on PocketGo) - [x] Miyoo CFW Linux (tested on PocketGo)
- [ ] Android - [ ] Android

View File

@ -1,5 +1,6 @@
#pragma once #pragma once
#include "SDL/SDL.h" #include "LibMultiSpacc/MultiSpacc.h"
//#include "SDL/SDL.h"
#define BlocksetNum 6 #define BlocksetNum 6
#define BlockSize 32 #define BlockSize 32

View File

@ -1,9 +1,10 @@
#include <time.h> #include <time.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdbool.h> #include <stdbool.h>
#include "SDL/SDL.h" #include "LibMultiSpacc/MultiSpacc.h"
#include "SDL/SDL_image.h" //#include "SDL/SDL.h"
#include "SDL/SDL_ttf.h" //#include "SDL/SDL_image.h"
//#include "SDL/SDL_ttf.h"
#include "TargetsConfigs.h" #include "TargetsConfigs.h"
#include "Blocks.h" #include "Blocks.h"
#include "Keys.h" #include "Keys.h"
@ -74,21 +75,22 @@ bool SysInit() {
printf("[E] Error initializing SDL_TTF.\n"); printf("[E] Error initializing SDL_TTF.\n");
return false; return false;
} }
SDL_WM_SetCaption ( AppName, "Assets/Icon.png" ); MultiSpacc_SetAppTitle( Screen, AppName );
MultiSpacc_SetAppIcon( Screen, LoadImage( "Assets/Cursorset.png" ) );
return true; return true;
} }
bool LoadAssets() { bool LoadAssets() {
bool Error = false; bool Error = false;
Cursorset = LoadImage ( "Assets/Cursorset.png" ); Cursorset = LoadImage( "Assets/Cursorset.png" );
if ( Cursorset == NULL ) { if ( Cursorset == NULL ) {
Error = true; Error = true;
} }
BlocksImg = LoadImage ( "Assets/Blocks.png" ); BlocksImg = LoadImage( "Assets/Blocks.png" );
if ( BlocksImg == NULL ) { if ( BlocksImg == NULL ) {
Error = true; Error = true;
} }
DebugFont = TTF_OpenFont ( "Assets/LiberationMono-Regular.ttf", 12 ); DebugFont = TTF_OpenFont( "Assets/LiberationMono-Regular.ttf", 12 );
if ( DebugFont == NULL ) { if ( DebugFont == NULL ) {
Error = true; Error = true;
} }
@ -99,7 +101,7 @@ bool LoadAssets() {
return true; return true;
} }
void MoveCursor (int Direction) { void MoveCursor( int Direction ) {
if ( Direction == 0 && CursorPos.z > 0 ) { // Up if ( Direction == 0 && CursorPos.z > 0 ) { // Up
CursorPos.z -= BlockSize; CursorPos.z -= BlockSize;
} }

View File

@ -1,11 +1,12 @@
#include <stdbool.h> #include <stdbool.h>
#include "SDL/SDL.h" #include "LibMultiSpacc/MultiSpacc.h"
#include "SDL/SDL_image.h" //#include "SDL/SDL.h"
//#include "SDL/SDL_image.h"
SDL_Surface * LoadImage ( char * FilePath ) { SDL_Surface * LoadImage ( char * FilePath ) {
SDL_Surface * a = NULL; SDL_Surface * a = NULL;
SDL_Surface * b = NULL; SDL_Surface * b = NULL;
a = IMG_Load ( FilePath ); a = IMG_Load ( FilePath );///*
if ( a == NULL ) { if ( a == NULL ) {
printf("[E] Error reading image %s.\n", FilePath); printf("[E] Error reading image %s.\n", FilePath);
} else { } else {
@ -15,10 +16,10 @@ SDL_Surface * LoadImage ( char * FilePath ) {
printf("[E] Error adapting image %s.\n", FilePath); printf("[E] Error adapting image %s.\n", FilePath);
} else { } else {
Uint32 ColorKey = SDL_MapRGB( b->format, 0xFF, 0x00, 0xFF ); // Magenta 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 ) { 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 #ifdef Target_PocketGo
SDL_HWSURFACE SDL_HWSURFACE
#else #else
//SDL_SWSURFACE //| SDL_SWSURFACE //|
SDL_HWSURFACE | //SDL_HWSURFACE |
SDL_DOUBLEBUF | //SDL_DOUBLEBUF |
SDL_RESIZABLE //| //SDL_RESIZABLE //|
//SDL_FULLSCREEN //| //SDL_FULLSCREEN //|
#endif #endif
); );

View File

@ -1,5 +1,6 @@
#pragma once #pragma once
#include <stdbool.h> #include <stdbool.h>
#include "LibMultiSpacc/MultiSpacc.h"
SDL_Surface * LoadImage ( char * FilePath ); SDL_Surface * LoadImage ( char * FilePath );
void DrawSurf ( int x, int y, SDL_Surface * Src, SDL_Rect * Clip, SDL_Surface * Dst ); void DrawSurf ( int x, int y, SDL_Surface * Src, SDL_Rect * Clip, SDL_Surface * Dst );