Example #1
0
void Pipe::SendEnemyToGameEngine()
{
	if (m_enemyBeingSpawned != NULL)
	{
		Goomba *goombaJustSpawned = new Goomba("goomba", m_enemyBeingSpawned->GetPosition(), DLEFT); // Will be deleted by game engine when character dies
		EngineEvent newGoomba(NEW_CHARACTER, goombaJustSpawned);
		m_gameEngine->PushEvent(newGoomba);

		goombaJustSpawned = NULL;
	}
}
Example #2
0
/**Constructor*/
Game::Game(QTimer *t, QString n)
{	
	setFixedSize(500, 500);
	setFocus();
	
	//removes scroll bars
	setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
	setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
	
	//creates a new scene and sets it in a fixed location
	gScene = new QGraphicsScene();
	gScene->setSceneRect(0, 0, 500, 500);
	setScene(gScene);
	
	//creates the Pixmaps of all the "things" for their constructors
	yPix = new QPixmap("img/yoshiw2.png");
	bPix = new QPixmap("img/bg.png");
	hPix = new QPixmap("img/heart.png");
	coinPix = new QPixmap("img/coin.png");
	goombaPix = new QPixmap("img/goombaw1.png");
	koopaPix = new QPixmap("img/koopaw1r.png");
	kamekLPix = new QPixmap("img/kamek1.png");
	kamekRPix = new QPixmap("img/kamek21.png");
	billLPix = new QPixmap("img/lbill.png");
	billRPix = new QPixmap("img/rbill.png");
	magicPix = new QPixmap("img/magic.png");
	boltPix = new QPixmap("img/bolt.png");
	windPix = new QPixmap("img/wind.png");
	
	/*creates "things"*/
	//background
	background = new Bg(bPix, 0, 0, 0, 0);
	
	//adds Yoshi (playable character) to list
	yoshi = new Yoshi(yPix, 225, 405, 1, 1);
	things.push_back(yoshi);
	yoshi->setZValue(3);
	
	//coin on stats panel (lava)
	sCoin = new Coin(coinPix, 170, 460, 0, 0);
	sCoin->setZValue(2);
	
	//heart
	heart = new Heart(hPix, 20, 465, 0, 0);
	heart->setZValue(2);
	
	/*create text*/
	//font size
	font.setPixelSize(30);
	fontT.setPixelSize(14);
	
	//word "Score"
	sLabel = new QGraphicsSimpleTextItem("Score: ");
	sLabel->setPos(300, 450);
	sLabel->setFont(fontT);
	sLabel->setZValue(3);
	nameLabel = new QGraphicsSimpleTextItem("Name: ");
	nameLabel->setPos(300, 465);
	nameLabel->setFont(fontT);
	nameLabel->setZValue(3);
	levelLabel = new QGraphicsSimpleTextItem("Level: ");
	levelLabel->setPos(300, 480);
	levelLabel->setFont(fontT);
	levelLabel->setZValue(3);
	
	//actual score value
	score = 0;
	QString temp = QString::number(score);
	sAmount = new QGraphicsSimpleTextItem(temp);
	sAmount->setPos(400, 450);
	sAmount->setFont(fontT);
	sAmount->setZValue(3);
	
	//lives
	lives = 3;
	temp = QString::number(lives);
	lAmount = new QGraphicsSimpleTextItem(temp);
	lAmount->setPos(70, 460);
	lAmount->setFont(font);
	lAmount->setZValue(3);
	
	//number of coins collected
	nCoins = 0;
	temp = QString::number(nCoins);
	cAmount = new QGraphicsSimpleTextItem(temp);
	cAmount->setPos(210, 460);
	cAmount->setFont(font);
	cAmount->setZValue(2);
	
	//level
	levelCnt = 1;
	temp = QString::number(levelCnt);
	levelAmount = new QGraphicsSimpleTextItem(temp);
	levelAmount->setPos(400, 480);
	levelAmount->setFont(fontT);
	levelAmount->setZValue(2);
	gScene->addItem(levelAmount);
	
	//name
	nLabel = new QGraphicsSimpleTextItem(n);
	nLabel->setPos(400, 465);
	nLabel->setFont(fontT);
	nLabel->setZValue(2);
	
	
	//now barrage the scene with the items!
	gScene->addItem(background);
	gScene->addItem(heart);
	gScene->addItem(sCoin);
	gScene->addItem(sLabel);
	gScene->addItem(nLabel);
	gScene->addItem(sAmount);
	gScene->addItem(lAmount);
	gScene->addItem(cAmount);
	gScene->addItem(nameLabel);
	gScene->addItem(levelLabel);
	for(int k=1; k<things.size(); k++)
		gScene->addItem(things[k]);
	
	gScene->addItem(yoshi);
	
	//timers
	timer = t;
	
	//counters
	goombaCnt = 0;
	koopaCnt = 0;
	kamekCnt = 0;
	billCnt = 0;
	coinCnt = 0;
	heartCnt = 0;
	goombaMax = 150;
	koopaMax = 200;
	kamekMax = 300;
	billMax = 400;
	coinMax = 200;
	heartMax = 450;
	yoshiJCnt = 0;
	spawnCnt = 100;
	timeCnt = 0;
	interval = timer->interval();
	velx = 1;
	vely = 1;
	boolMagic = false;
	overG = false;
	
	//connect to slot functions
	connect(timer, SIGNAL(timeout()), this, SLOT(animate()));
	connect(timer, SIGNAL(timeout()), this, SLOT(newCoin()));
	connect(timer, SIGNAL(timeout()), this, SLOT(newGoomba()));
	connect(timer, SIGNAL(timeout()), this, SLOT(newKoopa()));
	connect(timer, SIGNAL(timeout()), this, SLOT(newKamek()));
	connect(timer, SIGNAL(timeout()), this, SLOT(newBill()));
	connect(timer, SIGNAL(timeout()), this, SLOT(newHeart()));
	connect(timer, SIGNAL(timeout()), this, SLOT(offScreen()));
}