- Main Page
- Classes
- Files

- File List
- File Members

# C:/Documents and Settings/Adam Schwartz/My Documents/um/code/building.h

Go to the documentation of this file.

    00001
    00002
    00003
    00004 #pragma once
    00005 #include <string>
    00006 using namespace std;
    00007 #ifndef BUILDING_H
    00008 #define BUILDING_H
    00009
    00012 class building{
    00013
    00014         int id;
    00015         int life;
    00016         char * model;
    00017         int texture;
    00018         int size;
    00019         int xPos;
    00020         int zPos;
    00021
    00022 public:
    00023         building();
    00024         building(int i, int l, char * m,int t, int s,  int x, int z);
    00025         void destroyBuilding();
    00026         void decreaseLife(int l);
    00027         void newBuilding();
    00028
    00029 };
    00030 #endif
    00031
    00032
    00033 #include "DarkGDK.h"
    00034 #include <string>
    00035 //#include <cstring>
    00036 //#include <cctype>
    00037 using namespace std;
    00038
    00039 //Default const.
    00040
    00041 building::building()
    00042 {
    00046         id = 0;
    00047         life = 0;
    00048         model = NULL;
    00049         texture = 0;
    00050         size = 0;
    00051         xPos = 0;
    00052         zPos = 0;
    00053
    00054
    00055
    00056 }
    00057 //Constructor. Is passed values for building's id, life,  model, texture id, size, and x and z coordinates
    00058 building::building(int i, int l, char * m, int t, int s,  int x, int z)
    00059 {
    00065         id = i;
    00066         life = l;
    00067         model = m;
    00068         texture = t;
    00069         size = s;
    00070         xPos = x;
    00071         zPos = z;
    00072         newBuilding();
    00073
    00074
    00075 }
    00076 //Creates the building.
    00077 void building::newBuilding(){
    00082         //int temp=model.size();
    00083         //char model
    00084         //calls a method to get model's filename. Has not been written yet. Using a dummy variable for now.
    00085
    00087 //  strcpy (temp, model.c_str());
    00088
    00089   //if (temp != NULL){
    00090         dbLoadObject( model ,id );
    00091         dbPositionObject(id, xPos, 0,zPos);
    00092         dbScaleObject(id, size, size, size);
    00093         //dbColorObject ( id, dbRgb ( dbRnd ( 255 ), dbRnd ( 255 ), dbRnd ( 255 ) ) );
    00094                 dbTextureObject(id, texture);
    00095   //}
    00096
    00097 }
    00098
    00099 //destroy the building
    00100 void building::destroyBuilding(){
    00104         dbDeleteObject(id);
    00105 }
    00106
    00107 //decrease their life
    00108 void building::decreaseLife(int l){
    00113         life = life - l;
    00114         if(life <= 0){
    00115                 destroyBuilding();
    00116         }
    00117
    00118 }