Upload stale local changes (MultiSpacc_PrintString)

This commit is contained in:
octospacc 2023-10-07 01:55:59 +02:00
parent 3480071958
commit 1c660aa6ec
5 changed files with 36 additions and 9 deletions

2
.gitignore vendored
View File

@ -1 +1,3 @@
*.o
*.exe
*.run

View File

@ -22,23 +22,26 @@ int main( int argc, char *args[] )
// Copyright (c) 2018 Doug Fraker www.nesdoug.com (MIT)
MultiSpacc_Surface *TilesImg = MultiSpacc_LoadImage( "Tiles.png", Screen, NULL );
const char Text[] = "Hello, World!";
for(int i = 0; i < sizeof(Text); i++){
SDL_Rect Offset = {
.x = (8 * i) + (ScreenWidth / sizeof(Text)),
/*char Text[] = "Hello, World!";
for(int i = 0; i < sizeof( Text ); i++){
MultiSpacc_Rect Offset = {
.x = (8 * i) + (ScreenWidth / sizeof( Text )),
.y = ScreenHeight / 3,
};
SDL_Rect Clip = {
.x = 8 * ((int)Text[i] % 16),
.y = 8 * ((int)Text[i] / 16),
MultiSpacc_Rect Clip = {
.x = 8 * (Text[i] % 16),
.y = 8 * (Text[i] / 16),
.w = 8,
.h = 8,
};
SDL_BlitSurface( TilesImg, &Clip, Screen, &Offset );
};
};*/
MultiSpacc_PrintString( "Hello, World!", Screen, ScreenWidth, ScreenHeight, 4, 4, TilesImg );
if( MultiSpacc_UpdateWindowSurface( Window ) != 0 ) {
if( MultiSpacc_UpdateWindowSurface( Window ) != 0 )
{
printf("[E] Error updating Screen.\n");
return -1;
};
MultiSpacc_Sleep( 3000 );

View File

@ -22,3 +22,5 @@ MultiSpacc_Surface *MultiSpacc_LoadImage( char FilePath[], MultiSpacc_Surface *S
int MultiSpacc_SetColorKey( MultiSpacc_Surface *Surface, bool Flag, Uint32 Key );
int MultiSpacc_PollEvent( MultiSpacc_Event *Event );
void MultiSpacc_PrintString( char Text[], MultiSpacc_Surface *Surface, int ScreenWidth, int ScreenHeight, int x, int y, MultiSpacc_Surface *Tiles /*, int FontSize, int Color */ ); // WIP

View File

@ -31,3 +31,22 @@ MultiSpacc_Surface *MultiSpacc_LoadImage( char FilePath[], MultiSpacc_Surface *S
};
return Final;
};
void MultiSpacc_PrintString( char Text[], MultiSpacc_Surface *Surface, int ScreenWidth, int ScreenHeight, int x, int y, MultiSpacc_Surface *Tiles /*, int FontSize, int Color */ )
{
for(int i = 0; i < strlen( Text ); i++)
//while(*(Text++))
{
MultiSpacc_Rect Offset = {
.x = (x * 8) + (8 * i),
.y = (y * 8),
};
MultiSpacc_Rect Clip = {
.x = 8 * (Text[i] % 16),
.y = 8 * (Text[i] / 16),
.w = 8,
.h = 8,
};
SDL_BlitSurface( Tiles, &Clip, Surface, &Offset );
};
};

View File

@ -6,3 +6,4 @@
#define MultiSpacc_Surface SDL_Surface
#define MultiSpacc_GetTicks SDL_GetTicks
#define MultiSpacc_Sleep SDL_Delay
#define MultiSpacc_Rect SDL_Rect