void streams_to_stream_ii_4i_base::construct()
{
    Resource_impl::_started = false;
    loadProperties();
    serviceThread = 0;
    sentEOS = false;
    inputPortOrder.resize(0);;
    outputPortOrder.resize(0);

    PortableServer::ObjectId_var oid;
    long_in_0 = new bulkio::InLongPort("long_in_0");
    long_in_0->setNewStreamListener(this, &streams_to_stream_ii_4i_base::long_in_0_newStreamCallback);
    oid = ossie::corba::RootPOA()->activate_object(long_in_0);
    long_in_1 = new bulkio::InLongPort("long_in_1");
    long_in_1->setNewStreamListener(this, &streams_to_stream_ii_4i_base::long_in_1_newStreamCallback);
    oid = ossie::corba::RootPOA()->activate_object(long_in_1);
    long_in_2 = new bulkio::InLongPort("long_in_2");
    long_in_2->setNewStreamListener(this, &streams_to_stream_ii_4i_base::long_in_2_newStreamCallback);
    oid = ossie::corba::RootPOA()->activate_object(long_in_2);
    long_in_3 = new bulkio::InLongPort("long_in_3");
    long_in_3->setNewStreamListener(this, &streams_to_stream_ii_4i_base::long_in_3_newStreamCallback);
    oid = ossie::corba::RootPOA()->activate_object(long_in_3);
    long_out = new bulkio::OutLongPort("long_out");
    oid = ossie::corba::RootPOA()->activate_object(long_out);

    registerInPort(long_in_0);
    inputPortOrder.push_back("long_in_0");
    registerInPort(long_in_1);
    inputPortOrder.push_back("long_in_1");
    registerInPort(long_in_2);
    inputPortOrder.push_back("long_in_2");
    registerInPort(long_in_3);
    inputPortOrder.push_back("long_in_3");
    registerOutPort(long_out, long_out->_this());
    outputPortOrder.push_back("long_out");

}
void argmax_ss_3i_base::construct()
{
    Resource_impl::_started = false;
    loadProperties();
    serviceThread = 0;
    sentEOS = false;
    inputPortOrder.resize(0);;
    outputPortOrder.resize(0);

    PortableServer::ObjectId_var oid;
    short_in_1 = new bulkio::InShortPort("short_in_1");
    short_in_1->setNewStreamListener(this, &argmax_ss_3i_base::short_in_1_newStreamCallback);
    oid = ossie::corba::RootPOA()->activate_object(short_in_1);
    short_in_2 = new bulkio::InShortPort("short_in_2");
    short_in_2->setNewStreamListener(this, &argmax_ss_3i_base::short_in_2_newStreamCallback);
    oid = ossie::corba::RootPOA()->activate_object(short_in_2);
    short_in_3 = new bulkio::InShortPort("short_in_3");
    short_in_3->setNewStreamListener(this, &argmax_ss_3i_base::short_in_3_newStreamCallback);
    oid = ossie::corba::RootPOA()->activate_object(short_in_3);
    short_out_1 = new bulkio::OutShortPort("short_out_1");
    oid = ossie::corba::RootPOA()->activate_object(short_out_1);
    short_out_2 = new bulkio::OutShortPort("short_out_2");
    oid = ossie::corba::RootPOA()->activate_object(short_out_2);

    registerInPort(short_in_1);
    inputPortOrder.push_back("short_in_1");
    registerInPort(short_in_2);
    inputPortOrder.push_back("short_in_2");
    registerInPort(short_in_3);
    inputPortOrder.push_back("short_in_3");
    registerOutPort(short_out_1, short_out_1->_this());
    outputPortOrder.push_back("short_out_1");
    registerOutPort(short_out_2, short_out_2->_this());
    outputPortOrder.push_back("short_out_2");

}
Beispiel #3
0
Entity *addPendulum(int x, int y, char *name)
{
	Entity *e = getFreeEntity();

	if (e == NULL)
	{
		showErrorAndExit("No free slots to add a Pendulum");
	}

	loadProperties(name, e);

	e->x = x;
	e->y = y;

	e->action = &init;
	e->draw = &drawLoopingAnimationToMap;
	e->touch = &entityTouch;

	e->type = ENEMY;

	setEntityAnimation(e, "STAND");

	return e;
}
Beispiel #4
0
    bool Module::init(QWidget* parent)
    {		
        // has it already been init?
        if (m_isInit)
            return false;

        qDebug() << "initializing module: " << getModuleName();
        
        m_parent = parent;
        QMainWindow::setParent(m_parent);

        // load properties from file
        loadProperties(getModuleName());

        // init module
        if (iInit(m_parent))
            m_isInit = true;

        if (m_isInit)
            qDebug() << "module " << getModuleName() << " was successfully initialized";

        // was it successful?
        return m_isInit;
    }
Beispiel #5
0
Entity *addFlyBoss(int x, int y, char *name)
{
	Entity *e = getFreeEntity();

	if (e == NULL)
	{
		showErrorAndExit("No free slots to add the Fly Boss");
	}

	loadProperties(name, e);

	e->x = x;
	e->y = y;

	e->action = &initialise;

	e->draw = &drawSuspended;

	e->takeDamage = NULL;

	e->type = ENEMY;

	e->flags |= FLY;

	e->active = FALSE;

	e->fallout = &fallout;

	e->die = &die;

	e->creditsAction = &creditsMove;

	setEntityAnimation(e, "CUSTOM_1");

	return e;
}
Beispiel #6
0
static void addStunStar()
{
    int i;
    Entity *e;

    for (i=0; i<2; i++)
    {
        e = getFreeEntity();

        if (e == NULL)
        {
            showErrorAndExit("No free slots to add the Awesome Boss's Star");
        }

        loadProperties("boss/armour_boss_star", e);

        e->x = self->x;
        e->y = self->y;

        e->action = &starWait;

        e->draw = &drawLoopingAnimationToMap;

        e->thinkTime = 300;

        e->head = self;

        setEntityAnimation(e, "STAND");

        e->currentFrame = (i == 0 ? 0 : 6);

        e->x = self->x + self->w / 2 - e->w / 2;

        e->y = self->y - e->h;
    }
}
void USRP_UHD_base::construct()
{
    Resource_impl::_started = false;
    loadProperties();
    serviceThread = 0;
    
    PortableServer::ObjectId_var oid;
    DigitalTuner_in = new FRONTEND_DigitalTuner_In_i("DigitalTuner_in", this);
    oid = ossie::corba::RootPOA()->activate_object(DigitalTuner_in);
    RFInfo_in = new FRONTEND_RFInfo_In_i("RFInfo_in", this);
    oid = ossie::corba::RootPOA()->activate_object(RFInfo_in);
    dataShortComplex_in = new BULKIO_dataShort_In_i("dataShortComplex_in", this);
    oid = ossie::corba::RootPOA()->activate_object(dataShortComplex_in);
    dataFloatComplex_in = new BULKIO_dataFloat_In_i("dataFloatComplex_in", this);
    oid = ossie::corba::RootPOA()->activate_object(dataFloatComplex_in);
    dataShort_out = new BULKIO_dataShort_Out_i("dataShort_out", this);
    oid = ossie::corba::RootPOA()->activate_object(dataShort_out);

    registerInPort(DigitalTuner_in);
    registerInPort(RFInfo_in);
    registerInPort(dataShortComplex_in);
    registerInPort(dataFloatComplex_in);
    registerOutPort(dataShort_out, dataShort_out->_this());
}
Beispiel #8
0
Entity *addSpider(int x, int y, char *name)
{
	Entity *e = getFreeEntity();

	if (e == NULL)
	{
		showErrorAndExit("No free slots to add a Spider");
	}

	loadProperties(name, e);

	e->x = x;
	e->y = y;

	e->action = &init;

	e->draw = &draw;
	e->touch = &entityTouch;
	e->die = &entityDie;

	if (strcmpignorecase(name, "enemy/red_spider") == 0)
	{
		e->takeDamage = &redTakeDamage;
	}

	else
	{
		e->takeDamage = &takeDamage;
	}

	e->type = ENEMY;

	setEntityAnimation(e, "STAND");

	return e;
}
Beispiel #9
0
Entity *addJigsawPuzzle(int x, int y, char *name)
{
	Entity *e = getFreeEntity();

	if (e == NULL)
	{
		showErrorAndExit("No free slots to add a Jigsaw Puzzle");
	}

	loadProperties(name, e);

	e->x = x;
	e->y = y;

	e->type = KEY_ITEM;

	e->action = &init;

	e->draw = &drawLoopingAnimationToMap;

	setEntityAnimation(e, "STAND");

	return e;
}
Beispiel #10
0
Entity *addHighStriker(int x, int y, char *name)
{
	Entity *e = getFreeEntity();

	if (e == NULL)
	{
		showErrorAndExit("No free slots to add a High Striker");
	}

	loadProperties(name, e);

	e->touch = &touch;

	e->action = &init;

	e->draw = &drawLoopingAnimationToMap;

	e->x = x;
	e->y = y;

	setEntityAnimation(e, "STAND");

	return e;
}
Beispiel #11
0
Entity *addGolemRockDropper(int x, int y, char *name)
{
	Entity *e = getFreeEntity();

	if (e == NULL)
	{
		showErrorAndExit("No free slots to add the Golem Rock Dropper");
	}

	loadProperties(name, e);

	e->x = x;
	e->y = y;

	e->action = &followPlayer;

	e->draw = &drawLoopingAnimationToMap;
	e->die = &die;
	e->activate = &activate;

	setEntityAnimation(e, "STAND");

	return e;
}
Beispiel #12
0
static void acidStream()
{
	Entity *e;

	self->endY--;

	if (self->endY <= 0)
	{
		e = getFreeEntity();

		if (e == NULL)
		{
			showErrorAndExit("No free slots to add Acid");
		}

		loadProperties("boss/cave_boss_acid", e);

		setEntityAnimation(e, "DOWN");

		if (self->face == LEFT)
		{
			e->x = self->x + self->w - self->offsetX;
		}

		else
		{
			e->x = self->x + self->offsetX;
		}

		e->y = self->y + self->offsetY;

		e->x -= e->w / 2;

		e->action = &fireFall;
		e->draw = &drawLoopingAnimationToMap;
		e->touch = &entityTouch;

		e->face = self->face;

		e->type = ENEMY;

		e->health = 0;

		self->endY = 6;
	}

	if (self->mental == 0)
	{
		self->thinkTime--;

		if (self->thinkTime <= 0)
		{
			setEntityAnimation(self, "NORMAL_ATTACK_DOWN_WALK");

			self->thinkTime = 60;

			self->mental = 1;

			self->dirX = self->face == LEFT ? self->speed : -self->speed;
		}
	}

	else
	{
		if (self->dirX == 0)
		{
			setEntityAnimation(self, "NORMAL_ATTACK_DOWN");

			self->thinkTime--;

			if (self->thinkTime <= 0)
			{
				self->targetX = getMapStartX() + SCREEN_WIDTH / 2 - self->w / 2;

				self->dirX = self->targetX < self->x ? -self->speed : self->speed;

				self->action = &acidStreamFinish;

				setEntityAnimation(self, "NORMAL_WALK");
			}
		}
	}

	checkToMap(self);
}
cpp_comp_base::cpp_comp_base(const char *uuid, const char *label) :
    Component(uuid, label),
    ThreadedComponent()
{
    loadProperties();
}
Beispiel #14
0
static void lightningCageWait()
{
	int i, middle;
	Entity *e;

	if (self->face == LEFT)
	{
		self->x = self->head->x + self->head->w - self->w - self->offsetX;
	}

	else
	{
		self->x = self->head->x + self->offsetX;
	}

	self->y = self->head->y + self->offsetY;

	middle = 0;

	e = NULL;

	if (self->head->mental == 1)
	{
		if (self->mental == 0)
		{
			self->endY = getMapFloor(self->x + self->w / 2, self->y);

			for (i=self->y;i<self->endY;i+=32)
			{
				e = getFreeEntity();

				if (e == NULL)
				{
					showErrorAndExit("No free slots to add lightning");
				}

				loadProperties("enemy/lightning", e);

				setEntityAnimation(e, "STAND");

				if (i == self->startY)
				{
					middle = self->targetX + self->w / 2 - e->w / 2;
				}

				e->x = middle;
				e->y = i;

				e->action = &cageLightningWait;

				e->draw = &drawLoopingAnimationToMap;
				e->touch = &entityTouch;

				e->head = self;

				e->currentFrame = prand() % 6;

				e->face = RIGHT;

				e->thinkTime = 15;
			}

			e->mental = 1;

			self->mental = 1;

			if (self->face == LEFT)
			{
				self->targetX = playSoundToMap("sound/boss/azriel/azriel_lightning_cage", -1, self->x, self->y, -1);
			}
		}
	}

	else if (self->head->mental == 2)
	{
		if (self->face == LEFT)
		{
			stopSound(self->targetX);
		}

		self->inUse = FALSE;
	}
}
Beispiel #15
0
static void beamWait()
{
	int i, x, startX, floor;
	Entity *e;

	self->thinkTime--;

	if (self->thinkTime <= 0)
	{
		if (self->mental == 1)
		{
			self->thinkTime = 60;

			setEntityAnimation(self, "STAND_RED");

			self->action = &redBeamWait;
		}

		else
		{
			i = 0;

			floor = getMapFloor(self->head->x + self->head->w / 2, self->head->y);

			/* Left side of beam */

			x = self->x;

			startX = getMapStartX();

			for (;x>=startX;)
			{
				e = getFreeEntity();

				loadProperties("boss/azriel_ground_spikes", e);

				e->head = self;

				e->x = x - e->w;
				e->y = floor;

				e->startY = e->y - e->h;

				e->endY = e->y;

				e->action = &spikeRise;
				e->draw = &drawLoopingAnimationToMap;
				e->touch = &entityTouch;

				e->face = RIGHT;

				e->type = ENEMY;

				e->thinkTime = prand() % 30;

				x = e->x;

				i++;
			}

			/* Right side of beam */

			x = self->x + self->w;

			startX = getMapStartX() + SCREEN_WIDTH;

			for (;x<startX;)
			{
				e = getFreeEntity();

				loadProperties("boss/azriel_ground_spikes", e);

				e->head = self;

				e->x = x;
				e->y = floor;

				e->startY = e->y - e->h;

				e->endY = e->y;

				e->action = &spikeRise;
				e->draw = &drawLoopingAnimationToMap;
				e->touch = &entityTouch;

				e->face = RIGHT;

				e->type = ENEMY;

				e->thinkTime = prand() % 30;

				x = e->x + e->w;

				i++;
			}

			self->mental = i;

			self->thinkTime = 30;

			self->action = &beamFinish;
		}
	}
}
Beispiel #16
0
void TMXLoader::loadObjectLayers(std::unique_ptr<TMXMap> const &map, rapidxml::xml_node<> *parentNode)
{
    // Create a new node based on the parent node
    rapidxml::xml_node<> *currentNode = parentNode;
    
    // Move to first layer node
    currentNode = currentNode->first_node("objectgroup");
    
    std::vector<char*> layerVector;
    char* layerName = nullptr;
    std::unordered_map<std::string, std::string> layerProperties;
    std::unordered_map<std::string, std::string> objectProperties;
    
    while (currentNode != nullptr)
    {
        // Clear these both to hold data for the next layer
        layerProperties.clear();
        layerVector.clear();
        
        // Read data into the current layer vector
        for (rapidxml::xml_attribute<char> *attr = currentNode->first_attribute(); attr; attr = attr->next_attribute())
        {
            layerVector.push_back(attr->value());
        }
        
        layerName = layerVector[0];
        loadProperties(layerProperties, currentNode);

        currentNode = currentNode->first_node("object");
        
        // Move to the tile nodes for the current layer
        
        // Create 2D vector to hold object data
        std::vector<TMXObject> objectVector;
        std::vector<char*> attrVector;
        
        // Loop whilst there are still tiles to be read and add them to the vector
        
        unsigned int objId;
        char* objtype = nullptr;
        unsigned int objgid;
        unsigned int objx;
        unsigned int objy;
        unsigned int objWidth;
        unsigned int objHeight;
        
        
        while (currentNode != nullptr)
        {
            
            objectProperties.clear();
            attrVector.clear();
            
            for (rapidxml::xml_attribute<char> *attr = currentNode->first_attribute(); attr; attr = attr->next_attribute())
            {
                attrVector.push_back(attr->value());
            }
            
            objId = atoi(attrVector[0]);
            objtype = attrVector[1];
            objgid = atoi(attrVector[2]);
            objx = atoi(attrVector[3]);
            objy = atoi(attrVector[4]);
            objy-= 16;
            std::cout << objy << std::endl;
            objWidth = atoi(attrVector[5]);
            objHeight = atoi(attrVector[6]);
            loadProperties(objectProperties, currentNode);
            
            TMXObject object(objId,objtype,objgid,objx,objy,objWidth,objHeight,objectProperties);
            objectVector.push_back(object);
            
                if (currentNode->next_sibling("object") == nullptr)
                    break;
                else
                    currentNode = currentNode->next_sibling("object");
      
            
        }
        
        // Add the newly read layer to the map
        map->addObjectLayer(TMXObjectLayer(layerName, objectVector));
        
        // Move to the next layer
        currentNode = currentNode->parent()->parent()->next_sibling("objectgroup");
    }
}
Beispiel #17
0
void TMXLoader::loadTileSets(std::unique_ptr<TMXMap> const &map, rapidxml::xml_node<> *parentNode)
{
	// Create a new node based on the parent node
	rapidxml::xml_node<> *currentNode = parentNode;

	// Check if there is a tileset node
	if (currentNode->first_node("tileset") != nullptr)
	{
		// Move to the first tileset node
		currentNode = currentNode->first_node("tileset");

		// Use a map to hold data for creating a tile set
		std::unordered_map<std::string, std::string> tileSetData;

		// Use a map to hold tileset properties
		std::unordered_map<std::string, std::string> propertiesMap;

		// Use a vector and map for individual tiles that have properties
		std::vector<TMXTile> tileVector;
		std::unordered_map<std::string, std::string> tileProperties;

		// Loop whilst there are tileset nodes found
		while (currentNode != nullptr)
		{
			// Read tileset data 
			for (rapidxml::xml_attribute<char> *attr = currentNode->first_attribute(); attr; attr = attr->next_attribute())
			{
				tileSetData[attr->name()] = attr->value();
			}

			// Check for offset node
			rapidxml::xml_node<> *offsetNode = currentNode;
			if (offsetNode->first_node("tileoffset") != nullptr)
			{
				offsetNode = offsetNode->first_node("tileoffset");

				tileSetData["tileoffsetX"] = offsetNode->first_attribute()->value();
				tileSetData["tileoffsetY"] = offsetNode->first_attribute()->next_attribute()->value();
			}

			// Clear the properties map of the data from the previous tileset
			propertiesMap.clear();
			// Load tileset properties
			loadProperties(propertiesMap, currentNode);

			// Move to the image childnode and read data
			currentNode = currentNode->first_node("image");
			for (rapidxml::xml_attribute<char> *attr = currentNode->first_attribute(); attr; attr = attr->next_attribute())
			{
				if (strcmp(attr->name(), "trans") == 0)
				{
					unsigned int colour = std::stoi(attr->value(), 0, 16);
                    
                    // Convert from hex to RGB
					tileSetData["red"] = std::to_string(colour / 0x10000);
					tileSetData["green"] = std::to_string((colour / 0x100) % 0x100);
					tileSetData["blue"] = std::to_string(colour / 0x10000);
				}
				else
				{
					tileSetData[attr->name()] = attr->value();
				}
			}

			// Check and load if any individual tiles have properties
			tileVector.clear();
			rapidxml::xml_node<> *tileNode = currentNode->parent()->first_node("tile");
			while (tileNode != nullptr)
			{
				unsigned int tileID = atoi(tileNode->first_attribute()->value());
				loadProperties(tileProperties, tileNode);
				tileVector.push_back(TMXTile(tileID, tileProperties));

				tileProperties.clear();

				if (tileNode->next_sibling("tile") != nullptr)
				{
					tileNode = tileNode->next_sibling("tile");
				}
				else
				{
					break;
				}
			}

			// Pass the new tileset data to the map
 			map->addTileSet(TMXTileSet(tileSetData, propertiesMap, tileVector));

			// Move to the next tileset node and increment the counter
			if (currentNode->parent()->next_sibling("tileset") == nullptr)
			{
				break;
			}
			else
			{
				tileSetData.clear();
				currentNode = currentNode->parent()->next_sibling("tileset");
			}
		}
	}
}
static void lightningBolt()
{
	int i, middle;
	Entity *e;

	self->flags |= NO_DRAW;

	self->thinkTime--;

	middle = -1;

	if (self->thinkTime <= 0)
	{
		playSoundToMap("sound/enemy/thunder_cloud/lightning", -1, self->targetX, self->startY, 0);

		for (i=self->startY;i<self->endY;i+=32)
		{
			e = getFreeEntity();

			if (e == NULL)
			{
				showErrorAndExit("No free slots to add lightning");
			}

			loadProperties("enemy/lightning", e);

			setEntityAnimation(e, "STAND");

			if (i == self->startY)
			{
				middle = self->targetX + self->w / 2 - e->w / 2;
			}

			e->x = middle;
			e->y = i;

			e->action = &lightningWait;

			e->draw = &drawLoopingAnimationToMap;
			e->touch = &entityTouch;

			e->head = self;

			e->currentFrame = prand() % 6;

			e->face = RIGHT;

			e->thinkTime = 15;
		}

		e = addSmallRock(self->x, self->endY, "common/small_rock");

		e->x += (self->w - e->w) / 2;
		e->y -= e->h;

		e->dirX = -3;
		e->dirY = -8;

		e = addSmallRock(self->x, self->endY, "common/small_rock");

		e->x += (self->w - e->w) / 2;
		e->y -= e->h;

		e->dirX = 3;
		e->dirY = -8;

		self->inUse = FALSE;
	}
}
Beispiel #19
0
static void smallBounceAround()
{
	int y;

	if (self->flags & ON_GROUND)
	{
		self->dirX = self->standingOn == NULL ? 0 : self->standingOn->dirX;

		if (self->mental <= 0)
		{
			y = self->y + self->h;

			loadProperties("enemy/splitter_medium", self);

			setEntityAnimation(self, "CUSTOM_1");

			self->y = y - self->h;

			self->action = &smallBecomeMedium;

			self->touch = &entityTouch;

			self->thinkTime = 120;

			setCustomAction(self, &invulnerableNoFlash, 120, 0, 0);
		}

		else if (self->thinkTime <= 0)
		{
			if (prand() % 3 == 0)
			{
				playSoundToMap("sound/enemy/jumping_slime/baby_jump2", -1, self->x, self->y, 0);
			}

			else
			{
				playSoundToMap("sound/enemy/jumping_slime/baby_jump1", -1, self->x, self->y, 0);
			}

			self->dirY = -(6 + prand() % 2);

			self->thinkTime = 30 + prand() % 60;

			if (prand() % 2 == 0)
			{
				self->face = LEFT;

				if (isAtEdge(self) == TRUE)
				{
					self->face = RIGHT;
				}
			}

			else
			{
				self->face = RIGHT;

				if (isAtEdge(self) == TRUE)
				{
					self->face = LEFT;
				}
			}

			self->dirX = (prand() % 2 + 2) * (self->face == LEFT ? -1 : 1);
		}

		else
		{
			self->thinkTime--;

			self->mental--;
		}
	}

	checkToMap(self);
}
Beispiel #20
0
static void stunned()
{
	int i;
	long onGround = self->flags & ON_GROUND;
	Entity *e;

	checkToMap(self);

	if (self->flags & ON_GROUND)
	{
		if (onGround == 0)
		{
			for (i=0;i<2;i++)
			{
				e = getFreeEntity();

				if (e == NULL)
				{
					showErrorAndExit("No free slots to add the Cave Boss's Star");
				}

				loadProperties("boss/armour_boss_star", e);

				e->x = self->x;
				e->y = self->y;

				e->action = &starWait;

				e->draw = &drawLoopingAnimationToMap;

				e->thinkTime = self->thinkTime;

				e->head = self;

				setEntityAnimation(e, "STAND");

				e->currentFrame = (i == 0 ? 0 : 6);

				if (self->face == LEFT)
				{
					e->x = self->x + self->w - e->w - e->offsetX;
				}

				else
				{
					e->x = self->x + e->offsetX;
				}

				e->y = self->y + e->offsetY;
			}

			for (i=0;i<20;i++)
			{
				addSmoke(self->x + prand() % self->w, self->y + self->h - prand() % 10, "decoration/dust");
			}

			playSoundToMap("sound/common/crash", BOSS_CHANNEL, self->x, self->y, 0);
		}

		self->action = &stunFinish;
	}
}
	void MenuLoad::load()
	{
		loadIconMasks();
		loadProperties();
		loadAssets();
	}
Beispiel #22
0
static void ceilingBurn()
{
	Entity *e;

	self->thinkTime--;

	if (self->thinkTime <= 0)
	{
		e = getFreeEntity();

		if (e == NULL)
		{
			showErrorAndExit("No free slots to add Fire");
		}

		loadProperties("enemy/fire", e);

		setEntityAnimation(e, "UP");

		if (self->face == LEFT)
		{
			e->x = self->x + self->w - self->offsetX;
		}

		else
		{
			e->x = self->x + self->offsetX;
		}

		e->y = self->y + self->offsetY;

		e->x -= e->w / 2;

		e->action = &fireFall;
		e->draw = &drawLoopingAnimationToMap;
		e->touch = &entityTouch;

		e->face = self->face;

		e->type = ENEMY;

		e->flags |= FLY;

		e->thinkTime = 600;

		e->dirY = -15;

		self->mental--;

		if (self->mental <= 0)
		{
			self->endY += TILE_SIZE / 2 - e->w / 2;

			self->thinkTime = 30;

			self->action = &ceilingBurnWait;
		}

		else
		{
			self->thinkTime = 6;
		}
	}

	checkToMap(self);
}
Beispiel #23
0
void TMXLoader::loadLayers(std::unique_ptr<TMXMap> const &map, rapidxml::xml_node<> *parentNode)
{
	// Create a new node based on the parent node
	rapidxml::xml_node<> *currentNode = parentNode;

	// Move to first layer node
	currentNode = currentNode->first_node("layer");
    
    std::vector<char*> layerVector;

	char* layerName = nullptr;
	unsigned int layerWidth = 0;
	unsigned int layerHeight = 0;
	std::unordered_map<std::string, std::string> layerProperties;

	while (currentNode != nullptr)
	{
        // Clear these both to hold data for the next layer
		layerProperties.clear();
        layerVector.clear();
        
		// Read data into the current layer vector
		for (rapidxml::xml_attribute<char> *attr = currentNode->first_attribute(); attr; attr = attr->next_attribute())
		{
            layerVector.push_back(attr->value());
		}
        
        layerName = layerVector[0];
        layerWidth = atoi(layerVector[1]);
        layerHeight = atoi(layerVector[2]);

		// Load any properties for the layer
		loadProperties(layerProperties, currentNode);

		currentNode = currentNode->first_node("data");
		// Move to the tile nodes for the current layer
		currentNode = currentNode->first_node("tile");

        // Create 2D vector to hold tile data
        std::vector<std::vector<unsigned int>> tileVector(layerHeight, std::vector<unsigned int>(layerWidth));

        int currentTile = 0;
        int currentRow = 0;
        
        // Loop whilst there are still tiles to be read and add them to the vector
        while (currentNode != nullptr)
        {
            if (currentTile < layerWidth)
            {
                // Add tile to vector, must be cast from char* to unsigned int
                tileVector[currentRow][currentTile] = (unsigned int)std::stoul(currentNode->first_attribute()->value());
                
                currentTile++;
                
                // Determine if there is another tile to be read or not
                if (currentNode->next_sibling("tile") == nullptr)
                    break;
                else
                    currentNode = currentNode->next_sibling("tile");
            }
            else
            {
                currentTile = 0;
                currentRow++;
            }
                             
        }

		// Add the newly read layer to the map
		map->addLayer(TMXTileLayer(layerName, layerWidth, layerHeight, layerProperties, tileVector));
		
		// Move to the next layer
		currentNode = currentNode->parent()->parent()->next_sibling("layer");
	}
}
int
main(int argc, char *argv[]) {
	
	info = (struct test_info *)malloc(sizeof(struct test_info));
	test_info_init(info);
	info->test_type = 0;
    info->msg_count=50;
    
    struct plat_opts_config_mpilogme config;
    SDF_boolean_t success = SDF_TRUE;
    uint32_t numprocs;
    int tmp, namelen, mpiv = 0, mpisubv = 0, i;
    char processor_name[MPI_MAX_PROCESSOR_NAME];
    int msg_init_flags = SDF_MSG_MPI_INIT;
    config.inputarg = 0;
    config.msgtstnum = 500;

    /* We may not need to gather anything from here but what the heck */
    loadProperties("/opt/schooner/config/schooner-med.properties"); // TODO get filename from command line

    /* make sure this is first in order to get the the mpi init args */
    success = plat_opts_parse_mpilogme(&config, argc, argv) ? SDF_FALSE : SDF_TRUE;

    printf("input arg %d msgnum %d success %d\n", config.inputarg, config.msgtstnum, success);
    fflush(stdout);
    myid = sdf_msg_init_mpi(argc, argv, &numprocs, &success, msg_init_flags);
    info->myid = myid;
    if ((!success) || (myid < 0)) {
        printf("Node %d: MPI Init failure... exiting - errornum %d\n", myid, success);
        fflush(stdout);
        MPI_Finalize();
        return (EXIT_FAILURE);
    }

    int debug = 0;
    while(debug);

    tmp = init_msgtest_sm((uint32_t)myid);

    /* Enable this process to run threads across 2 cpus, MPI will default to running all threads
     * on only one core which is not what we really want as it forces the msg thread to time slice
     * with the fth threads that send and receive messsages
     * first arg is the number of the processor you want to start off on and arg #2 is the sequential
     * number of processors from there
     */
    //lock_processor(0, 7);
    lock_processor(myid * 4, 4);
    info->lock_cpu = 4;
    sleep(1);
    msg_init_flags =  msg_init_flags | SDF_MSG_RTF_DISABLE_MNGMT;

    /* Startup SDF Messaging Engine FIXME - dual node mode still - pnodeid is passed and determined
     * from the number of processes mpirun sees.
     */
    sdf_msg_init(myid, &pnodeid, msg_init_flags);

    MPI_Get_version(&mpiv, &mpisubv);
    MPI_Get_processor_name(processor_name, &namelen);

    printf("Node %d: MPI Version: %d.%d Name %s \n", myid, mpiv, mpisubv, processor_name);
    fflush(stdout);

    plat_log_msg(
            PLAT_LOG_ID_INITIAL,
            LOG_CAT,
            PLAT_LOG_LEVEL_TRACE,
            "\nNode %d: Completed Msg Init.. numprocs %d pnodeid %d Starting Test\n",
            myid, numprocs, pnodeid);
    info->pnodeid = pnodeid;
    for (i = 0; i < 2; i++) {
        sleep(2);
        plat_log_msg(PLAT_LOG_ID_INITIAL, LOG_CAT, PLAT_LOG_LEVEL_TRACE,
                "\nNode %d: Number of sleeps %d\n", myid, i);
    }

    fthInit();

    /* SAVE THIS may need to play with the priority later */
#if 0
    struct sched_param param;
    int newprio = 60;
    pthread_attr_t hi_prior_attr;

    pthread_attr_init(&hi_prior_attr);
    pthread_attr_setschedpolicy(&hi_prior_attr, SCHED_FIFO);
    pthread_attr_getschedparam(&hi_prior_attr, &param);
    param.sched_priority = newprio;
    pthread_attr_setschedparam(&hi_prior_attr, &param);
    pthread_create(&fthPthread, &hi_prior_attr, &fthPthreadRoutine, NULL);
#endif

    pthread_attr_t attr;
    pthread_attr_init(&attr);
    pthread_create(&fthPthread, &attr, &SinglePtlSequentialPressPthreadRoutine, NULL);

    plat_log_msg(PLAT_LOG_ID_INITIAL, LOG_CAT, PLAT_LOG_LEVEL_TRACE,
                 "\nNode %d: Created pthread for FTH %d\n", myid, i);
    info->pthread_info = 1;
    info->fth_info = 2;
    pthread_join(fthPthread, NULL);

    plat_log_msg(PLAT_LOG_ID_INITIAL, LOG_CAT, PLAT_LOG_LEVEL_TRACE,
                 "\nNode %d: SDF Messaging Test Complete - i %d\n", myid, i);

    /* Lets stop the messaging engine this will block until they complete */
    /* FIXME arg is the threadlvl */
    sdf_msg_stopmsg(myid, SYS_SHUTDOWN_SELF);
    
    if (numprocs > 1) {
        sdf_msg_nsync(myid, (myid == 0 ? 1 : 0));
    }

    plat_shmem_detach();
    info->success++;
    if (myid == 0) {
        sched_yield();
        printf("Node %d: Exiting message test after yielding... Calling MPI_Finalize\n", myid);
        fflush(stdout);
        sched_yield();
        MPI_Finalize();
        print_test_info(info);
        test_info_final(info);
    }
    else {
        printf("Node %d: Exiting message test... Calling MPI_Finalize\n", myid);
        fflush(stdout);
        sched_yield();
        MPI_Finalize();
    }
    printf("Successfully ends\n");
    return (EXIT_SUCCESS);

}
Beispiel #25
0
static void entityWait()
{
	int i;
	Entity *e;

	self->thinkTime--;

	if (self->thinkTime <= 0)
	{
		self->mental = self->mental == 0 ? 1 : 0;

		self->thinkTime = 120;

		for (i=0;i<2;i++)
		{
			e = getFreeEntity();

			if (e == NULL)
			{
				showErrorAndExit("No free slots to add a Flame Statue Flame");
			}

			loadProperties("enemy/horizontal_flame", e);

			if (i == 0)
			{
				e->face = RIGHT;

				e->x = self->x + self->w;

				e->y = self->y + (self->mental == 1 ? self->offsetY : self->offsetX);
			}

			else
			{
				e->face = LEFT;

				e->x = self->x - e->w;

				e->y = self->y + (self->mental == 0 ? self->offsetY : self->offsetX);
			}

			e->action = &flameWait;
			e->draw = &drawLoopingAnimationToMap;
			e->touch = &flameTouch;

			e->head = self;

			e->thinkTime = self->thinkTime;

			if (i == 0)
			{
				e->endY = playSoundToMap("sound/enemy/fire_burner/flame", -1, self->x, self->y, -1);
			}

			else
			{
				e->endY = -1;
			}

			e->type = ENEMY;

			e->flags |= DO_NOT_PERSIST|PLAYER_TOUCH_ONLY;

			setEntityAnimation(e, "STAND");
		}

		self->action = &doFlame;
	}

	self->dirX = self->standingOn != NULL ? self->standingOn->dirX : 0;

	checkToMap(self);
}
TestCppOptionalProps_base::TestCppOptionalProps_base(const char *uuid, const char *label) :
    Component(uuid, label),
    ThreadedComponent()
{
    loadProperties();
}
Beispiel #27
0
static void lightningCageCreate()
{
	int i;
	Entity *e;

	self->thinkTime--;

	if (self->thinkTime <= 0)
	{
		setEntityAnimation(self, "LIGHTNING_CAGE");

		self->x = player.x + player.w / 2 - self->w / 2;

		addParticleExplosion(self->x + self->w / 2, self->y + self->h / 2);

		playSoundToMap("sound/common/spell", -1, self->x, self->y, 0);

		self->flags &= ~NO_DRAW;

		self->face = prand() % 2 == 0 ? LEFT : RIGHT;

		self->mental = 0;

		self->thinkTime = 60;

		self->maxThinkTime = 0;

		for (i=0;i<2;i++)
		{
			e = getFreeEntity();

			if (e == NULL)
			{
				showErrorAndExit("No free slots to add a lightning cage");
			}

			loadProperties("boss/azriel_lightning_cage_spell", e);

			e->action = &lightningCageWait;

			e->draw = &drawLoopingAnimationToMap;

			e->touch = &entityTouch;

			e->head = self;

			e->face = i == 0 ? LEFT : RIGHT;

			setEntityAnimation(e, "STAND");

			if (e->face == LEFT)
			{
				e->x = self->x + self->w - e->w - e->offsetX;
			}

			else
			{
				e->x = self->x + e->offsetX;
			}

			e->y = self->y + e->offsetY;
		}

		self->action = &lightningCageMoveAbovePlayer;
	}

	becomeTransparent();
}
Beispiel #28
0
void doCursor()
{
	char name[MAX_VALUE_LENGTH];
	int x, y;

	cursor.x = input.mouseX;
	cursor.y = input.mouseY;

	if (cursor.type == TILES || cursor.snapToGrid == 1)
	{
		cursor.x /= TILE_SIZE;
		cursor.y /= TILE_SIZE;

		cursor.x *= TILE_SIZE;
		cursor.y *= TILE_SIZE;
	}

	if (cursor.y >= SCREEN_HEIGHT - TILE_SIZE)
	{
		cursor.y = SCREEN_HEIGHT - TILE_SIZE * 2;
	}

	if (input.left == 1)
	{
		mapStartXNext(-TILE_SIZE);
	}

	else if (input.right == 1)
	{
		mapStartXNext(TILE_SIZE);
	}

	if (input.up == 1)
	{
		mapStartYNext(-TILE_SIZE);
	}

	else if (input.down == 1)
	{
		mapStartYNext(TILE_SIZE);
	}

	if (input.snap == 1)
	{
		cursor.snapToGrid = 1 - cursor.snapToGrid;

		input.snap = 0;
	}

	if (input.activate == 1)
	{
		cursor.entity.face = (cursor.entity.face == RIGHT ? LEFT : RIGHT);

		input.activate = 0;
	}

	if (input.block == 1)
	{
		if (cursor.type == TILES)
		{
			x = (getMapStartX() + cursor.x) / TILE_SIZE;
			y = (getMapStartY() + cursor.y) / TILE_SIZE;

			while (mapTileAt(x, y) == BLANK_TILE && x >= 0)
			{
				setTileAt(x, y, cursor.tileID);

				x--;
			}

			x = (getMapStartX() + cursor.x) / TILE_SIZE;

			x++;

			while (mapTileAt(x, y) == BLANK_TILE && x < MAX_MAP_X)
			{
				setTileAt(x, y, cursor.tileID);

				x++;
			}
		}
	}

	if (input.add == 1)
	{
		if (cursor.type == TILES)
		{
			setTileAt((getMapStartX() + cursor.x) / TILE_SIZE, (getMapStartY() + cursor.y) / TILE_SIZE, cursor.tileID);
		}

		else
		{
			/* Entities can only be placed in blank spaces */

			if (isValidOnMap(&cursor.entity) == 1 && isSpaceEmpty(&cursor.entity) == NULL)
			{
				if (cursor.entityType == 0)
				{
					setPlayerLocation(getMapStartX() + cursor.x, getMapStartY() + cursor.y);
				}

				else
				{
					if (strcmpignorecase(cursor.entity.name, "lift/lift_target") == 0)
					{
						snprintf(name, sizeof(name), "NEW_TARGET_%03d", targetID);

						addTarget(getMapStartX() + cursor.x, getMapStartY() + cursor.y, name);

						targetID++;
					}

					else
					{
						cursor.entity.startX = getMapStartX() + cursor.x;
						cursor.entity.startY = getMapStartY() + cursor.y;

						cursor.entity.endX = getMapStartX() + cursor.x;
						cursor.entity.endY = getMapStartY() + cursor.y;

						addEntity(cursor.entity, getMapStartX() + cursor.x, getMapStartY() + cursor.y);
					}
				}
			}

			input.add = 0;
		}
	}

	else if (input.remove == 1)
	{
		if (cursor.type == TILES)
		{
			setTileAt((getMapStartX() + cursor.x) / TILE_SIZE, (getMapStartY() + cursor.y) / TILE_SIZE, BLANK_TILE);
		}

		else
		{
			self = isSpaceEmpty(&cursor.entity);

			if (self != NULL)
			{
				self->inUse = FALSE;
			}
		}
	}

	if (input.cut == 1)
	{
		if (cursor.type != TILES)
		{
			self = isSpaceEmpty(&cursor.entity);

			if (self != NULL)
			{
				cursor.entity = *self;

				self->inUse = FALSE;
			}
		}

		input.cut = 0;
	}

	if (input.previous == 1)
	{
		if (cursor.type == TILES)
		{
			cursor.tileID = prevTile(cursor.tileID);
		}

		else
		{
			cursor.entityType--;

			if (cursor.entityType < 0)
			{
				cursor.entityType = entityNamesLength - 1;
			}

			memset(&cursor.entity, 0, sizeof(Entity));

			cursor.entity.draw = &drawLoopingAnimationToMap;

			cursor.entity.weight = 0;

			cursor.entity.originalWeight = 0;

			cursor.entity.inUse = TRUE;

			loadProperties(entityNames[cursor.entityType], &cursor.entity);

			cursor.entity.active = TRUE;

			cursor.entity.alpha = 255;

			if (cursor.entity.weight == 0)
			{
				cursor.entity.weight = 1;

				cursor.entity.originalWeight = 1;
			}
		}

		input.previous = 0;
	}

	else if (input.next == 1)
	{
		if (cursor.type == TILES)
		{
			cursor.tileID = nextTile(cursor.tileID);
		}

		else
		{
			cursor.entityType++;

			if (cursor.entityType >= entityNamesLength)
			{
				cursor.entityType = 0;
			}

			memset(&cursor.entity, 0, sizeof(Entity));

			cursor.entity.draw = &drawLoopingAnimationToMap;

			cursor.entity.weight = 0;

			cursor.entity.originalWeight = 1;

			cursor.entity.inUse = TRUE;

			loadProperties(entityNames[cursor.entityType], &cursor.entity);

			cursor.entity.active = TRUE;

			cursor.entity.alpha = 255;

			if (cursor.entity.weight == 0)
			{
				cursor.entity.weight = 1;

				cursor.entity.originalWeight = 1;
			}
		}

		input.next = 0;
	}

	if (input.save == 1)
	{
		if (saveMap() == TRUE)
		{
			setStatusPanelMessage("Saved");
		}

		else
		{
			setStatusPanelMessage("Saving Failed");
		}

		input.save = 0;
	}
	/*
	if (input.load == 1)
	{
		loadMap(map.filename);

		printf("Loaded\n");

		input.load = 0;
	}
	*/
	if (input.left == 1 || input.right == 1 || input.up == 1 || input.down == 1)
	{
		SDL_Delay(30);
	}

	if (input.toggle == 1)
	{
		if (cursor.type == TILES)
		{
			cursor.type = ENTITIES;
		}

		else
		{
			cursor.type = TILES;
		}

		input.toggle = 0;
	}

	centerMapOnEntity(NULL);
}
Beispiel #29
0
static void soulStealMoveToPlayer()
{
	int mid;
	Entity *e;
	Target *t;

	self->thinkTime--;

	if (self->thinkTime <= 0)
	{
		setEntityAnimation(self, "SOUL_STEAL");

		self->flags &= ~NO_DRAW;

		t = getTargetByName("AZRIEL_LEFT_TARGET");

		if (t == NULL)
		{
			showErrorAndExit("Azriel cannot find target");
		}

		mid = getMapStartX() + SCREEN_WIDTH / 2;

		self->x = player.x < mid ? player.x + player.w + 24 : player.x - self->w - 24;

		self->y = t->y;

		self->targetX = player.x;

		setCustomAction(&player, &stickToFloor, 3, 0, 0);

		facePlayer();

		addParticleExplosion(self->x + self->w / 2, self->y + self->h / 2);

		playSoundToMap("sound/common/spell", -1, self->x, self->y, 0);

		self->action = &soulSteal;

		self->thinkTime = 600;

		self->maxThinkTime = player.alpha;

		self->targetY = player.alpha;

		self->mental = -3;

		e = getFreeEntity();

		if (e == NULL)
		{
			showErrorAndExit("No free slots to add the Soul Steal Spell");
		}

		loadProperties("boss/azriel_soul_steal_spell", e);

		setEntityAnimation(e, "STAND");

		e->face = self->face;

		if (self->face == LEFT)
		{
			e->x = self->x + self->w - e->w - e->offsetX;
		}

		else
		{
			e->x = self->x + e->offsetX;
		}

		e->y = self->y + e->offsetY;

		e->action = &soulStealSpellAttack;

		e->startX = e->x;
		e->startY = e->y;

		e->head = self;

		e->endX = player.x + player.w / 2;
		e->endY = player.y + player.h / 2;

		e->draw = &drawSoulStealSpell;

		e->flags &= ~NO_DRAW;
	}

	checkToMap(self);

	becomeTransparent();
}
TestLoggingAPI_base::TestLoggingAPI_base(const char *uuid, const char *label) :
    Resource_impl(uuid, label),
    ThreadedComponent()
{
    loadProperties();
}