In Iron Infantry... We GO THROUGH THE FREAKING WALLS! ... LOL... just kidding
Um... Hang ON <grrr> <LOL> I like you man.. I'll give you a simple "Head Banger" demo ok?
NEEDS SPARKY's!
#include "DarkGDK.h"
#include "SC_Collision.h"
void DarkGDK ( void )
{
dbSyncOn ( );
dbSyncRate ( 60 );
SC_Start( );
// Walls.
dbMakeObjectBox(1, 100, 100, 16);
dbMakeObjectBox(2, 100, 100, 16);
dbPositionObject(1, 50, 50, 100);
dbPositionObject(2, 200, 50, 50);
SC_SetupObject(1, 1, 2); // Groups other than ZERO for stuff you hit
SC_SetupObject(2, 1, 2); // reserve ZERO for your player :)
// I think this is a good idea - I'm not sure you can have a group item hit something
// in the same group. That MIGHT be an issue you came across and didn't know it.
// Player.
dbMakeObjectCube(3, 32);
dbPositionObject(3, 0, 16, 0);
SC_SetupObject(3, 2, 2);
// Camera Object.
//dbMakeObjectCube(4, 100);
//dbHideObject(4);
//SC_SetupObject(4, 0, 2);
// Old Values. (More Efficient I THINK declaring up here).
// maybe no difference seeing how SCOPE didn;t change... anyways...
float ox;
float oy;
float oz;
float oax;
float oay;
float oaz;
int iCollideID=0;
while ( LoopGDK ( ) )
{
//float ay = dbObjectAngleY(3);
// Old Values.
//ox = dbCameraPositionX();
//oy = dbCameraPositionY();
//oz = dbCameraPositionZ();
ox =dbObjectPositionX(3);
oy =dbObjectPositionY(3);
oz =dbObjectPositionZ(3);
oax = dbObjectAngleX(3);
oay = dbObjectAngleY(3);
oaz = dbObjectAngleZ(3);
// I move the player.
if (dbUpKey() == 1)
{
dbMoveObject(3, 1.0);
}
if (dbDownKey() == 1)
{
dbMoveObject(3, -1.0);
}
if (dbLeftKey() == 1)
{
//dbYRotateObject(3, oy + 1.0);
dbTurnObjectLeft(3,1.0);
}
if (dbRightKey() == 1)
{
//dbYRotateObject(3, oy - 1.0);
dbTurnObjectRight(3,1.0);
}
SC_UpdateObject(3);
iCollideID = SC_GroupCollision(3,1);// your Box, and Group 1
if(iCollideID>0){
dbPositionObject(3,ox,oy,oz);
dbRotateObject(3,oax,oay,oaz);
};
dbPositionCamera(dbObjectPositionX(3),dbObjectPositionY(3),dbObjectPositionZ(3));
dbRotateCamera(dbObjectAngleX(3),dbObjectAngleY(3),dbObjectAngleZ(3));
dbMoveCamera(-160);
dbPitchCameraUp(90);
dbMoveCamera(40);
dbPointCamera(dbObjectPositionX(3),dbObjectPositionY(3),dbObjectPositionZ(3));
// I move the Camera Object.
//float cz = dbNewZValue(dbObjectPositionZ(3), dbWrapValue(ay + 180), 100);
//float cx = dbNewXValue(dbObjectPositionX(3), dbWrapValue(ay + 180), 100);
//dbPositionObject(4, cx, dbObjectPositionY(3) + 30, cz);
//dbRotateObject(4, dbObjectAngleX(3), dbObjectAngleY(3), dbObjectAngleZ(3));
// Camera Object collision.
//if (dbObjectCollision(4, 0) > 0)
//{
// dbPositionObject(4, ox, oy, oz);
// dbRotateObject(4, oax, oay, oaz);
//}
// I place the camera.
//dbPositionCamera(dbObjectPositionX(4), dbObjectPositionY(4), dbObjectPositionZ(4));
//dbRotateCamera(dbObjectAngleX(4), dbObjectAngleY(4), dbObjectAngleZ(4));
dbSetCursor(0,0);
dbPrint(dbStr(iCollideID));
dbSync ( );
}
return;
}