Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

About this user

Bryan Abrams

« Newer Snippets
Older Snippets »
Showing 1-1 of 1 total  RSS 

Irrlicht 8bit chara problem

GAHHH

#include <iostream>
#include <cstring>
#include <irrlicht.h>

using namespace irr;
using namespace video;
using namespace gui;
using namespace core;
using namespace std;

#pragma comment(lib, "Irrlicht.lib")

//---------START ENEMY CLASS-----------------//
class cEnemy {
	int iHealth, iDamage;
	float fPosX, fPosY;
	char sImage[64];
public:
	void set_Health(int,int);
	void set_Damage(int);
	void startingPos(float,float);
	void sImgMonster(char[64]);

};

void cEnemy::set_Health(int hp,int handi)
{
	iHealth = (hp * handi);
	return;
}

void cEnemy::set_Damage(int dmg)
{
	iDamage = dmg;
	return;
}

void cEnemy::startingPos(float xPos,float yPos)
{
	fPosX = xPos;
	fPosY = yPos;
	return;
}

void cEnemy::sImgMonster(char path[64])
{
	sImage[64] = path[64];
	return;
}
//---------END ENEMY CLASS-----------------//

//---------START PLAYER CLASS-----------------//
class cPlayer {
	int iHealth, iDamage;
	float fPosX, fPosY;
	
public:
	void set_Health(int,int);
	void set_Damage(int);
	void startingPos(float,float);
	void sImg(char[8]);	
	char sImage[8];
	
};

void cPlayer::set_Health(int hp,int handi)
{
	iHealth = (hp * handi);
	return;
}

void cPlayer::set_Damage(int dmg)
{
	iDamage = dmg;
}

void cPlayer::startingPos(float xPos,float yPos)
{
	fPosX = xPos;
	fPosY = yPos;
}

void cPlayer::sImg(char path[8])
{
	sImage[8] = path[8];
}
//---------END PLAYER CLASS-----------------//


int main()
{
	cout << "Welcome to Space Invaders! A clone made by Bryan Abrams!"
		 << "There are only 6 ships, mainly because I'm lazy, so deal"
		 << "with it for now, once you are ready press any key and get"
		 << "ready to play!" << endl;
	system("PAUSE");

	//class variables stuff
	
	cPlayer player1;
	cEnemy ship1, ship2, ship3, ship4, ship5, ship6;

	player1.set_Health(100,1);
	player1.set_Damage(10);
	player1.sImg("shp.bmp");
	player1.startingPos(400,500);
	

	IrrlichtDevice *device = createDevice(EDT_OPENGL,dimension2d<s32>(800, 600));

	if (device == 0)
		return 1;

	device->setWindowCaption(L"Space Invaders!");

	IVideoDriver* driver = device->getVideoDriver();

	IGUIFont* font = device->getGUIEnvironment()->getFont("fonthaettenschweiler.bmp");

	driver->beginScene(true, true, SColor(0,0,0,0));

	ITexture* images = driver->getTexture( player1.sImage );
	driver->makeColorKeyTexture(images, SColor(255,255,255,255));
	driver->draw2DImage(images,core::position2d<s32>(400,500));
	

	while(device->run() && driver)
	{
		if (device->isWindowActive())
		{
			u32 time = device->getTimer()->getTime();

			// draw some text
			if (font)
				font->draw(L"Welcome to Space Invaders!",rect<s32>(0,0,300,50),SColor(255,255,255,255));

			driver->endScene();
		}
	}

	device->drop();
	return 0;
}




« Newer Snippets
Older Snippets »
Showing 1-1 of 1 total  RSS