1 2 #include <iostream> 3 #include <cstring> 4 #include <irrlicht.h> 5 6 using namespace irr; 7 using namespace video; 8 using namespace gui; 9 using namespace core; 10 using namespace std; 11 12 #pragma comment(lib, "Irrlicht.lib") 13 14 //---------START ENEMY CLASS-----------------// 15 class cEnemy { 16 int iHealth, iDamage; 17 float fPosX, fPosY; 18 char sImage[64]; 19 public: 20 void set_Health(int,int); 21 void set_Damage(int); 22 void startingPos(float,float); 23 void sImgMonster(char[64]); 24 25 }; 26 27 void cEnemy::set_Health(int hp,int handi) 28 { 29 iHealth = (hp * handi); 30 return; 31 } 32 33 void cEnemy::set_Damage(int dmg) 34 { 35 iDamage = dmg; 36 return; 37 } 38 39 void cEnemy::startingPos(float xPos,float yPos) 40 { 41 fPosX = xPos; 42 fPosY = yPos; 43 return; 44 } 45 46 void cEnemy::sImgMonster(char path[64]) 47 { 48 sImage[64] = path[64]; 49 return; 50 } 51 //---------END ENEMY CLASS-----------------// 52 53 //---------START PLAYER CLASS-----------------// 54 class cPlayer { 55 int iHealth, iDamage; 56 float fPosX, fPosY; 57 58 public: 59 void set_Health(int,int); 60 void set_Damage(int); 61 void startingPos(float,float); 62 void sImg(char[8]); 63 char sImage[8]; 64 65 }; 66 67 void cPlayer::set_Health(int hp,int handi) 68 { 69 iHealth = (hp * handi); 70 return; 71 } 72 73 void cPlayer::set_Damage(int dmg) 74 { 75 iDamage = dmg; 76 } 77 78 void cPlayer::startingPos(float xPos,float yPos) 79 { 80 fPosX = xPos; 81 fPosY = yPos; 82 } 83 84 void cPlayer::sImg(char path[8]) 85 { 86 sImage[8] = path[8]; 87 } 88 //---------END PLAYER CLASS-----------------// 89 90 91 int main() 92 { 93 cout << "Welcome to Space Invaders! A clone made by Bryan Abrams!" 94 << "There are only 6 ships, mainly because I'm lazy, so deal" 95 << "with it for now, once you are ready press any key and get" 96 << "ready to play!" << endl; 97 system("PAUSE"); 98 99 //class variables stuff 100 101 cPlayer player1; 102 cEnemy ship1, ship2, ship3, ship4, ship5, ship6; 103 104 player1.set_Health(100,1); 105 player1.set_Damage(10); 106 player1.sImg("shp.bmp"); 107 player1.startingPos(400,500); 108 109 110 IrrlichtDevice *device = createDevice(EDT_OPENGL,dimension2d<s32>(800, 600)); 111 112 if (device == 0) 113 return 1; 114 115 device->setWindowCaption(L"Space Invaders!"); 116 117 IVideoDriver* driver = device->getVideoDriver(); 118 119 IGUIFont* font = device->getGUIEnvironment()->getFont("fonthaettenschweiler.bmp"); 120 121 driver->beginScene(true, true, SColor(0,0,0,0)); 122 123 ITexture* images = driver->getTexture( player1.sImage ); 124 driver->makeColorKeyTexture(images, SColor(255,255,255,255)); 125 driver->draw2DImage(images,core::position2d<s32>(400,500)); 126 127 128 while(device->run() && driver) 129 { 130 if (device->isWindowActive()) 131 { 132 u32 time = device->getTimer()->getTime(); 133 134 // draw some text 135 if (font) 136 font->draw(L"Welcome to Space Invaders!",rect<s32>(0,0,300,50),SColor(255,255,255,255)); 137 138 driver->endScene(); 139 } 140 } 141 142 device->drop(); 143 return 0; 144 } 145 146 147 148
You need to create an account or log in to post comments to this site.