SmallBuilding::SmallBuilding(df::Position p) {
    df::ResourceManager &resource_manager = df::ResourceManager::getInstance();
    df::LogManager &log_manager = df::LogManager::getInstance();

    // Link to "smallbuilding" sprite
    df::Sprite *p_temp_sprite;
    p_temp_sprite = resource_manager.getSprite("smallbuilding");
    if (!p_temp_sprite) {
        log_manager.writeLog("SmallBuilding::SmallBuilding(): Warning! Sprite '%s' not found", "smallbuilding");
    }
    else {
        setSprite(p_temp_sprite);
    }

    setType("SmallBuilding");

    setSolidness(df::Solidness::SOFT);

    //Set starting position
    setPosition(p);

    health = 10;
    hit_slowdown = 5;
    hit_countdown = hit_slowdown;
    was_hit = false;
    has_flashed = false;
}
Exemplo n.º 2
0
_border::_border()
{
	// Get instances of necessary managers.
	LogManager &log_manager = LogManager::getInstance();
	ResourceManager &resource_manager = ResourceManager::getInstance();
	WorldManager &world_manager = WorldManager::getInstance();

	// Set up border sprite.
	Sprite *p_temp_sprite = resource_manager.getSprite("border");
	if (!p_temp_sprite) 
	{
		log_manager.writeLog("_border::_border(): Warning! Sprite '%s' not found", "border");
	} 
	else
	{
		// If sprite is found, set sprite for this object.
		setSprite(p_temp_sprite);
	}

	// Set type of border.
	setType("_border");

	// Make sure it collides with others so game objects don't pass through message box.
	setSolidness(HARD);
	setAltitude(2);

	// Set position to middle center of the terminal.
	Position pos(world_manager.getBoundary().getCorner().getX() + world_manager.getBoundary().getHorizontal()/2,
              ( world_manager.getBoundary().getCorner().getY() + world_manager.getBoundary().getVertical()/2) + 6);
  	setPosition(pos);
};
MediumRock::MediumRock(df::Position p) {
	df::ResourceManager &resource_manager = df::ResourceManager::getInstance();
	df::LogManager &log_manager = df::LogManager::getInstance();

	// Link to "mediumrock" sprite
	df::Sprite *p_temp_sprite;
	p_temp_sprite = resource_manager.getSprite("mediumrock");
	if (!p_temp_sprite) {
		log_manager.writeLog("MediumRock::MediumRock(): Warning! Sprite '%s' not found", "mediumrock");
	}
	else {
		setSprite(p_temp_sprite);
		setSpriteSlowdown(0);
	}

	setType("MediumRock");

	setSolidness(df::Solidness::SOFT);

	//Set starting position
	setPosition(p);

	health = 15;
	hit_slowdown = 5;
	hit_countdown = hit_slowdown;
	was_hit = false;
	has_flashed = false;
}
NixonPowerCell::NixonPowerCell(df::Position p) {
	df::ResourceManager &resource_manager = df::ResourceManager::getInstance();
	df::LogManager &log_manager = df::LogManager::getInstance();

	// Link to "largerock" sprite
	df::Sprite *p_temp_sprite;
	p_temp_sprite = resource_manager.getSprite("nixonpowercell");
	if (!p_temp_sprite) {
		log_manager.writeLog("NixonPowerCell::NixonPowerCell(): Warning! Sprite '%s' not found", "nixonpowercell");
	}
	else {
		setSprite(p_temp_sprite);
		setSpriteSlowdown(0);
	}

	setType("NixonPowerCell");

	setSolidness(df::Solidness::HARD);

	//Set starting position
	setPosition(p);

	health = 10;
	hit_slowdown = 5;
	hit_countdown = hit_slowdown;
	was_hit = false;
	has_flashed = false;
}
Exemplo n.º 5
0
// overloaded constructor to take in initial velocity and position
Ball::Ball(float xVelocity, float yVelocity, df::Position pos){
	setType("Ball");
	setXVelocity(xVelocity);
	setYVelocity(yVelocity);
	setSolidness(df::HARD);
	setPosition(pos);
}
FootSoldier::FootSoldier(df::Position p, df::Object *new_player) {
	df::ResourceManager &resource_manager = df::ResourceManager::getInstance();
	df::LogManager &log_manager = df::LogManager::getInstance();

	// Link to "player" sprite
	df::Sprite *p_temp_sprite;
	p_temp_sprite = resource_manager.getSprite("footsoldier");
	if (!p_temp_sprite) {
		log_manager.writeLog("FootSoldier::FootSoldier(): Warning! Sprite '%s' not found", "footsoldier");
	}
	else {
		setSprite(p_temp_sprite);
		setSpriteSlowdown(0);
	}

	setType("FootSoldier");

	setSolidness(df::Solidness::SOFT);

	//Register interests
	registerInterest(df::STEP_EVENT);

	//Set starting position
	setPosition(p);

	player = new_player;
	fire_slowdown = 15 + rand() % 5;
	fire_countdown = fire_slowdown;
}
Exemplo n.º 7
0
Explosion::Explosion(df::Position *p){
	setType(Type::EXPLOSION);
	setSolidness(df::SPECTRAL);

	df::LogManager &log_manager = df::LogManager::getInstance();
	df::ResourceManager &resource_manager = df::ResourceManager::getInstance();

	df::Sprite *sprite;
	sprite = resource_manager.getSprite("explosion");
	if(!sprite){
		log_manager.writeLog("Explosion::Explosion() could not load explosion sprite");
	} else {
		time_to_live = sprite->getFrameCount(); //set time as # of frames
		log_manager.writeLog("Explosion::Explosion() frameCount %d", time_to_live);
		setSprite(sprite);
	}

	if(p)
		setPosition(*p);

	registerInterest(df::STEP_EVENT);

	if(Role::isServer()){
		NetSyncing::create(this);
	}

}
Mortar::Mortar(df::Position p, df::Object *new_player) {
	df::ResourceManager &resource_manager = df::ResourceManager::getInstance();
	df::LogManager &log_manager = df::LogManager::getInstance();

	// Link to "mortar" sprite
	df::Sprite *p_temp_sprite;
	p_temp_sprite = resource_manager.getSprite("mortar");
	if (!p_temp_sprite) {
		log_manager.writeLog("Mortar::Mortar(): Warning! Sprite '%s' not found", "mortar");
	}
	else {
		setSprite(p_temp_sprite);
		setSpriteSlowdown(0);
	}

	setType("Mortar");

	setSolidness(df::Solidness::SOFT);

	//Set starting position
	setPosition(p);

	player = new_player;
	fire_slowdown = 60;
	fire_countdown = fire_slowdown;
	firing_anim_slowdown = 5;
	firing_anim_countdown = firing_anim_slowdown;
	occupied = true;
	firing = false;
}
EnemyTank::EnemyTank(df::Position p, df::Object *new_player) {
    df::ResourceManager &resource_manager = df::ResourceManager::getInstance();
    df::LogManager &log_manager = df::LogManager::getInstance();

    // Link to "player" sprite
    df::Sprite *p_temp_sprite;
    p_temp_sprite = resource_manager.getSprite("enemytank");
    if (!p_temp_sprite) {
        log_manager.writeLog("EnemyTank::EnemyTank(): Warning! Sprite '%s' not found", "enemytank");
    }
    else {
        setSprite(p_temp_sprite);
        setSpriteSlowdown(0);
    }

    setType("EnemyTank");

    setSolidness(df::Solidness::SOFT);

    //Set starting position
    setPosition(p);

    player = new_player;
    fire_slowdown = 60;
    fire_countdown = fire_slowdown;
    move_slowdown = 5;
    move_countdown = move_slowdown;
}
Exemplo n.º 10
0
// default constructor
Reticle::Reticle(){
	setType("Reticle");
	setSolidness(df::SPECTRAL);

	// put above the rest of the objects
	setAltitude(4);
}
Exemplo n.º 11
0
Star::Star() {
  setType("Star");
  setSolidness(df::SPECTRAL);
  setVelocity(df::Vector((float) -1.0 /(rand()%9 + 2), 0));
  setAltitude(0);	// Make Stars in the background.
  df::WorldManager &world_manager = df::WorldManager::getInstance();
  df::Vector p((float) (rand()%(int)world_manager.getBoundary().getHorizontal()),
	       (float) (rand()%(int)world_manager.getBoundary().getVertical()));
  setPosition(p);
}
Exemplo n.º 12
0
Star::Star() {
	setType("Star");
	setSolidness(df::SPECTRAL);
	setXVelocity((float)(-1.0 / (rand() % 10 + 1)));
	setAltitude(0);
	df::WorldManager &world_manager = df::WorldManager::getInstance();
	df::Position pos(rand() % world_manager.getBoundary().getHorizontal(),
		rand() % world_manager.getBoundary().getVertical());
	setPosition(pos);
}
Exemplo n.º 13
0
Star::Star() {
  setType("Star");
  setSolidness(SPECTRAL);
  setXVelocity(-1.0 / (random()%10 + 1));
  setAltitude(0);	// Make them in the background.
  WorldManager &world_manager = WorldManager::getInstance();
  Position pos(random()%world_manager.getBoundary().getHorizontal(),
	       random()%world_manager.getBoundary().getVertical());
  setPosition(pos);
}
Exemplo n.º 14
0
Explosion::Explosion() {
  setType("Explosion");

  // Exit after about 6 steps.
  time_to_live =  6; 

  // Doesn't collide
  setSolidness(df::SPECTRAL);

  // Need step event to countdown.
  registerInterest(df::STEP_EVENT);
}
Exemplo n.º 15
0
Ghost::Ghost(Position pos) {
	ghost_velocity = GHOST_VELOCITY;

	WorldManager &world_manager = WorldManager::getInstance();

	setPosition(pos);
	setType("Ghost");
	setSolidness(SOFT); //Ghosts can move through anything
	setAltitude(MAX_ALTITUDE);

	//TODO: This takes too long to find, is there a more efficient way?
	/*
	 ObjectList objects = world_manager.getAllObjects();
	 ObjectListIterator iterator = objects.createIterator();

	 bool found = false;
	 while(!iterator.isDone() && !found){
	 if (iterator.currentObject()->getType() == "Hero"){

	 hero_pos = iterator.currentObject()->getPosition();

	 found = true;
	 }
	 }
	 */

//	if (!found){
	Position h_pos(world_manager.getBoundary().getHorizontal() / 2,
			world_manager.getBoundary().getVertical() / 2);
	hero_pos = h_pos;
//	}

	LogManager &lm = LogManager::getInstance();
	ResourceManager &rm = ResourceManager::getInstance();
	Sprite *p_temp_sprite;

	p_temp_sprite = rm.getSprite("ghost");
	if (!p_temp_sprite) {
		lm.writeLog("Ghost::Ghost(): Warning! Sprite '%s' not found", "ghost");
	} else {
		setSprite(p_temp_sprite);
		setSpriteSlowdown(15);
	}

	max_speed_cooldown = MAX_SPEED_COOLDOWN;
	speed_cooldown = max_speed_cooldown;

	registerInterest(HERO_MOVE_EVENT);
	registerInterest(STEP_EVENT);
	registerInterest(COLLISION_EVENT);
	registerInterest(LEVEL_UP_EVENT);
}
Exemplo n.º 16
0
Input::Input(){
	setVisible(false);
	setSolidness(df::SPECTRAL);

	hero = NULL;

	if((Role::isServer() && DISABLE_SERVER_INPUT) || DISBALE_CLIENT_INPUT){
		return;
	}

 	registerInterest(df::KEYBOARD_EVENT);
	registerInterest(df::MOUSE_EVENT);
}
Exemplo n.º 17
0
Reticle::Reticle() {
  setType("Reticle");
  setSolidness(df::SPECTRAL);
  setAltitude(df::MAX_ALTITUDE); // Make Reticle in the foreground.

  // Reticle moves with mouse, so register.
  registerInterest(df::MOUSE_EVENT);

  // Start reticle in center of window.
  df::Vector p(WM.getBoundary().getHorizontal()/2,
	       WM.getBoundary().getVertical()/2);
  setPosition(p);
}
Exemplo n.º 18
0
Reticle::Reticle() {
  setType("Reticle");
  setSolidness(df::SPECTRAL);
  setAltitude(df::MAX_ALTTITUDE); // Make Reticle in the foreground.

  // Reticle moves with mouse, so register.
  registerInterest(df::_MOUSE_EVENT);

  // Start reticle in center of window.
  df::GraphicsManager &graphics_manager = df::GraphicsManager::getInstance();
  df::Position pos(graphics_manager.getHorizontal() / 2,
	  graphics_manager.getVertical() / 2);
  setPosition(pos);
}
Exemplo n.º 19
0
ViewObject::ViewObject(int on_level){

	//Object attributes
	setSolidness(SPECTRAL);
	setAltitude(MAX_ALTITUDE);
	setType("ViewObject");


	//ViewObject attributes
	setValue(0);
	setBorder(true);
	setLocation(TOP_CENTER);
	setColor(COLOR_DEFAULT);

	//Register interest in view events
	registerInterest(VIEW_EVENT);
}
Exemplo n.º 20
0
Platform::Platform(Stages s){
    // Dragonfly managers needed for this method.
    df::LogManager &log_manager = df::LogManager::getInstance();
    df::ResourceManager &resource_manager = df::ResourceManager::getInstance();
    df::WorldManager &world_manager = df::WorldManager::getInstance();
    
    df::Sprite *p_temp_sprite = NULL;
    // Setup "bullet" sprite.
    switch(s) {
        case ULTIMATE_TERMINAL:
            p_temp_sprite = resource_manager.getSprite("ut-platform");
            break;
        case VORTEX:
            p_temp_sprite = resource_manager.getSprite("vortex-platform");
            break;
        case VACATION:
            p_temp_sprite = resource_manager.getSprite("vacation-platform");
            break;
        default:
            p_temp_sprite = resource_manager.getSprite("ut-platform");
    }
    if (!p_temp_sprite) {
        log_manager.writeLog("Platform::Platform(): Warning! Sprite '%s' not found",
            "platform");
    }
    else {
        setSprite(p_temp_sprite);
    }

    // Set object type.
    setType("Platform");
    setSolidness(df::SOFT);
    this->setAltitude(0);

    this->setTransparency('#');

    setPos(df::Position(20, 10));

    setSpriteSlowdown(10);

    registerInterest(df::JOYSTICK_EVENT);
    registerInterest(df::KEYBOARD_EVENT);
    registerInterest(df::STEP_EVENT);
}
Explosion::Explosion() {
  registerInterest(df::STEP_EVENT);

  // Link to "explosion" sprite.
  df::ResourceManager &resource_manager = df::ResourceManager::getInstance();
  df::Sprite *p_temp_sprite = resource_manager.getSprite("explosion");
  if (!p_temp_sprite) {
    df::LogManager &log_manager = df::LogManager::getInstance();
    log_manager.writeLog("Explosion::Explosion(): Warning! Sprite '%s' not found", 
		"explosion");
    return;
  }
  setSprite(p_temp_sprite);

  setType("Explosion");

  time_to_live =  getSprite()->getFrameCount();
  setSolidness(df::SPECTRAL);
}
Exemplo n.º 22
0
//Reticle constructor
Reticle::Reticle(){
	//needed managers
	df::WorldManager &world_manager = df::WorldManager::getInstance();

	//set type and solidness
	setType("Reticle");
	setSolidness(df::SPECTRAL);

	// Make Reticle in foreground
	setAltitude(df::MAX_ALTITUDE);

	//interested in mouse events
	registerInterest(df::A_MOUSE_EVENT);

	//start in center of screen
	int view_h = world_manager.getView().getHorizontal();
	int view_v = world_manager.getView().getVertical();
	df::Position pos(view_h / 2, view_v / 2);
	setPosition(df::viewToWorld(pos));
}
Exemplo n.º 23
0
Platform::Platform()
{
	setType("Platform");
	isItThick = false;
	size = 50;
	setSolidness(HARD);
	setXVelocity(0.0);
	setYVelocity(0.0);
	setAltitude(3);	// Make them in the background.
	WorldManager &world_manager = WorldManager::getInstance();
	//Position pos(random() % world_manager.getBoundary().getHorizontal(),
	//	random() % world_manager.getBoundary().getVertical());
	Position pos(0, 15);
	setPosition(pos);
	height = 5;
	setBox(Box(Position(), size, height));
	thecolor = rand() % 7;



}
Exemplo n.º 24
0
Explosion::Explosion() {
  LogManager &log_manager = LogManager::getInstance();
  ResourceManager &resource_manager = ResourceManager::getInstance();

  //Setup explosion sprite
  Sprite *p_temp_sprite = resource_manager.getSprite("explosion");
  if (!p_temp_sprite) {
    log_manager.writeLog("Explosion::Explosion(): Warning! Sprite '%s' !found", "explosion");
  }
  setSprite(p_temp_sprite);
  setType("Explosion");
  registerInterest(DF_STEP_EVENT);


  //set live time as long as sprite length
  time_to_live = getSprite()->getFrameCount();

  //set solidness of explosion
  setSolidness(SPECTRAL);

}
Exemplo n.º 25
0
Explosion::Explosion()
{
	setType("Explosion");

	// Exit after about 6 steps.
	time_to_live = 6;

	// Doesn't collide
	setSolidness(SPECTRAL);

	auto& resMgr = ResourceManager::getInstance();

	setSprite(resMgr.getSprite("explosion"));
	setSpriteSlowdown(4);

#ifdef REGISTER
	// Need step event to countdown.
	registerInterest(DF_STEP_EVENT);
#endif

}
Exemplo n.º 26
0
// default constructor
Enemy::Enemy(df::Position pos){
	// Dragonfly managers needed for this method.
	df::LogManager &log_manager = df::LogManager::getInstance();
	df::ResourceManager &resource_manager = df::ResourceManager::getInstance();
	df::WorldManager &world_manager = df::WorldManager::getInstance();

	// Setup "hero" sprite.
	df::Sprite *p_temp_sprite = resource_manager.getSprite("enemy");
	if (!p_temp_sprite) {
		log_manager.writeLog("Enemy::Enemy(): Warning! Sprite '%s' not found",
			"enemy");
	}
	else {
		setSprite(p_temp_sprite);
		setSpriteSlowdown(4);
	}

	// set attributes
	startPos = pos;
	setType("Enemy");
	setPosition(pos);

	// set slowdown
	move_slowdown = 4;
	move_countdown = move_slowdown;

	// set initial hero position
	heroPosition = df::Position(40, 5);
	int counterOfPath = 0;

	// get path to hero
	TreeNode *base = new TreeNode(df::Position(getPosition().getX(), getPosition().getY() + 1));
	pathToHero = TreeNode::pathToPosition(base, heroPosition, &sizeOfPath, 3, false);

	setSolidness(df::HARD);

	// set slowdown
	moveSlowdown = 5;
	updatePathSlowdown = 50;
}
Exemplo n.º 27
0
Platform::Platform(bool thickness, int sizee, int heightt, int x, int y, float x_speed, float y_speed)
{
	setType("Platform");
	isItThick = thickness;
	size = sizee;
	setSolidness(HARD);
	setXVelocity(x_speed);
	move_countdown = 10;
	setYVelocity(y_speed);
	setAltitude(3);	// Make them in the background.
	WorldManager &world_manager = WorldManager::getInstance();
	//Position pos(random() % world_manager.getBoundary().getHorizontal(),
	//	random() % world_manager.getBoundary().getVertical());
	Position pos(x, y);
	setPosition(pos);
	height = heightt;
	setBox(Box(Position(), size, height));
	thecolor = rand() % 7;



}
Exemplo n.º 28
0
Weapon::Weapon(df::Position init_pos, Direction init_direction) {

	df::ResourceManager &rm = df::ResourceManager::getInstance();
	df::LogManager &log_manager = df::LogManager::getInstance();

	exist_countdown = exist_slowdown;

	// Setup "hero" sprite.
	df::Sprite *p_temp_sprite = rm.getSprite("weapon");
	if (!p_temp_sprite) {
		log_manager.writeLog("Weapon::Weapon(): Warning! Sprite '%s' not found",
			"weapon");
	}
	else {
		setSprite(p_temp_sprite);
		setSpriteSlowdown(0);
	}
	setSolidness(df::SOFT);
	setType("Weapon");
	direction = init_direction;
	setWeaponPosition(init_pos, direction);
	setAltitude(4);
}
Exemplo n.º 29
0
Reticle::Reticle(){

	//dragonfly managers needed for this method
	df::WorldManager &world_manager = df::WorldManager::getInstance();

	//set object type
	setType("Reticle");

	//set solidness
	setSolidness(df::SPECTRAL);

	//draw in foreground
	setAltitude(df::MAX_ALTITUDE);

	//register for interest
	registerInterest(df::MOUSE_EVENT);

	//set intial position
	int world_horiz = world_manager.getBoundary().getHorizontal();
	int world_vert = world_manager.getBoundary().getVertical();
	df::Position pos(world_horiz / 2, world_vert / 2);
	setPosition(pos);
}
Exemplo n.º 30
0
// overloaded constructor to set initial position and altitude.
Bus::Bus(df::Position pos, int alt){
	setType("Bus");
	setSolidness(df::SOFT);
	setPosition(pos);
	setAltitude(alt);
}