SBSPSS/source/level/layercollision.cpp

158 lines
3.2 KiB
C++
Raw Normal View History

2001-02-02 19:39:16 +01:00
/******************************/
2001-02-02 20:16:49 +01:00
/*** Collision Layer Class ***/
2001-02-02 19:39:16 +01:00
/******************************/
#include "system\global.h"
#include <DStructs.h>
#include "utils\utils.h"
2001-02-02 20:16:49 +01:00
#include "LayerCollision.h"
2001-02-02 19:39:16 +01:00
/*****************************************************************************/
/*****************************************************************************/
/*****************************************************************************/
2001-02-02 20:16:49 +01:00
CLayerCollision::CLayerCollision(sLayerHdr *Hdr)
2001-02-02 19:39:16 +01:00
{
2001-02-02 20:16:49 +01:00
LayerHdr=Hdr;
Map=(u8*)MakePtr(Hdr,sizeof(sLayerHdr));
MapWidth=LayerHdr->Width;
MapHeight=LayerHdr->Height;
printf("COLLISION LAYER = %i %i\n",MapWidth,MapHeight);
2001-02-02 19:39:16 +01:00
}
/*****************************************************************************/
2001-02-02 20:16:49 +01:00
CLayerCollision::~CLayerCollision()
2001-02-02 19:39:16 +01:00
{
}
/*****************************************************************************/
2001-02-02 20:16:49 +01:00
void CLayerCollision::shutdown()
2001-02-02 19:39:16 +01:00
{
2001-02-13 17:44:54 +01:00
}
/*****************************************************************************/
#ifdef __SHOW_COLLISION__
#include "gfx\prim.h"
2001-02-13 23:36:06 +01:00
#include "pad\pads.h"
#if defined (__USER_paul__) || (__USER_art__)
2001-02-13 17:44:54 +01:00
int showCollision=true;
2001-02-13 17:46:16 +01:00
#else
int showCollision=false;
#endif
2001-02-13 17:44:54 +01:00
void CLayerCollision::render(DVECTOR &MapPos)
{
2001-02-13 23:36:06 +01:00
if(PadGetDown(0)&PAD_TRIANGLE)
{
showCollision=!showCollision;
}
2001-02-13 17:44:54 +01:00
if(showCollision)
{
int x,y;
int mapx,mapy;
int xoff,yoff;
u8 *coll;
POLY_F4 *f4;
2001-02-13 21:24:05 +01:00
POLY_F3 *f3;
2001-02-02 19:39:16 +01:00
2001-02-13 17:44:54 +01:00
xoff=MapPos.vx&15;
yoff=MapPos.vy&15;
mapx=MapPos.vx/16;
mapy=MapPos.vy/16;
for(y=-yoff;y<(20*16)-yoff;y+=16)
{
coll=&Map[mapx+(mapy*MapWidth)];
for(x=-xoff;x<(33*16)-xoff;x+=16)
{
2001-02-13 21:24:05 +01:00
switch(*coll)
2001-02-13 17:44:54 +01:00
{
2001-02-13 21:24:05 +01:00
case 0:
break;
case 1:
case 2:
f4=GetPrimF4();
setXYWH(f4,x,y,16,16);
setRGB0(f4,0,0,90);
setSemiTrans(f4,true);
AddPrimToList(f4,0);
break;
case 5:
f3=GetPrimF3();
setXY3(f3,x+16,y+16,
x,y+16,
x+16,y+8);
setRGB0(f3,0,0,90);
setSemiTrans(f3,true);
AddPrimToList(f3,0);
break;
case 6:
f3=GetPrimF3();
setXY3(f3,x,y+16,
x+16,y+16,
x,y+8);
setRGB0(f3,0,0,90);
setSemiTrans(f3,true);
AddPrimToList(f3,0);
break;
case 9:
f4=GetPrimF4();
setXY4(f4,x+16,y,
x,y+8,
x+16,y+16,
x,y+16);
setRGB0(f4,0,0,90);
setSemiTrans(f4,true);
AddPrimToList(f4,0);
break;
case 10:
f4=GetPrimF4();
setXY4(f4,x,y,
x+16,y+8,
x,y+16,
x+16,y+16);
setRGB0(f4,0,0,90);
setSemiTrans(f4,true);
AddPrimToList(f4,0);
break;
case 13:
f3=GetPrimF3();
setXY3(f3,x+16,y+16,
x,y+16,
x+16,y);
setRGB0(f3,0,0,90);
setSemiTrans(f3,true);
AddPrimToList(f3,0);
break;
case 14:
f3=GetPrimF3();
setXY3(f3,x,y+16,
x+16,y+16,
x,y);
setRGB0(f3,0,0,90);
setSemiTrans(f3,true);
AddPrimToList(f3,0);
break;
default:
f4=GetPrimF4();
setXYWH(f4,x,y,16,16);
setRGB0(f4,200,0,0);
setSemiTrans(f4,true);
AddPrimToList(f4,0);
break;
2001-02-13 17:44:54 +01:00
}
coll++;
}
mapy++;
}
}
2001-02-02 19:39:16 +01:00
}
2001-02-13 17:44:54 +01:00
#endif