|
|
@ -4,17 +4,17 @@
|
|
|
|
#include "network.h"
|
|
|
|
#include "network.h"
|
|
|
|
#include "gfx.h"
|
|
|
|
#include "gfx.h"
|
|
|
|
#include "sound.h"
|
|
|
|
#include "sound.h"
|
|
|
|
|
|
|
|
#include <math.h>
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
void
|
|
|
|
draw_bomb (_bomb * bomb)
|
|
|
|
draw_bomb (_bomb * bomb)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
SDL_Rect src,
|
|
|
|
SDL_Rect src,
|
|
|
|
dest;
|
|
|
|
dest;
|
|
|
|
int x = bomb->pos.x >> 8,
|
|
|
|
int x = bomb->pos.x,
|
|
|
|
y = bomb->pos.y >> 8;
|
|
|
|
y = bomb->pos.y;
|
|
|
|
|
|
|
|
|
|
|
|
if (x < 0 || y < 0 || x >= bman.fieldsize.x || y >= bman.fieldsize.y) {
|
|
|
|
if (x < 0 || y < 0 || x>>8 >= bman.fieldsize.x || y>>8 >= bman.fieldsize.y) {
|
|
|
|
d_fatal ("Draw Bomb out of range [%d,%d]\n", x, y);
|
|
|
|
d_fatal ("Draw Bomb out of range [%d,%d]\n", x, y);
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -34,12 +34,12 @@ draw_bomb (_bomb * bomb)
|
|
|
|
dest.w = src.w = gfx.bomb.image->w;
|
|
|
|
dest.w = src.w = gfx.bomb.image->w;
|
|
|
|
dest.h = src.h = gfx.block.y;
|
|
|
|
dest.h = src.h = gfx.block.y;
|
|
|
|
|
|
|
|
|
|
|
|
dest.x = gfx.offset.x + (x * gfx.block.x);
|
|
|
|
dest.x = gfx.offset.x + (x* gfx.block.x/0x100);
|
|
|
|
dest.y = gfx.offset.y + (y * gfx.block.y);
|
|
|
|
dest.y = gfx.offset.y + (y* gfx.block.y/0x100);
|
|
|
|
|
|
|
|
|
|
|
|
src.x = 0;
|
|
|
|
src.x = 0;
|
|
|
|
src.y = src.h * bomb->frame;
|
|
|
|
src.y = src.h * bomb->frame;
|
|
|
|
draw_stone (x, y);
|
|
|
|
draw_stone (x>>8, y>>8);
|
|
|
|
SDL_BlitSurface (gfx.bomb.image, &src, gfx.screen, &dest);
|
|
|
|
SDL_BlitSurface (gfx.bomb.image, &src, gfx.screen, &dest);
|
|
|
|
|
|
|
|
|
|
|
|
gfx_AddUpdateRect (dest.x, dest.y, dest.w, dest.h);
|
|
|
|
gfx_AddUpdateRect (dest.x, dest.y, dest.w, dest.h);
|
|
|
@ -74,33 +74,71 @@ bomb_explode (int p, int b, int net)
|
|
|
|
void
|
|
|
|
void
|
|
|
|
bomb_move (_bomb * bomb)
|
|
|
|
bomb_move (_bomb * bomb)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
_point npos;
|
|
|
|
_point npos,fpos;
|
|
|
|
if (bomb->pos.x == bomb->moveto.x) {
|
|
|
|
int dx = 0,
|
|
|
|
if (bomb->pos.y == bomb->moveto.y) {
|
|
|
|
dy = 0;
|
|
|
|
bomb->moves = 0;
|
|
|
|
float vec;
|
|
|
|
return;
|
|
|
|
if (bomb->moveto.x < 0) {
|
|
|
|
|
|
|
|
switch (bomb->moveto.x) {
|
|
|
|
|
|
|
|
case -1:
|
|
|
|
|
|
|
|
case -2:
|
|
|
|
|
|
|
|
dx = -bomb->moves; //move bomb left
|
|
|
|
|
|
|
|
case -3:
|
|
|
|
|
|
|
|
case -4:
|
|
|
|
|
|
|
|
dx = bomb->moves; //move bomb right
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (bomb->pos.y > bomb->moveto.y) {
|
|
|
|
|
|
|
|
npos.y = bomb->pos.y - bomb->moves; //move bomb up
|
|
|
|
|
|
|
|
npos.x = bomb->pos.x;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
else {
|
|
|
|
npos.y = bomb->pos.y + bomb->moves; // move bomb down
|
|
|
|
dx = bomb->moveto.x - bomb->pos.x; //move bomb to field
|
|
|
|
npos.x = bomb->pos.x;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (bomb->moveto.y < 0) {
|
|
|
|
|
|
|
|
switch (bomb->moveto.y) {
|
|
|
|
|
|
|
|
case -1:
|
|
|
|
|
|
|
|
case -2:
|
|
|
|
|
|
|
|
dy = -bomb->moves; //move bomb up
|
|
|
|
|
|
|
|
case -3:
|
|
|
|
|
|
|
|
case -4:
|
|
|
|
|
|
|
|
dy = bomb->moves; //move bomb down
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
|
|
|
|
if (bomb->pos.x > bomb->moveto.x) {
|
|
|
|
|
|
|
|
npos.x = bomb->pos.x - bomb->moves; //move bomb left
|
|
|
|
|
|
|
|
npos.y = bomb->pos.y;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
else {
|
|
|
|
npos.x = bomb->pos.x + bomb->moves; // move bomb right
|
|
|
|
dy = bomb->moveto.y - bomb->pos.y; //move bomb to field
|
|
|
|
npos.y = bomb->pos.y;
|
|
|
|
}
|
|
|
|
|
|
|
|
d_printf("move bomb %d %d\n",dx,dy);
|
|
|
|
|
|
|
|
if (!dx && !dy) { // bomb has reached its final position
|
|
|
|
|
|
|
|
bomb->moves = 0;
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// calculate movement
|
|
|
|
|
|
|
|
if (abs(dx)>bomb->moves || abs(dy)>bomb->moves) {
|
|
|
|
|
|
|
|
vec=sqrt(dx*dx+dy*dy);
|
|
|
|
|
|
|
|
dx=dx*bomb->moves/vec;
|
|
|
|
|
|
|
|
dy=dy*bomb->moves/vec;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
npos.x=bomb->pos.x+dx;
|
|
|
|
|
|
|
|
npos.y=bomb->pos.y+dy;
|
|
|
|
|
|
|
|
d_printf("move bomb %d %d\n",dx,dy);
|
|
|
|
|
|
|
|
// check if field is used
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
if (!(dx && dy)) {
|
|
|
|
|
|
|
|
fpos.x=npos.x>>8;
|
|
|
|
|
|
|
|
fpos.y=npos.y>>8;
|
|
|
|
|
|
|
|
if (((npos.x & 0xff ) >0) && (dx>0)) fpos.x++;
|
|
|
|
|
|
|
|
if (((npos.y & 0xff ) >0) && (dy>0)) fpos.y++;
|
|
|
|
|
|
|
|
if (bman.bfield[fpos.x][fpos.y] || bman.field[fpos.x][fpos.y].type != FT_nothing) {
|
|
|
|
|
|
|
|
npos.x &= 0xff00;
|
|
|
|
|
|
|
|
npos.y &= 0xff00;
|
|
|
|
|
|
|
|
if (dx<0) npos.x+=0x100;
|
|
|
|
|
|
|
|
if (dy<0) npos.y+=0x100;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
bomb->pos.x=npos.x;
|
|
|
|
|
|
|
|
bomb->pos.y=npos.y;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int
|
|
|
|
int
|
|
|
|
bomb_loop ()
|
|
|
|
bomb_loop ()
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -135,7 +173,7 @@ bomb_loop ()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
draw_bomb (bomb);
|
|
|
|
draw_bomb (bomb);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// if (bomb->moves>0) bomb_move(bomb);
|
|
|
|
if (bomb->moves>0) bomb_move(bomb);
|
|
|
|
b++; // Count ticking Bombs for Return value
|
|
|
|
b++; // Count ticking Bombs for Return value
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case BS_exploding:
|
|
|
|
case BS_exploding:
|
|
|
|