Game Development Community

C++ Help

by Chris "Had Chris First" · in General Discussion · 04/09/2005 (5:21 pm) · 4 replies

Hey guys I use the Codewarrior 5 learning edition at school, and Im trying to use Dev C++ at home. I have a really cool(to me at least) Space invaders game, and its not working with dev C++. I'd really like it if one of you could tell me how to fix it, and why its not working.

P.S. I know there may be bugs and such that may cause it to not function, but it did at school.

Thanks,
Chris Sharp

#include <iostream.h>
#include <math.h>
#include "CMUgraphics.h"
int loopcount;
int gsx = 0;
int mx, my;
int i;
struct sship
{
 int x, y;
 int mx, my;
 int alive; //1000 = alive, < 1000 && > 0 = dying, <= 0 = dead
};
struct sshot 
{
 int x, y;
 bool alive;
};
sshot shot; //Shots
sship ship; //Ships

image Space("C:\downloads\Uber2.jpg");
image Good("C:\downloads\Goodshiptwo.jpg");
window myWin(700, 400, 5, 5);
int main( )
{
 
 Good.Open("C:\downloads\Goodshiptwo.jpg");
 Space.Open("C:\downloads\Uber2.jpg");
 
 myWin.SetBuffering(true);
 
 myWin.SetPen(WHITE);
 myWin.SetPen(WHITE);
 myWin.DrawRectangle(ship.x-1,50,ship.x+7,85,FILLED);
 
 ship.x = 0;
 ship.y = 50;
 ship.mx = 1;
 ship.alive = 1000;
 
 while(1)
 {
  
  loopcount++;
  if (loopcount == 500000)
  {
   loopcount = 0;
   //color poop = color(int(rand() * 256 / RAND_MAX),  int(rand() * 256 / RAND_MAX),  int(rand() * 256 / RAND_MAX));
   //myWin.SetPen(poop);
   //myWin.SetBrush(poop);
   //myWin.DrawRectangle(700,400,-5,-5,FILLED);
   myWin.SetPen(BLACK);
   myWin.SetBrush(BLACK);
   myWin.DrawRectangle(700,400,-5,-5,FILLED);
   ship.x += ship.mx;
   
   //cout << "msbx = " << mbsx << "\nbsx = " << bsx << endl;
   myWin.DrawImage(Good, gsx, 350, Good.GetWidth(), Good.GetHeight());
   
   if (ship.alive == 1000)
   {
    if (ship.x > 700 - Space.GetWidth())
    {
     ship.x = 700 - Space.GetWidth();
     ship.mx = -1;
    }
    else if (ship.x < 10)
    {
     ship.x = 10;
     ship.mx = 1;
    }
    myWin.DrawImage(Space, ship.x, ship.y, Space.GetWidth(), Space.GetHeight());
   }
   else if (ship.alive < 1000 && ship.alive > 0)
   {
    ship.alive--; //Decrease count
   }
   
   myWin.GetMouseCoord(mx, my);
   if(gsx != mx)
   {
    //myWin.SetBrush(poop);
    //myWin.SetPen(poop);
    //myWin.DrawRectangle(gsx-1,350,gsx+61,400,FILLED);
    gsx = mx - (Good.GetWidth() / 2);
    //myWin.DrawImage(Good,gsx,350,60,20);
   }
   
   myWin.SetPen(RED);
   if (shot.alive)
   {
    myWin.DrawLine(shot.x, shot.y, shot.x, shot.y + 25);
    shot.y -= 7; //Move up 10 pixels
    if (shot.y <= 0) shot.alive = false; //Off top so it's dead
   }
   
   if (myWin.GetButtonState(LEFT_BUTTON, mx, my) == BUTTON_DOWN)
   {
    shot.alive = true;
    shot.x = mx;
    shot.y = 700;
   }
   
   if (shot.alive && shot.y < ship.y + 70 && shot.y > 30)
   {
    if (shot.x <= ship.x + Space.GetWidth() && shot.x >= ship.x) //Does it have the right x coords
    {
     shot.alive = false;
     ship.alive--; //Set ship to start dying
     cout << "Bad guy died!!!!!!!!!!!!!!!!!!\n";
    }
   }
   
   //Needs to be last
   myWin.UpdateBuffer();
  }
  
 }
return 0;
}

#1
04/09/2005 (5:41 pm)
Well, showing us the actual errors might be helpful...
#2
04/09/2005 (5:54 pm)
Solution:
Use Torque 2D :)

Ill download that graphics lib and see whats going on too.
#3
04/09/2005 (6:06 pm)
Ahhh t2d is what Ill be buying as soon as I can afford it.

And there are a bunch of errors, and Im not sure how to copy them all, this is my first go at Dev CPP
#4
04/09/2005 (6:29 pm)
Lol i just relized i dont have dev c++, i use VS.net

I never touched this lib before but why are you useing 1.5 and not 2.
It even has a project setup for Dev c++.

But still i tried and i have never had such a hard time trying to get a lib to work.....
There is no way i should be getting all these linker errors trying out their default project.