Ejemplo n.º 1
0
void Collectible::init()
{
	setDrawOffset(16, 16);
	setFrameSize(32, 32);

	Animation * tmp;
	tmp = addAnimation("image");
	tmp->addFrame(0, .1f);
	setCurrentAnimation("image");
	shape->collision_type = PhysicsType::Item;
	setShapeLayers(PhysicsLayer::Player);
}
Ejemplo n.º 2
0
BossSpider::BossSpider(float x, float y)
:Enemy(x, y, 56.0f, 41.0f)
{
	setImage("spider.png");
	walk_speed = 100.0f;

	dying = false;
	life = 5;

	setDrawOffset(32, 63);
	setFrameSize(64, 64);
	lastShot = 0;
	shootInterval = 0.5f;
	time = 0;

	patrolInterval = 1.5f;
	patrolTime = 0;

	Animation * tmp;

	//pick a random death sound
	int sound_num = rand() % 19;
	sound_num += 1;
	std::string s;
	std::stringstream out;
	out << sound_num;
	s = out.str();

	std::string sound_file = s + "-BugSplat.ogg";
	//cout << sound_file;
	fireSound = soundCache[sound_file];
	shape->u = 0.1f;

	tmp = addAnimation("walk");
	tmp->addFrame(0, .2f);
	tmp->addFrame(1, .2f);
	tmp->addFrame(2, .2f);
	tmp->addFrame(4, .2f);
	tmp->addFrame(5, .2f);
	tmp->setDoLoop(true);

	tmp = addAnimation("die");
	tmp->addFrame(8, .2f);
	tmp->addFrame(9, .2f);
	tmp->addFrame(10, .2f);
	tmp->addFrame(11, .2f);

	tmp = addAnimation("hurt");
	tmp->addFrame(0, 0.07f);

	setCurrentAnimation("walk");
}
Ejemplo n.º 3
0
EnemyCrawler::EnemyCrawler(float x, float y)
:EnemyPatroller(x, y, 40.0f, 16.0f)
{
	setImage("crawler.png");
	walk_speed = 70.f;
	shape->u = 0.1f;

	dying = false;
	life = 2;

	setDrawOffset(33, 26);
	setFrameSize(64, 32);

	Animation * tmp;
	actorName = "Crawler";
	
	//pick a random death sound
	int sound_num = rand() % 19;
	sound_num += 1;
	std::string s;
	std::stringstream out;
	out << sound_num;
	s = out.str();

	std::string sound_file = s + "-BugSplat.ogg";
	//cout << sound_file;
	fireSound = soundCache[sound_file];
	facing_direction = Facing::Left;

	tmp = addAnimation("walk");
	tmp->addFrame(2, .2f);
	tmp->addFrame(3, .2f);
	tmp->setDoLoop(true);

	tmp = addAnimation("die");
	tmp->addFrame(8, .07f);
	tmp->addFrame(7, .07f);
	tmp->addFrame(6, .07f);
	tmp->addFrame(5, .07f);

	tmp = addAnimation("hurt");
	tmp->addFrame(4, 0.07f);

	setCurrentAnimation("walk");
}
Ejemplo n.º 4
0
CollectibleEnergyBall::CollectibleEnergyBall(double x, double y, int expValue)
: Collectible(x, y, 32.0f, 32.0f) {
	actorName = "EnergyBall";
	this->setImage("energyball.png");
	setDrawOffset(16, 16);
	setFrameSize(32, 32);
	experienceValue = expValue;

	Animation * tmp;
	tmp = addAnimation("anim");
	tmp->addFrame(0, .2f);
	tmp->addFrame(1, .2f);
	tmp->addFrame(2, .2f);
	tmp->addFrame(3, .2f);
	tmp->setDoLoop(true);
	setCurrentAnimation("anim");
	shape->collision_type = PhysicsType::Item;
	setShapeLayers(PhysicsLayer::Player);
}
Ejemplo n.º 5
0
PlayerBullet::PlayerBullet(float x, float y, int facing, float angleVariation, float lifetime):
AnimatedActor(x, y, 15.0f, 7.0f)
{
	this->setImage("xeon-bullet.png");
	this->lifetime = lifetime;
	bulletTime = 0;

	facing_direction = facing;

	float speed = 500.f;

	float angle = ((facing_direction == Facing::Right) ? 90 : -90) + (rand() % 200 - 100) * angleVariation/100;
	float speed_x = (int)(0.5f + sin(angle * 3.14159/180.0) * speed);
	float speed_y = (int)(0.5f + cos(angle * 3.14159/180.0) * speed);
	
	body->v.x = speed_x;
	body->v.y = speed_y;
	body->a = deg2rad(angle - 90);
	
	setVelocityFunc(no_gravity);
	
	// Put it in the PLayerBullets group so it doesn't collide with other PlayerBullets
	shape->group = PhysicsGroup::PlayerBullets;
	shape->layers = PhysicsLayer::Map|PhysicsLayer::PlayerBullet;
	shape->collision_type = PhysicsType::PlayerBullet;
	
	setDrawOffset(8, 13);
	setFrameSize(16, 16);
	damage = 1;

	Animation * tmp;

	tmp = addAnimation("bullet");
	tmp->addFrame(0, .1f);
	tmp->addFrame(1, .1f);
	tmp->addFrame(2, .1f);
	tmp->addFrame(3, .1f);
	tmp->addFrame(4, .1f);
	tmp->setDoLoop(true);

	setCurrentAnimation("bullet");
}