Compare commits
3 Commits
0cee2e3c36
...
2b60054466
| Author | SHA1 | Date | |
|---|---|---|---|
| 2b60054466 | |||
| ee4d869ac9 | |||
| 40a531f8b5 |
@@ -323,7 +323,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)
|
||||
void draw(const int dx, const int dy, const int w, const int h, const int sx, const int sy, const int flip, int dw, int dh)
|
||||
{
|
||||
// Si no hi ha superficie d'oritge especificada, no fem res, o petarà el mame
|
||||
if (source == nullptr)
|
||||
@@ -331,20 +331,26 @@ namespace draw
|
||||
return;
|
||||
}
|
||||
|
||||
if (dw==0) dw = w;
|
||||
if (dh==0) dh = h;
|
||||
|
||||
// En principi, el quadrat de l'oritge començarà en (sx,sy) i avançarem 1 pixel en positiu tant en x com en y
|
||||
int sdx = 1, sdy = 1, ssx = sx, ssy = sy;
|
||||
float sdx = float(w)/float(dw);
|
||||
float sdy = float(h)/float(dh);
|
||||
float ssx = sx;
|
||||
float ssy = sy;
|
||||
|
||||
// Però si s'ha especificat que fem flip en horitzontal...
|
||||
if (flip & DRAW_FLIP_HORIZONTAL)
|
||||
{
|
||||
sdx = -1; // Avançarem 1 pixel en negatiu
|
||||
sdx = -sdx; // Avançarem 1 pixel en negatiu
|
||||
ssx = sx + w - 1; // I començarem al final, o siga, sumarem a sx el ample
|
||||
}
|
||||
|
||||
// De igual forma per al flip en vertical, per a la y
|
||||
if (flip & DRAW_FLIP_VERTICAL)
|
||||
{
|
||||
sdy = -1;
|
||||
sdy = -sdy;
|
||||
ssy = sy + h - 1;
|
||||
}
|
||||
|
||||
@@ -352,12 +358,12 @@ namespace draw
|
||||
int csx = ssx;
|
||||
|
||||
// Anem linea per linea. Les variables dels dos bucles for controlen les coordenades en la destinació, que sempre van avant.
|
||||
for (int y = dy; y < dy + h; ++y)
|
||||
for (int y = dy; y < dy + dh; ++y)
|
||||
{
|
||||
ssx = csx; // fiquem la coordenada de l'oritge al principi
|
||||
|
||||
// en cada linea, anem pixel a pixel
|
||||
for (int x = dx; x < dx + w; ++x)
|
||||
for (int x = dx; x < dx + dw; ++x)
|
||||
{
|
||||
pset(destination, x, y, pget(source, ssx, ssy)); // Agafem pixel de l'oritge i el fiquem en la destinació
|
||||
ssx += sdx; // avancem (o retrocedim) la coordenada x de l'oritge
|
||||
@@ -445,7 +451,7 @@ namespace draw
|
||||
for (int i=0;i<len;++i)
|
||||
{
|
||||
char chr = text[i]-32;
|
||||
draw((x+i)*8, y*8, zoom&FONT_ZOOM_HORIZONTAL?16:8, zoom&FONT_ZOOM_VERTICAL?16:8, (chr&15)*8, (chr>>4)*8);
|
||||
draw((x+i)*8, y*8, 8, 8, (chr&15)*8, (chr>>4)*8, DRAW_FLIP_NONE,zoom&FONT_ZOOM_HORIZONTAL?16:8, zoom&FONT_ZOOM_VERTICAL?16:8);
|
||||
}
|
||||
source = tmp;
|
||||
}
|
||||
|
||||
@@ -95,7 +95,7 @@ namespace draw
|
||||
/// @param sx coordenada x de l'oritge
|
||||
/// @param sy coordenada y de l'oritge
|
||||
/// @param flip si s'ha de fer flip en hortizontal o vertical (o ambdos)
|
||||
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 = DRAW_FLIP_NONE, int dw=0, int dh=0);
|
||||
|
||||
void swapcol(const uint8_t c1, const uint8_t c2);
|
||||
void restorecol(const uint8_t c);
|
||||
|
||||
@@ -94,7 +94,7 @@ namespace modules
|
||||
{
|
||||
draw::fillrect(60+pixels[i].x*4, 106+pixels[i].y*4, 4*pixels[i].di, 4*pixels[i].di);
|
||||
}
|
||||
} else {
|
||||
} else if (steps>280) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
32
source/m_menu.cpp
Normal file
32
source/m_menu.cpp
Normal file
@@ -0,0 +1,32 @@
|
||||
#include "m_menu.h"
|
||||
#include "jgame.h"
|
||||
#include "jinput.h"
|
||||
#include "jdraw.h"
|
||||
#include <SDL2/SDL.h>
|
||||
|
||||
namespace modules
|
||||
{
|
||||
namespace menu
|
||||
{
|
||||
void init()
|
||||
{
|
||||
::game::setUpdateTicks(64);
|
||||
|
||||
}
|
||||
|
||||
bool loop()
|
||||
{
|
||||
if (input::keyDown(SDL_SCANCODE_ESCAPE)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
draw::cls(2);
|
||||
draw::color(1);
|
||||
|
||||
draw::print2("THE POOL", 16, 3, YELLOW, FONT_ZOOM_VERTICAL);
|
||||
|
||||
draw::render();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
10
source/m_menu.h
Normal file
10
source/m_menu.h
Normal file
@@ -0,0 +1,10 @@
|
||||
#pragma once
|
||||
|
||||
namespace modules
|
||||
{
|
||||
namespace menu
|
||||
{
|
||||
void init();
|
||||
bool loop();
|
||||
}
|
||||
}
|
||||
@@ -5,10 +5,12 @@
|
||||
#include "string.h"
|
||||
|
||||
#include "m_game.h"
|
||||
#include "m_menu.h"
|
||||
#include "m_logo.h"
|
||||
|
||||
#define M_LOGO 0
|
||||
#define M_GAME 1
|
||||
#define M_MENU 1
|
||||
#define M_GAME 2
|
||||
int current_module = M_LOGO;
|
||||
|
||||
void game::init()
|
||||
@@ -24,7 +26,12 @@ void game::init()
|
||||
|
||||
draw::loadPalette("test.gif");
|
||||
|
||||
modules::logo::init();
|
||||
if (editor::isDevMode()) {
|
||||
current_module = M_GAME;
|
||||
modules::game::init();
|
||||
|
||||
} else
|
||||
modules::logo::init();
|
||||
}
|
||||
|
||||
bool game::loop()
|
||||
@@ -32,7 +39,10 @@ bool game::loop()
|
||||
switch(current_module)
|
||||
{
|
||||
case M_LOGO:
|
||||
if (!modules::logo::loop()) { modules::game::init(); current_module = M_GAME; }
|
||||
if (!modules::logo::loop()) { modules::menu::init(); current_module = M_MENU; }
|
||||
break;
|
||||
case M_MENU:
|
||||
if (!modules::menu::loop()) { modules::game::init(); current_module = M_GAME; }
|
||||
break;
|
||||
case M_GAME:
|
||||
return modules::game::loop();
|
||||
|
||||
Reference in New Issue
Block a user