Hey all
Im having trouble with creating an object using visual studio 2005
c++ and some opengl code. i am making a lunar lander game for college
assignment and this part has confused me.. ive created an object
called lander using header files and classes etc and it is working
fine i am able to move around the screen, rotate, land etc but then
when i try include the platform object the whole program stops
working and im just left with the lander image on the screen.
the following is my code for the platform
first the header file platform.h
#pragma once
#include "opengl.h"
#include "Vector.h"
class Platform
{
Vector topLeftPos,topRightPos,botLeftPos,botRightPos;
//int platColor;
//int platReward;
//Texture texture;
public:
Platform(void);
~Platform(void);
void Draw();
void Init();
Vector getTopLeft();
Vector getBottomRight();
};
then the platform.cpp file
#include "StdAfx.h"
#include "Platform.h"
Platform::Platform (void)
{
topLeftPos = (20.0,100.0);
botRightPos = (200.0,80.0);
topRightPos = (200.0,100.0);
botLeftPos = (20.0, 80.0);
}
Platform::~Platform (void)
{
}
void Platform::Draw(void)
{
glColor3f(1.0f,1.0f,1.0f);
glBegin(GL_QUADS);
glVertex2f(topLeftPos.x,topLeftPos.y);
glVertex2f(topRightPos.x,topRightPos.y);
glVertex2f(botRightPos.x,botRightPos.y);
glVertex2f(botLeftPos.x,botLeftPos.y);
glEnd();
}
void Platform::Init(){
//texture.Load("shuttle.bmp",255,255,255);/// load texture,
set transparent colour.. not in use yet
}
i create the platform along with the lander in the game.h file
using the following
Lander lander;
Platform platform;
which i assumed calls the constructors of the objects
then in game.cpp i refer to them in the game loop
glPushMatrix();
lander.Draw();
glPopMatrix();
platform.Draw();
what am i doing wrong?? any ideas? i can post more code if needed not
sure whats wrong so i dont know exactly what to show
thanks for any help given
g