- testing jgame

This commit is contained in:
2023-02-28 19:09:25 +01:00
parent 08f4160503
commit 07d4e03930
6 changed files with 57 additions and 4 deletions

3
.gitignore vendored Normal file
View File

@@ -0,0 +1,3 @@
*.exe
*.dll
vscode/*

BIN
data/test.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 641 B

View File

@@ -204,7 +204,7 @@ namespace draw
}
// Pinta un troç de la superficie "source" en la superficie "destination".
void draw(const int dx, const int dy, const int w, const int h, const int sx, const int sy, const int flip = DRAW_FLIP_NONE)
void draw(const int dx, const int dy, const int w, const int h, const int sx, const int sy, const int flip)
{
// Si no hi ha superficie d'oritge especificada, no fem res, o petarà el mame
if (source == nullptr)

20
source/jgame.cpp Normal file
View File

@@ -0,0 +1,20 @@
#include "jgame.h"
#include "jdraw.h"
#include <SDL2/SDL.h>
int main(int argc, char *argv[])
{
game::init();
bool should_exit=false;
SDL_Event e;
while (!should_exit)
{
while(SDL_PollEvent(&e))
{
if (e.type==SDL_QUIT) { should_exit = true; break; }
}
if (!game::loop()) should_exit = true;
}
return 0;
}

10
source/jgame.h Normal file
View File

@@ -0,0 +1,10 @@
#pragma once
namespace game
{
void init();
bool loop();
}

View File

@@ -1,7 +1,27 @@
#include "jfile.h"
#include "jgame.h"
#include "jdraw.h"
int main(int argc, char *argv[])
{
draw::surface *surf;
void game::init()
{
draw::init("The Pool", 320, 240, 3);
surf = draw::loadSurface("test.gif");
draw::setSource(surf);
draw::loadPalette("test.gif");
}
bool game::loop()
{
draw::cls(0);
for (int y=0;y<8;++y)
{
for (int x=0;x<8;++x)
{
draw::draw(148+x*12-y*12,80+x*6+y*6,24,11,0,13);
}
}
draw::render();
return true;
}