So I screwed up, and I can't seem to unscrew this. lol.
I was fixing my collision code, and I ended up adding a green bg in the process. However, I have not been able to figure out how it changed from the default blue, to green, without any bg altering code?
Here is a picture of what I'm dealing with; and below is my complete source code. Can someone shed any light on what the heck I did wrong?
#include <DarkGDK.h>
#include <SC_Collision.h>
#include <MikeNet.h>
// Below used to identify what each packet is supposed to be for
#define OP_NEWPLAYER 0 // Tcp
#define OP_LEFTPLAYER 1 // Tcp
#define OP_POSITIONPLAYER 0 // Udp
#define HitObjects 100 // All Objects that the bullet would collide with must be bigger than this
#define BulletObjects 1000 // This is the range from where the code looks for free slots to create new bullets
#define MaxBullets 100 // This is the Max number of bullets to cycle, this effects memory
#define ShootDelay 10 // This is the amount of time between shooting
#define BulletSpeed 50 // This is the speed the bullet travels
#define BulletLife 1000 // The bullet will be killed after this time to prevent it from moving around aimlesly
// declare all variables here
float oldx;
float oldy;
float oldz;
float x;
float y;
float z;
float oax;
float oay;
float oaz;
float angx;
float angy;
float angz;
float fCameraAngleX = 0.0f;
float fCameraAngleY = 0.0f;
float vy = 0;
float gravity = -0.1f;
float slope = 0.5f;
float mouseX;
float mouseY;
int maxconnections;
int ammo = 20;
int character;
int score = 0;
int MaximumClients;
int MaximumOperations;
int collide = 0;
int ReloadTimer; // This is the timer alowing the player to shoot
int CurrentBullet = 200; // This is the bullet cycle
int ground = 1;
int respawnPoint;
int killedPlayer = 0;
char * connectIP;
char * characterInput;
unsigned int characterModel;
unsigned short connectPort = 6789;
long long int RecvPacket = mnCreatePacket();
long long int SendPacket = mnCreatePacket();
void KillBullet ( void ) {
}
void KillPlayer ( void ) {
}
void RunBullets ( void ) {
}
void ShootBullet ( void ) {
}
void NextBullet ( void ) {
}
void Connect ( void ) {
mnSetMemorySize(SendPacket,1024);
int Result = mnStart(1,0);
// get ip
dbPrint("Enter the IP that you would like to connect to: ");
connectIP = dbInput();
// try connecting
int connect = mnConnect(0,connectIP,connectPort,connectIP,connectPort,10,true);
if(connect == 1)
{
dbPrint("Connection was successful!");
MaximumClients = mnGetMaxClients(0);
MaximumOperations = mnGetMaxOperations(0);
}
// If the connection timed out
if(connect == 0)
{
dbPrint("Connection timed out! Check that the server is switched on");
dbWaitKey();
return;
}
// If an error occurred during connection
if(connect == -1)
{
dbPrint("An error occurred while trying to connect");
dbWaitKey();
return;
}
}
void SelectAPlayer ( void ) {
if (mnClientConnected(0,0) == 1) {
dbCLS();
dbPasteImage(4,(dbScreenWidth()/2)-400,(dbScreenHeight()/2)-300);
dbPrint("Select a model:");
dbPrint("1. Soilder");
dbPrint("2. Sargent");
dbPrint("3. Camo");
characterInput = dbInput();
characterModel = atoi(characterInput);
if (characterModel > 3) {
character = 1;
}
else if (characterModel < 1) {
character = 1;
}
else if (characterModel == 1) {
character = 1;
}
else if (characterModel == 2) {
character = 2;
}
else if (characterModel == 3) {
character = 3;
}
}
}
void CreateAPlayer ( void ){
dbMakeObjectBox (101,40,100,40);
respawnPoint = dbRnd(4);
respawnPoint++;
dbMakeCamera(1);
if (respawnPoint == 1){
dbPositionObject (101, 1100, 100, 0);
dbPositionCamera (1,1100,100,0);
}
else if (respawnPoint == 2){
dbPositionObject (101, 900, 100, 1150);
dbPositionCamera (1,900,100,1150);
}
else if (respawnPoint == 3){
dbPositionObject (101, -900, 100, 1150);
dbPositionCamera (1,-900,100,1150);
}
else if (respawnPoint == 4){
dbPositionObject (101, -1100, 100, 0);
dbPositionCamera (1,-1100,100,0);
}
else if (respawnPoint == 5){
dbPositionObject (101, 0, 222, 0);
dbPositionCamera (1,0,222,0);
}
dbHideObject(101);
SC_SetupObject (101, 0, 1);
}
void CreateMap ( void ) {
dbCLS();
dbLoadObject("maps/1/map.dbo",100);
dbSetObjectLight(100,0);
SC_SetupComplexObject (100,1,2);
}
void LoadImages ( void ) {
dbLoadImage("images/crosshair.png",1);
dbLoadImage("images/ammo.png",2);
dbLoadImage("images/reload.png",3);
dbSprite(1,(dbScreenWidth()/2)-24,(dbScreenHeight()/2)-24,1);
dbSprite(2,2,dbScreenHeight()-52,2);
dbSprite(3,(dbScreenWidth()/2)-200,(dbScreenHeight()/2)-150,3);
dbHideSprite(3);
}
void LoadSounds ( void ) {
dbLoadSound("sounds/shoot.wav",1);
dbLoadSound("sounds/reload.wav",2);
dbLoadSound("sounds/click.wav",3);
}
void SetDisplay ( void ) {
int display;
display = dbCheckDisplayMode ( 1280, 1024, 32 );
if (display == 1) {
dbSetDisplayMode(1280,1024,32);
}
else {
display = dbCheckDisplayMode ( 1024, 768, 32 );
if (display == 1) {
dbSetDisplayMode(1024,768,32);
}
else {
display = dbCheckDisplayMode ( 800, 600, 32 );
if (display == 1) {
dbSetDisplayMode(800,600,32);
}
else {
dbCLS();
dbPrint("Your computer can not handle this game. Please get a new graphics card.");
dbWaitKey();
return;
}
}
}
dbSetWindowOff ( );
dbHideMouse ( );
dbLoadImage("images/splash.png",4);
dbPasteImage(4,(dbScreenWidth()/2)-400,(dbScreenHeight()/2)-300);
}
void CheckNetwork ( void ) {
// Check for new TCP messages
int iTcpPackets = mnRecvTCP(0,RecvPacket,NULL);
// If there is a new TCP message
if(iTcpPackets > 0)
{
// Get operation of new message
// and player that it applies to
int Operation = mnGetInt(RecvPacket);
int Player = mnGetInt(RecvPacket);
// If the server is telling us that a new player has joined
// then create a cube for that player
if(Operation == OP_NEWPLAYER)
{
if(dbObjectExist(Player+100) == 0)
{
//dbMakeObjectCube(Player+20,50);
dbLoadObject ( "models/Colonel-X.X", Player+100 );
dbLoopObject ( Player+100, 235, 259);
}
}
// If the server is telling us that a player has left then
// delete the cube of that player
if(Operation == OP_LEFTPLAYER)
{
if(dbObjectExist(Player+100) == 1)
{
dbDeleteObject(Player+100);
}
}
}
// Check for new UDP messages on a per client per operation basis
// Check each client
for(int Player = 1;Player<=MaximumClients;Player++)
{
// Check each operation for current client
for(int Operation = 0;Operation<MaximumOperations;Operation++)
{
// Check for new UDP messages
int UdpPackets = mnRecvUDP(0,RecvPacket,Player,Operation);
if(dbObjectExist(Player+100) == 1)
{
// If there is a new UDP message
if(UdpPackets == 1)
{
// Get the player's position and angle
// and apply them to his/her cube
float PosX = mnGetFloat(RecvPacket);
float PosY = mnGetFloat(RecvPacket);
float PosZ = mnGetFloat(RecvPacket);
float RotX = mnGetFloat(RecvPacket);
float RotY = mnGetFloat(RecvPacket);
float RotZ = mnGetFloat(RecvPacket);
dbPositionObject(Player+100,PosX,PosY,PosZ);
dbRotateObject(Player+100,RotX,RotY,RotZ);
}
}
}
}
// Send our position/angle to the server via UDP
// Formulate packet
mnAddInt(SendPacket,OP_POSITIONPLAYER);
mnAddFloat(SendPacket,dbCameraPositionX(1));
mnAddFloat(SendPacket,dbCameraPositionY(1));
mnAddFloat(SendPacket,dbCameraPositionZ(1));
mnAddFloat(SendPacket,dbCameraAngleX(1));
mnAddFloat(SendPacket,dbCameraAngleY(1));
mnAddFloat(SendPacket,dbCameraAngleZ(1));
// Send packet
mnSendUDP(0,SendPacket,NULL,false,true);
}
void MovePlayer ( void ) {
oldx = dbCameraPositionX(1);
oldy = dbObjectPositionY(101);
oldz = dbCameraPositionZ(1);
int speed = 3;
if (dbShiftKey()){
speed = speed + 3;
}
dbControlCameraUsingArrowKeys ( 1, speed, 0.3f );
fCameraAngleX = dbWrapValue ( fCameraAngleX + dbMouseMoveY ( ) * 0.4f );
fCameraAngleY = dbWrapValue ( fCameraAngleY + dbMouseMoveX ( ) * 0.4f );
vy = vy + gravity;
x = dbCameraPositionX(1);
z = dbCameraPositionZ(1);
int collide = SC_SphereCastGroup( 1, oldx,oldy,oldz, oldx,oldy+vy,oldz, 30, 0 );
if ( collide > 0 )
{
vy=0;
}
else
{
oldy = oldy + vy;
ground = 0;
}
collide = SC_SphereSlideGroup( 1, oldx,oldy,oldz, x,oldy,z, 30, 0 );
if ( collide > 0 )
{
x = SC_GetCollisionSlideX();
oldy = SC_GetCollisionSlideY();
z = SC_GetCollisionSlideZ();
}
dbPositionObject( 101, x, oldy, z );
dbPositionCamera( 1, x, oldy, z );
dbXRotateCamera ( 1, fCameraAngleX );
dbYRotateCamera ( 1, fCameraAngleY );
SC_UpdateObject( 101 );
}
void AmmoInfo ( void ) {
dbSetTextFont("Arial");
dbSetTextSize(20);
dbText(50,dbScreenHeight()-25,dbStr(ammo));
}
void Respawn ( void ) {
respawnPoint = dbRnd(5);
if (respawnPoint == 1){
}
else if (respawnPoint == 2){
}
else if (respawnPoint == 3){
}
else if (respawnPoint == 4){
}
else if (respawnPoint == 5){
}
}
void DisplayLocation ( void ) {
dbText(dbScreenWidth()/2,0,dbStr(dbCameraPositionX(1)));
dbText(dbScreenWidth()/2,20,dbStr(dbCameraPositionY(1)));
dbText(dbScreenWidth()/2,40,dbStr(dbCameraPositionZ(1)));
}
void Score ( void ){
dbText(0,20,"Score:");
dbText(80,20,dbStr(score));
}
void DisplayFPS ( void ) {
dbText(0,0,dbStr(dbScreenFPS()));
}
void DarkGDK ( void )
{
SetDisplay();
Connect();
SC_Start();
SelectAPlayer();
CreateAPlayer();
CreateMap();
LoadImages();
LoadSounds();
dbSyncOn ( );
dbSyncRate ( 0 );
dbAutoCamOff( );
// our main loop
while( (mnClientConnected(0,0) == 1) && (LoopGDK() == true) )
{
MovePlayer();
AmmoInfo();
RunBullets();
DisplayLocation();
DisplayFPS();
Score();
dbText(0,50,"Your ID:");
dbText(65,50,dbStr(mnGetClientID(0)));
int mouseClick = dbMouseClick();
int mousePressed;
if (mouseClick == 1) {
mousePressed = mousePressed + 1;
if (mousePressed == 1){
if (ammo > 0){
ammo = ammo - 1;
ShootBullet();
NextBullet();
dbPlaySound(1);
if (ammo == 0){
dbShowSprite(3);
}
}
else if (ammo == 0){
dbPlaySound(3);
}
}
}
if (mouseClick == 2) {
ammo = 20;
dbPlaySound(2);
dbHideSprite(3);
}
if (mouseClick == 0) {
mousePressed = 0;
}
CheckNetwork();
// update the screen
dbSync ( );
}
// If we have become disconnected from the server
dbPrint("Lost connection to server!");
dbSync();
dbWaitKey();
// Close all ports and deallocate all memory
mnFinish(-1);
mnDeletePacket(RecvPacket);
mnDeletePacket(SendPacket);
// Delete images
dbDeleteImage(1);
dbDeleteImage(2);
dbDeleteImage(3);
dbDeleteImage(4);
// return back to windows
return;
}
[ freelance DarkGDK coder ]