- Creat mòdul proc_explosio per a vore pixels volant quan se trenca algo
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
#include "proc_arounders.h"
|
#include "proc_arounders.h"
|
||||||
#include "jgame.h"
|
#include "jgame.h"
|
||||||
#include "proc_mapa.h"
|
#include "proc_mapa.h"
|
||||||
|
#include "proc_explosio.h"
|
||||||
|
|
||||||
namespace arounders
|
namespace arounders
|
||||||
{
|
{
|
||||||
@@ -108,6 +109,7 @@ namespace arounders
|
|||||||
draw::setSource(marca);
|
draw::setSource(marca);
|
||||||
draw::draw(arounders::seleccionat->x-3, arounders::seleccionat->y-3);
|
draw::draw(arounders::seleccionat->x-3, arounders::seleccionat->y-3);
|
||||||
}
|
}
|
||||||
|
explosio::pintar();
|
||||||
}
|
}
|
||||||
|
|
||||||
const bool seleccionar()
|
const bool seleccionar()
|
||||||
@@ -213,6 +215,7 @@ namespace arounders
|
|||||||
draw::draw(a->x-9, a->y-12);
|
draw::draw(a->x-9, a->y-12);
|
||||||
draw::setTrans(0);
|
draw::setTrans(0);
|
||||||
draw::setDestination(nullptr);
|
draw::setDestination(nullptr);
|
||||||
|
explosio::crear(a->x+4, a->y+3, 20, 200, 20, 0);
|
||||||
mapa::arounders::morts++;
|
mapa::arounders::morts++;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -862,6 +865,7 @@ namespace arounders
|
|||||||
void doCavar(arounder *a)
|
void doCavar(arounder *a)
|
||||||
{
|
{
|
||||||
if (a->orientacio == arounders::orientacions::dreta) {
|
if (a->orientacio == arounders::orientacions::dreta) {
|
||||||
|
explosio::crear(a->x+8, a->y, 10, 200, 10, 3);
|
||||||
put_pixel(a->x+8, a->y, 0);
|
put_pixel(a->x+8, a->y, 0);
|
||||||
put_pixel(a->x+8, a->y+1, 0);
|
put_pixel(a->x+8, a->y+1, 0);
|
||||||
put_pixel(a->x+8, a->y+2, 0);
|
put_pixel(a->x+8, a->y+2, 0);
|
||||||
@@ -871,6 +875,7 @@ namespace arounders
|
|||||||
put_pixel(a->x+8, a->y+6, 0);
|
put_pixel(a->x+8, a->y+6, 0);
|
||||||
put_pixel(a->x+8, a->y+7, 0);
|
put_pixel(a->x+8, a->y+7, 0);
|
||||||
} else {
|
} else {
|
||||||
|
explosio::crear(a->x-1, a->y, 10, 200, 10, 3);
|
||||||
put_pixel(a->x-1, a->y, 0);
|
put_pixel(a->x-1, a->y, 0);
|
||||||
put_pixel(a->x-1, a->y+1, 0);
|
put_pixel(a->x-1, a->y+1, 0);
|
||||||
put_pixel(a->x-1, a->y+2, 0);
|
put_pixel(a->x-1, a->y+2, 0);
|
||||||
@@ -880,10 +885,12 @@ namespace arounders
|
|||||||
put_pixel(a->x-1, a->y+6, 0);
|
put_pixel(a->x-1, a->y+6, 0);
|
||||||
put_pixel(a->x-1, a->y+7, 0);
|
put_pixel(a->x-1, a->y+7, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void doPerforar(arounder *a)
|
void doPerforar(arounder *a)
|
||||||
{
|
{
|
||||||
|
explosio::crear(a->x+4, a->y+8, 10, 200, 10, 3);
|
||||||
put_pixel(a->x , a->y+8, 0);
|
put_pixel(a->x , a->y+8, 0);
|
||||||
put_pixel(a->x+1, a->y+8, 0);
|
put_pixel(a->x+1, a->y+8, 0);
|
||||||
put_pixel(a->x+2, a->y+8, 0);
|
put_pixel(a->x+2, a->y+8, 0);
|
||||||
|
|||||||
74
source/proc_explosio.cpp
Normal file
74
source/proc_explosio.cpp
Normal file
@@ -0,0 +1,74 @@
|
|||||||
|
#include "proc_explosio.h"
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include "jgame.h"
|
||||||
|
|
||||||
|
namespace explosio
|
||||||
|
{
|
||||||
|
struct tipo_pix // Cada pixel de la explosió
|
||||||
|
{
|
||||||
|
float x, y;
|
||||||
|
float xa, ya;
|
||||||
|
float g;
|
||||||
|
uint8_t c;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct tipo_exp // Tipo per a les explosions
|
||||||
|
{
|
||||||
|
int numpix;
|
||||||
|
tipo_pix pix[50];
|
||||||
|
int count;
|
||||||
|
};
|
||||||
|
|
||||||
|
static tipo_exp exp[10];
|
||||||
|
static int numexp {0};
|
||||||
|
|
||||||
|
void crear(const int x, const int y, const int num, const int c1, const int c2, const int c3)
|
||||||
|
{
|
||||||
|
if ( numexp >= 9 || numexp < 0 ) return;
|
||||||
|
|
||||||
|
exp[numexp].count = 0;
|
||||||
|
exp[numexp].numpix = num*2;
|
||||||
|
const int expansio = c2*100;
|
||||||
|
for (int i=0; i<=exp[numexp].numpix; ++i)
|
||||||
|
{
|
||||||
|
exp[numexp].pix[i].x = x;
|
||||||
|
exp[numexp].pix[i].y = y;
|
||||||
|
exp[numexp].pix[i].xa = float((rand()%expansio) - (expansio >> 1))/1000.0f;
|
||||||
|
exp[numexp].pix[i].ya = float((rand()%expansio) - (expansio >> 1))/1000.0f;
|
||||||
|
exp[numexp].pix[i].g = 0.05;
|
||||||
|
exp[numexp].pix[i].c = rand()%60;
|
||||||
|
}
|
||||||
|
numexp++;
|
||||||
|
}
|
||||||
|
|
||||||
|
void pintar()
|
||||||
|
{
|
||||||
|
int c1 = 0;
|
||||||
|
|
||||||
|
while (c1 != numexp)
|
||||||
|
{
|
||||||
|
for (int c2=0; c2<=exp[c1].numpix; ++c2)
|
||||||
|
{
|
||||||
|
exp[c1].pix[c2].x = exp[c1].pix[c2].x + exp[c1].pix[c2].xa;
|
||||||
|
exp[c1].pix[c2].ya = exp[c1].pix[c2].ya + exp[c1].pix[c2].g;
|
||||||
|
exp[c1].pix[c2].y = exp[c1].pix[c2].y + exp[c1].pix[c2].ya;
|
||||||
|
//if ((exp[c1].pix[c2].x > 0) && (exp[c1].pix[c2].x < 319) && (exp[c1].pix[c2].y > 0) && (exp[c1].pix[c2].y < 199))
|
||||||
|
draw::putPixel(exp[c1].pix[c2].x, exp[c1].pix[c2].y, exp[c1].pix[c2].c);
|
||||||
|
}
|
||||||
|
exp[c1].count++;
|
||||||
|
|
||||||
|
c1++;
|
||||||
|
|
||||||
|
if (exp[c1-1].count == 80)
|
||||||
|
{
|
||||||
|
numexp--;
|
||||||
|
c1--;
|
||||||
|
if (c1 != numexp)
|
||||||
|
{
|
||||||
|
exp[c1] = exp[numexp];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
8
source/proc_explosio.h
Normal file
8
source/proc_explosio.h
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
namespace explosio
|
||||||
|
{
|
||||||
|
void crear(const int x, const int y, const int num, const int c1, const int c2, const int c3);
|
||||||
|
|
||||||
|
void pintar();
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user