コード例 #1
0
ファイル: GameStart.cpp プロジェクト: jbmorse/Dragonfly
void GameStart::showInstructions(bool show) {

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

	showInstruct = show;

	if(!showInstruct) {  // Hiding instructions

		//Setup GameStart sprite
		Sprite *p_temp_sprite = resource_manager.getSprite("gamestart");
		if (!p_temp_sprite) {
			log_manager.writeLog("GameStart::showInstructions(): Warning! Sprite 'gamestart' not found", "gamestart");
		}
		else {
			log_manager.writeLog("GameStart::showInstructions(): Switching to start screen\n");
			setSprite(p_temp_sprite);
			setSpriteSlowdown(15);
		}
	} else {  // Showing instructions

		//Setup GameStart sprite
		Sprite *p_temp_sprite = resource_manager.getSprite("instructions");
		if (!p_temp_sprite) {
			log_manager.writeLog("GameStart::showInstructions(): Warning! Sprite 'gamestart' not found", "instructions");
		}
		else {
			log_manager.writeLog("GameStart::showInstructions(): Switching to instructions screen\n");
			log_manager.writeLog("Frame: %s\n", p_temp_sprite->getFrame(0).getString().c_str());
			setSprite(p_temp_sprite);
			setSpriteSlowdown(0);
		}
	}
}
コード例 #2
0
void SsScene3010DeadBoltButton::update() {

	if (_countdown1 != 0 && (--_countdown1 == 0)) {
		playSound(0);
		setVisible(false);
		setSprite(kScene3010DeadBoltButtonFileHashes1[_buttonIndex]);
	}

	if (_countdown2 != 0 && (--_countdown2 == 0)) {
		setVisible(true);
		setSprite(kScene3010DeadBoltButtonFileHashes2[_buttonIndex]);
	}

}
コード例 #3
0
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;
}
コード例 #4
0
ファイル: GameStart.cpp プロジェクト: jbmorse/Dragonfly
GameStart::GameStart() {

	//Dragonfly managers needed for this method
	LogManager &log_manager = LogManager::getInstance();
	ResourceManager &resource_manager = ResourceManager::getInstance();

	//Setup GameStart sprite
	Sprite *p_temp_sprite = resource_manager.getSprite("gamestart");
	if (!p_temp_sprite) {
		log_manager.writeLog("GameStart::GameStart(): Warning! Sprite 'gamestart' not found", "gamestart");
	}
	else {
		setSprite(p_temp_sprite);
		setSpriteSlowdown(15);
	}

	setType("GameStart");

	showInstruct = false;

	//Put in center of screen
	WorldManager &world_manager = WorldManager::getInstance();
	Position pos(world_manager.getBoundary().getCorner().getX() +
			world_manager.getBoundary().getHorizontal()/2,
			world_manager.getBoundary().getCorner().getY() +
			world_manager.getBoundary().getVertical()/2);
	setPosition(pos);

	//Register for "keyboard" event
	registerInterest(KEYBOARD_EVENT);

	log_manager.writeLog("GameStart::GameStart(): Made gamestart!\n");
	LevelHandler &levelhandler = LevelHandler::getInstance();

}
コード例 #5
0
ファイル: fixedsprite.cpp プロジェクト: Bobombe/LudumDare30
FixedSprite::FixedSprite(const sf::Vector2f& pos, const std::string& imagePath, bool addToFixedObjectList) : FixedObject(addToFixedObjectList)
{
    //ctor
    if (imagePath != "")
        setSprite(imagePath);
    setPosition(pos);
}
コード例 #6
0
ファイル: Saucer.cpp プロジェクト: Rdbaker/wings
Saucer::Saucer() {
  df::LogManager &log_manager = df::LogManager::getInstance();
  df::ResourceManager &resource_manager = df::ResourceManager::getInstance();
  df::WorldManager &world_manager = df::WorldManager::getInstance();

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

  // Set object type.
  setType("Saucer");

  // Set speed in horizontal direction.
  setXVelocity(-0.25); // 1 space left every 4 frames

  // Move Saucer to start location.
  moveToStart();
  // Register interest in "nuke" event.
  registerInterest(NUKE_EVENT);
  Role &role = Role::getInstance();
  if(role.isHost()) {
    Role &role = Role::getInstance();
    role.registerSyncObj(this);
  }
}
コード例 #7
0
ファイル: block.cpp プロジェクト: akrokan/Core
Entity Block::getBlock()
{
    // set position
    auto pos = new CPosition;
    pos->setX(32);
    pos->setY(32);
    E.addComponent(std::type_index(typeid(CPosition)), pos);

    // set sprite from a spritesheet
    auto spr = new CSprite;
    spr->setSize(32);
    spr->setSprite(this->getSprite(0, 0)); // coordinates in spritesheet
    E.addComponent(std::type_index(typeid(CSprite)), spr);

    // set state (0 = moveable)
    auto sta = new CState;
    sta->setS(0);
    E.addComponent(std::type_index(typeid(CState)), sta);

    // set velocity
    auto vel = new CVelocity;
    vel->setVelX(32);
    vel->setVelY(32);
    E.addComponent(std::type_index(typeid(CVelocity)), vel);

    return E;
}
コード例 #8
0
ファイル: being.cpp プロジェクト: Ablu/mana
void Being::setSubtype(Uint16 subtype)
{
    if (subtype == mSubType)
        return;

    mSubType = subtype;

    if (getType() == MONSTER)
    {
        mInfo = MonsterDB::get(mSubType);
        setName(mInfo->getName());
        setupSpriteDisplay(mInfo->getDisplay());
    }
    else if (getType() == NPC)
    {
        mInfo = NPCDB::get(mSubType);
        setupSpriteDisplay(mInfo->getDisplay(), false);
    }
    else if (getType() == PLAYER)
    {
        int id = -100 - subtype;

        // Prevent showing errors when sprite doesn't exist
        if (!itemDb->exists(id))
            id = -100;

        setSprite(Net::getCharHandler()->baseSprite(), id);
    }
}
コード例 #9
0
ファイル: Poder.cpp プロジェクト: rubenmv/herus-elementa
Poder::Poder(const int t) {
	tipo = t;
	setSprite(RUTA_OBJETOS_GFX);
	size.x = size.y = 32;
	active = -1;
	clock.restart();
}
コード例 #10
0
GameStart::GameStart(){
	setType("GameStart");

	//dragonfly managers needed for this
	df::ResourceManager &resource_manager = df::ResourceManager::getInstance();

	//setup GameOversprite
	df::Sprite *p_temp_sprite = resource_manager.getSprite("gamestart");

	if (!p_temp_sprite){
		df::LogManager &log_manager = df::LogManager::getInstance();
		log_manager.writeLog("GameStart::GameStart(): Warning! Sprite '%s' not found", "gamestart");
	}
	else{
		setSprite(p_temp_sprite);
		setSpriteSlowdown(30);
		setTransparency('#');
	}

	//put in center of window
	setLocation(df::CENTER_CENTER);

	//register interest
	registerInterest(df::KEYBOARD_EVENT);

	//play start music
	p_music = df::ResourceManager::getInstance().getMusic("start music");
	playMusic();
	df::WorldManager &world_manager = df::WorldManager::getInstance();
	world_manager.setBoundary(df::Box(df::Position(), 250, 250));
}
コード例 #11
0
ファイル: StaticObject.cpp プロジェクト: JustPowell/SFML_Game
StaticObject::StaticObject(int objType, sf::Vector2i position)
{
	setType(objType);
	setPosition(position);
	setSprite();
	setBounds();
}
コード例 #12
0
ファイル: Trap.cpp プロジェクト: piaoasd123/IMGD3000PROJ2
Trap::Trap(int x, int y)
{

	LogManager &log_manager = LogManager::getInstance();

#ifdef REGISTER


	// Need to update fire rate control each step.
	registerInterest(DF_STEP_EVENT);
#endif

	// Set object type.
	setType("Trap");
	auto& resMgr = ResourceManager::getInstance();
	setSprite(resMgr.getSprite("trap"));
	setSpriteSlowdown(4);
	setAltitude(1);
	// Set starting location.
	WorldManager &world_manager = WorldManager::getInstance();
	Position pos(7, world_manager.getBoundary().getVertical() / 2);
	setPosition(Position(x, y));
	setBox(Box(Position(0, 0), getSprite()->getWidth(), getSprite()->getHeight()));
	//setYVelocity(0.25);
	// Set firing variables.
}
コード例 #13
0
ファイル: _border.cpp プロジェクト: MaxwellP/IMGD3000
_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);
};
コード例 #14
0
ファイル: Explosion.cpp プロジェクト: chickenbellyfinn/CS4513
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);
	}

}
コード例 #15
0
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;
}
コード例 #16
0
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;
}
コード例 #17
0
ファイル: Rejilla.cpp プロジェクト: rubenmv/herus-elementa
Rejilla::Rejilla() {
	// Carga el sprite con la textura
	setSprite(RUTA_OBJETOS_GFX);
	setSize(32, 32);
	setCentro(this->getSize().x/2, this->getSize().y/2);
	setFrame(2, 2, 1, 1);
}
コード例 #18
0
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;
}
コード例 #19
0
ファイル: Saucer.cpp プロジェクト: g4vin/Dragonfly-Wings
Saucer::Saucer()
{
    // 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 "saucer" sprite.
    df::Sprite *p_temp_sprite = resource_manager.getSprite("saucer");
    if (!p_temp_sprite) {
        log_manager.writeLog("Saucer::Saucer(): Warning! Sprite '%s' not found", "saucer");
    } else {
        setSprite(p_temp_sprite);
        setSpriteSlowdown(4);		
    }

    // Set object type.
    setType("Saucer");

    // Set speed in horizontal direction.
    setXVelocity(-0.25); // 1 space left every 4 frames

    /*
    // Set starting location in the middle of window.
    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);*/

    moveToStart();
}
コード例 #20
0
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;
}
コード例 #21
0
bool CSpriteObject::init(CCDictionary* pObjectDict)
{
    do {
        CC_BREAK_IF(!CObjectBase::init(pObjectDict));
        CCString* fileType = getFileTypeFromDict();
        CC_BREAK_IF(NULL == fileType);
        CCString* fileName = getFileNameFromDict();
        CC_BREAK_IF(NULL == fileName);
        
        if (getMaxLevelFromDict() > 0)
        {
            fileName = CCString::createWithFormat("%s%d", fileName->getCString(), getLevel() - 1);
        }
        
        if (fileType->compare("ccbi") == 0)
        {
            fileName = CCString::createWithFormat("%s.ccbi", fileName->getCString());
            CC_BREAK_IF(!setSpriteFromCcbi(fileName->getCString()));
        }
        else
        {
            CC_BREAK_IF(!setSprite(fileName->getCString()));
        }
        
        return true;
    } while (false);
    
    return false;
}
コード例 #22
0
ファイル: player.cpp プロジェクト: mekolat/elektrogamesvn
Player::Player(int id, int job, Map *map, bool isNPC):
    Being(id, job, map),
    mGender(GENDER_UNSPECIFIED),
    mIsGM(false),
    mInParty(false)
{
    if (!isNPC)
    {
        for (int i = 0; i < VECTOREND_SPRITE; i++)
        {
            mSprites.push_back(NULL);
            mSpriteIDs.push_back(0);
            mSpriteColors.push_back("");
        }

        /* Human base sprite. When implementing different races remove this
         * line and set the base sprite when setting the race of the player
         * character.
         */
        setSprite(BASE_SPRITE, -100);
    }
    mShowName = config.getValue("visiblenames", 1);
    config.addListener("visiblenames", this);

    updateColors();
}
コード例 #23
0
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;
}
コード例 #24
0
//Block color is set depending on whether or not it's on a plate
void Block::chooseSprite(bool onPlate)
{
	ResourceManager &rm = ResourceManager::getInstance();
	if (!onPlate)
	{
		Sprite *p_temp_sprite;
		p_temp_sprite = rm.getSprite("blockoff");
		setSprite(p_temp_sprite);
	}
	else
	{
		Sprite *p_temp_sprite;
 		p_temp_sprite = rm.getSprite("blockon");
		setSprite(p_temp_sprite);
	}
	
}
コード例 #25
0
ファイル: Projectile.cpp プロジェクト: grnnn/CS146-Project2
Projectile::Projectile(const TextureHolder& textures)
: mType(AlliedBullet)
{
    sf::Sprite spr(textures.get(Textures::Projectile));
    centerOrigin(spr);
    setSprite(spr);
    setID(1);
}
コード例 #26
0
ファイル: Block.cpp プロジェクト: nshermione/pingpongcocos2dx
void Block::init(cocos2d::Sprite *sprite, const std::string& name) {
    GameObject::init(name);
    setSprite(sprite);
    setName(name);
    auto world = Physics::getWorld2D();
    auto physicsBody = world->addBody(sprite, name, "block");
    physicsBody->setDynamic(false);
}
コード例 #27
0
ファイル: SpaceObjectWidget.cpp プロジェクト: GoodRon/OpenSR
void SpaceObjectWidget::setObject(boost::shared_ptr< SpaceObject > object)
{
    m_object = object;
    if (!m_object)
        return;

    if (boost::shared_ptr<Asteroid> a = boost::dynamic_pointer_cast<Asteroid>(object))
    {
        boost::shared_ptr<AsteroidStyle> s = WorldManager::instance().styleManager().asteroidStyle(a->style());

        if (s->animated)
            setSprite(boost::shared_ptr<Sprite>(new AnimatedSprite(s->sprite)));
        else
            setSprite(boost::shared_ptr<Sprite>(new Sprite(s->sprite)));
    }

    updatePosition();
}
コード例 #28
0
ファイル: Hero.cpp プロジェクト: Rdbaker/wings
Hero::Hero(bool isClient) : isClient(isClient) {

  // Link to "ship" sprite.
  df::ResourceManager &resource_manager = df::ResourceManager::getInstance();
  df::LogManager &log_manager = df::LogManager::getInstance();
  df::Sprite *p_temp_sprite;
  if(isClient) {
    p_temp_sprite = resource_manager.getSprite("client");
  } else {
    p_temp_sprite = resource_manager.getSprite("ship");
  }
  if (!p_temp_sprite) {
    log_manager.writeLog("Hero::Hero(): Warning! Sprite '%s' not found",
			 "ship");
  } else {
    setSprite(p_temp_sprite);
    setSpriteSlowdown(3);  // 1/3 speed animation.
    setTransparency();	   // Transparent sprite.
  }

  // Player controls hero, so register for input events.
  registerInterest(df::KEYBOARD_EVENT);
  registerInterest(df::MOUSE_EVENT);

  // Need to update rate control each step.
  registerInterest(df::STEP_EVENT);

  // Set object type.
  setType("Hero");

  // Set starting location.
  df::WorldManager &world_manager = df::WorldManager::getInstance();
  if(isClient) {
    df::Position pos(7, world_manager.getBoundary().getVertical()/2+4);
    setPosition(pos);
  } else {
    df::Position pos(7, world_manager.getBoundary().getVertical()/2-4);
    setPosition(pos);
  }

  // Create reticle for firing bullets.
  p_reticle = new Reticle();
  p_reticle->draw();

  // Set attributes that control actions.
  move_slowdown = 2;
  move_countdown = move_slowdown;
  fire_slowdown = 30;
  fire_countdown = fire_slowdown;
  nuke_count = 1;
  Role &role = Role::getInstance();
  if(role.isHost()) {
    role.registerSyncObj(this);
    log_manager.writeLog("Hero::Hero(): INFO! registered with %s", serialize().c_str());
  }
}
コード例 #29
0
ファイル: Wall.cpp プロジェクト: westleyrussell/Dragonfly
Wall::Wall(int x, int y){
	pos = Position(x, y);
	this->setPosition(pos);
	ResourceManager &rm = ResourceManager::getInstance();
	Sprite *p_temp_sprite;
	p_temp_sprite = rm.getSprite("bullet");
	setSprite(p_temp_sprite);

	//setXVelocity(0.5);
}
コード例 #30
0
ファイル: Unit.cpp プロジェクト: kevinkraft/RTS_3
Unit::Unit(float pos_x, float pos_y, std::string name) :
  EntityAction(pos_x, pos_y, UNIT_INV_CAP)
{
  setSprite( new Sprite(pos_x, pos_y, UNIT_CLICK_WIDTH, UNIT_CLICK_HEIGHT, UNIT_CLICK_OFFSET_X, UNIT_CLICK_OFFSET_Y) );
  setPosX(pos_x);
  setPosY(pos_y);
  setName(name);
  
  setDead(false);
}