- testing jgame
This commit is contained in:
3
.gitignore
vendored
Normal file
3
.gitignore
vendored
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
*.exe
|
||||||
|
*.dll
|
||||||
|
vscode/*
|
||||||
BIN
data/test.gif
Normal file
BIN
data/test.gif
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 641 B |
@@ -204,7 +204,7 @@ namespace draw
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Pinta un troç de la superficie "source" en la superficie "destination".
|
// 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
|
// Si no hi ha superficie d'oritge especificada, no fem res, o petarà el mame
|
||||||
if (source == nullptr)
|
if (source == nullptr)
|
||||||
|
|||||||
20
source/jgame.cpp
Normal file
20
source/jgame.cpp
Normal 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
10
source/jgame.h
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
namespace game
|
||||||
|
{
|
||||||
|
|
||||||
|
void init();
|
||||||
|
|
||||||
|
bool loop();
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,7 +1,27 @@
|
|||||||
#include "jfile.h"
|
#include "jgame.h"
|
||||||
#include "jdraw.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;
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user