00001 #include "GameObject.h" 00002 00003 GameObject::GameObject(float xpos,float ypos,float width,float height,Color * color) 00004 { 00005 objectTexture=6; 00006 GameObject::xpos=xpos; 00007 GameObject::ypos=ypos; 00008 GameObject::width=width; 00009 GameObject::height=height; 00010 GameObject::color=color; 00011 collGeomList = new std::vector<CollideGeometry *>(); 00012 } 00013 GameObject::~GameObject() 00014 { 00015 collGeomList->clear(); 00016 delete collGeomList; 00017 } 00018 GLuint GameObject::getTexture() 00019 { 00020 return objectTexture; 00021 } 00022 void GameObject::setTexture(GLuint obTexture) 00023 { 00024 objectTexture=obTexture; 00025 } 00026 00027 float GameObject::getXpos() 00028 { 00029 return xpos; 00030 } 00031 00032 float GameObject::getYpos() 00033 { 00034 return ypos; 00035 } 00036 00037 float GameObject::getWidth() 00038 { 00039 return width; 00040 } 00041 float GameObject::getHeight() 00042 { 00043 return height; 00044 } 00045 Color * GameObject::getColor() 00046 { 00047 return color; 00048 } 00049 void GameObject::setXpos(float xpos) 00050 { 00051 GameObject::xpos=xpos; 00052 } 00053 void GameObject::setYpos(float ypos) 00054 { 00055 GameObject::ypos=ypos; 00056 } 00057 void GameObject::setWidth(float width) 00058 { 00059 GameObject::width=width; 00060 } 00061 void GameObject::setHeight(float height) 00062 { 00063 GameObject::height=height; 00064 } 00065 00066 bool GameObject::isCollidingWith(GameObject* object) 00067 { 00068 return false; 00069 } 00070 void GameObject::addCollideGeomenty(CollideGeometry * collgeom) 00071 { 00072 collGeomList->push_back(collgeom); 00073 } 00074 std::vector<CollideGeometry *>* GameObject::getCollideGeomenties() 00075 { 00076 return collGeomList; 00077 } 00078 void GameObject::setCollideGeometryVelosity(vec3 * velos) 00079 { 00080 for(unsigned int i=0;i<collGeomList->size() ;i++) 00081 { 00082 collGeomList->at(i)->setVelosity(velos); 00083 } 00084 } 00085 void GameObject::drawObject(float x, float y, float w, float h) 00086 { 00087 float newX=x+xpos*w; 00088 float newY=y+ypos*h; 00089 float newWidth= width*w; 00090 float newHight= height*h; 00091 00092 glBindTexture(GL_TEXTURE_2D,objectTexture); 00093 glBegin(GL_QUADS); 00094 glColor4f(color->GetNormalizedRed(),color->GetNormalizedGreen(),color->GetNormalizedBlue(),color->GetNormalizedAlpha()); 00095 glTexCoord2f( 0.0f, 1.0f); glVertex3f( newX, newY, 0.0f); 00096 glTexCoord2f( 0.0f, 0.0f); glVertex3f( newX, newY+newHight, 0.0f); 00097 glTexCoord2f( 1.0f, 0.0f); glVertex3f( newX+newWidth, newY+newHight, 0.0f); 00098 glTexCoord2f( 1.0f, 1.0f); glVertex3f( newX+newWidth, newY, 0.0f); 00099 00100 glEnd(); 00101 }