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
*.o
Source/LibMultiSpacc
Source/LibMultiSpacc/*

View File

@ -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)

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)
- [ ] 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

View File

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

View File

@ -1,9 +1,10 @@
#include <time.h>
#include <stdlib.h>
#include <stdbool.h>
#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;
}

View File

@ -1,11 +1,12 @@
#include <stdbool.h>
#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
);

View File

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