コード例 #1
0
TeleportToArtifactRoom::TeleportToArtifactRoom(Point pos){
	position = pos;
	width = Global::TileWidth;
	height = Global::TileHeight;
	setupMask(&fullMask, width, height, sf::Color::Magenta);
	setupMask(&mask, width, height, sf::Color::Cyan);
	texture.loadFromFile("Tileset/artifactRoomStair.png");
	sprite.setTexture(texture);
	sprite.setPosition(position.x, position.y);
}
コード例 #2
0
DungeonMap::DungeonMap(Point pos){
	position = pos;
	width = Global::TileWidth;
	height = Global::TileHeight;
	setupMask(&fullMask, width, height, sf::Color::Magenta);
	setupMask(&mask, width, height, sf::Color::Cyan);
	texture.loadFromFile("Tileset/Map.png");
	sprite.setTexture(texture);
	sprite.setPosition(position.x, position.y);
}
コード例 #3
0
ファイル: Triforce.cpp プロジェクト: Easihh/laughing-avenger
Triforce::Triforce(Point pos) {
	isObtained = false;
	currentFrame = 0;
	position = pos;
	texture.loadFromFile("Tileset/Triforce.png");
	width = Global::TileWidth;
	height = 4;
	setupMask(&fullMask, width, height, sf::Color::Magenta);
	setupMask(&mask, width, height, sf::Color::Cyan);
	sprite.setTexture(texture);
	sprite.setPosition(position.x, position.y);
}
コード例 #4
0
WoodSwordPickUp::WoodSwordPickUp(Point pos) {
	isObtained = false;
	currentFrame = 0;
	position = pos;
	position.x -= Global::HalfTileWidth;//to center align inbetween two grid tile.
	texture.loadFromFile("Tileset/weapon1.png");
	width = Global::TileWidth;
	height = 4;
	setupMask(&fullMask, width, height, sf::Color::Magenta);
	setupMask(&mask, width, height, sf::Color::Cyan);
	sprite.setTexture(texture);
	sprite.setPosition(position.x, position.y);
}
コード例 #5
0
ThrownBoomrang::ThrownBoomrang(Point pos, Direction direction) {
	depth = 40;//less than player since we update by depth order and player must be last.
	Sound::playSound(GameSound::Boomerang);
	position = pos;
	isReturning = false;
	boomrangDir = direction;
	width=Global::TileWidth;
	height = Global::TileHeight;
	setupMask(&fullMask, width, height, sf::Color::Magenta);
	setupMask(&mask, width, height, sf::Color::Cyan);
	setupInitialPosition();
	boomrangAnimation = std::make_unique<Animation>("Boomerang", height, width, position, 8);
}
コード例 #6
0
void BasicInteractiveObject::drawForPicking(){
	if (isVisible() && isParentTreeVisible()) {
		
		glPushMatrix();
		glMultMatrixf(getLocalTransformMatrix().getPtr());
		
		if (hasmask) setupMask();
		
		depthtestbefore = glIsEnabled(GL_DEPTH_TEST);
		if (depthtestenabled && !depthtestbefore)glEnable(GL_DEPTH_TEST);
		if (!depthtestenabled && depthtestbefore)glDisable(GL_DEPTH_TEST);
		
		ofPushStyle();
		ofColor pickingColor = pickingNameToColor(pickingName);
		ofSetColor(pickingColor.r, pickingColor.g, pickingColor.b);
		_drawForPicking();
		ofPopStyle();			
		
		drawChildrenForPicking();
		
		if(depthtestenabled && !depthtestbefore){
			glDisable(GL_DEPTH_TEST);
		}
		if(!depthtestenabled && depthtestbefore){
			glEnable(GL_DEPTH_TEST);
		}
		if(hasmask) restoreMask();		
		glPopMatrix();
	}
}
コード例 #7
0
void BasicScreenObject::drawForPicking() {
  if (isvisible && _isParentTreeVisible && _isAddedToRenderer) {

    glPushMatrix();
    glMultMatrixf(getLocalTransformMatrix().getPtr());

    if (hasmask) {
      setupMask();
    }

    depthtestbefore = glIsEnabled(GL_DEPTH_TEST);
    if (depthtestenabled && !depthtestbefore)
      glEnable(GL_DEPTH_TEST);
    if (!depthtestenabled && depthtestbefore)
      glDisable(GL_DEPTH_TEST);

    drawChildrenForPicking();

    if (depthtestenabled && !depthtestbefore) {
      glDisable(GL_DEPTH_TEST);
    }
    if (!depthtestenabled && depthtestbefore) {
      glEnable(GL_DEPTH_TEST);
    }
    if (hasmask) {
      restoreMask();
    }
    glPopMatrix();
  }
}
コード例 #8
0
ファイル: plausibility.c プロジェクト: daviddao/rf-optimizer
static void setupMask(unsigned int *smallTreeMask, nodeptr p, int numsp)
{
  if(isTip(p->number, numsp))
    smallTreeMask[(p->number - 1) / MASK_LENGTH] |= mask32[(p->number - 1) % MASK_LENGTH];
  else
    {    
      nodeptr 
	q = p->next;

      /* I had to change this function to account for mult-furcating trees.
	 In this case an inner node can have more than 3 cyclically linked 
	 elements, because there might be more than 3 outgoing branches 
	 from an inner node */

      while(q != p)
	{
	  setupMask(smallTreeMask, q->back, numsp);
	  q = q->next;
	}
      
      //old code below 
      //setupMask(smallTreeMask, p->next->back, numsp);	  
      //setupMask(smallTreeMask, p->next->next->back, numsp);      
    }
}
コード例 #9
0
void BasicScreenObject::draw() {

  // int elapsed = 0;

  if ((isvisible && _isParentTreeVisible && _isAddedToRenderer) || ismask) {

    glPushMatrix();
    glMultMatrixf(getLocalTransformMatrix().getPtr());

    if (hasmask)
      setupMask();

    glBlendFunc(sfactor, dfactor);

    lightingbefore = glIsEnabled(GL_LIGHTING);
    depthtestbefore = glIsEnabled(GL_DEPTH_TEST);

    if (depthtestenabled && !depthtestbefore)
      glEnable(GL_DEPTH_TEST);
    if (!depthtestenabled && depthtestbefore)
      glDisable(GL_DEPTH_TEST);

    if (lightingenabled && !lightingbefore)
      glEnable(GL_LIGHTING);
    if (!lightingenabled && lightingbefore)
      glDisable(GL_LIGHTING);

    ofPushMatrix();
    ofPushStyle();
    ofSetColor(color.r, color.g, color.b, getCombinedAlpha());
    _draw();
    ofPopStyle();
    ofPopMatrix();

    ofPushMatrix();
    drawChildren();
    ofPopMatrix();
    ofPushMatrix();
    _drawAfterChildren();
    ofPopMatrix();

    // lighting out
    if (lightingenabled && !lightingbefore)
      glDisable(GL_LIGHTING);
    if (!lightingenabled && lightingbefore)
      glEnable(GL_LIGHTING);

    // Depthtest out
    if (depthtestenabled && !depthtestbefore)
      glDisable(GL_DEPTH_TEST);
    if (!depthtestenabled && depthtestbefore)
      glEnable(GL_DEPTH_TEST);

    if (hasmask)
      restoreMask();

    glPopMatrix();
  }
}
コード例 #10
0
ThrownArrow::ThrownArrow(Point pos,Direction direction) {
	position = pos;
	arrowDir = direction;
	width = Global::TileWidth;
	height = Global::TileHeight;
	setup();
	setupMask(&fullMask, width, height, sf::Color::Magenta);
}
コード例 #11
0
ファイル: Tile.cpp プロジェクト: Easihh/laughing-avenger
void Tile::draw(sf::RenderWindow& mainWindow){
	mainWindow.draw(sprite);
	if (!hasBeenSetup){
		loadTileImage(id);
		setupMask(&fullMask, width, height, sf::Color::Magenta);
		hasBeenSetup = true;
	}
}
コード例 #12
0
ファイル: Stalfos.cpp プロジェクト: Easihh/laughing-avenger
Stalfos::Stalfos(Point pos, bool canBeCollidedWith){
	position = pos;
	width = Global::TileWidth;
	height = Global::TileHeight;
	isCollideable = canBeCollidedWith;
	loadAnimation();
	isInvincible = false;
	healthPoint = 2;
	strength = 1;
	currentInvincibleFrame = 0;
	pushbackStep = 0;
	setupMask(&fullMask, width, height, sf::Color::Magenta);
	setupMask(&mask, width, height, sf::Color::Magenta);
	dir = Direction::None;
	getNextDirection(Direction::None);
	walkAnimIndex = 0;
	isParalyzed = false;
	currentParalyzeTime = 0;
}
コード例 #13
0
ファイル: NPC.cpp プロジェクト: Easihh/laughing-avenger
NPC::NPC(Point pos,NpcType type) {
	npcType = type;
	position = pos;
	position.x -= Global::HalfTileWidth;//to center align inbetween two grid tile.
	width = Global::TileWidth;
	height = Global::TileHeight;
	setupMask(&fullMask, width, height, sf::Color::Magenta);
	isVisible = true;
	font.loadFromFile("zelda.ttf");
	txt.setFont(font);
	loadImage();
}
コード例 #14
0
ファイル: Trap.cpp プロジェクト: Easihh/laughing-avenger
Trap::Trap(Point pos, bool canBeCollidedWith) {
	position = pos;
	width = Global::TileWidth;
	height = Global::TileHeight;
	isCollideable = canBeCollidedWith;
	loadImage();
	healthPoint = 2;
	strength = 1;
	currentInvincibleFrame = 0;
	isInvincible = true;
	pushbackStep = 0;
	setupMask(&fullMask, width, height, sf::Color::Magenta);
	setupMask(&mask, width, height, sf::Color::Cyan);
	dir = Direction::None;
	walkAnimIndex = 0;
	currentDistance = 0;
	isActive = false;
	isReturning = false;
	moveSpeed = 4;
	//Trap use fullmask size when player touch it unlike other monster like octorok who use part of monster sprite.
	mask->setSize(fullMask->getSize());
}
コード例 #15
0
ファイル: plausibility.c プロジェクト: daviddao/rf-optimizer
void plausibilityChecker(tree *tr, analdef *adef)
{
  FILE 
    *treeFile,
    *rfFile;
  
  tree 
    *smallTree = (tree *)rax_malloc(sizeof(tree));

  char 
    rfFileName[1024];
 
  /* init hash table for big reference tree */
  
  hashtable
    *h      = initHashTable(tr->mxtips * 2 * 2);
  
  /* init the bit vectors we need for computing and storing bipartitions during 
     the tree traversal */
  unsigned int 
    vLength, 
    **bitVectors = initBitVector(tr, &vLength);
   
  int
    numberOfTreesAnalyzed = 0,
    branchCounter = 0,
    i;

  double 
    avgRF = 0.0;

  /* set up an output file name */

  strcpy(rfFileName,         workdir);  
  strcat(rfFileName,         "RAxML_RF-Distances.");
  strcat(rfFileName,         run_id);

  rfFile = myfopen(rfFileName, "wb");  

  assert(adef->mode ==  PLAUSIBILITY_CHECKER);

  /* open the big reference tree file and parse it */

  treeFile = myfopen(tree_file, "r");

  printBothOpen("Parsing reference tree %s\n", tree_file);

  treeReadLen(treeFile, tr, FALSE, TRUE, TRUE, adef, TRUE, FALSE);

  assert(tr->mxtips == tr->ntips);

  printBothOpen("The reference tree has %d tips\n", tr->ntips);

  fclose(treeFile);
  
  /* extract all induced bipartitions from the big tree and store them in the hastable */
  
  bitVectorInitravSpecial(bitVectors, tr->nodep[1]->back, tr->mxtips, vLength, h, 0, BIPARTITIONS_RF, (branchInfo *)NULL,
			  &branchCounter, 1, FALSE, FALSE);
     
  assert(branchCounter == tr->mxtips - 3);   
  
  /* now see how many small trees we have */

  treeFile = getNumberOfTrees(tr, bootStrapFile, adef);

  checkTreeNumber(tr->numberOfTrees, bootStrapFile);

  /* allocate a data structure for parsing the potentially mult-furcating tree */

  allocateMultifurcations(tr, smallTree);

  /* loop over all small trees */

  for(i = 0; i < tr->numberOfTrees;  i++)
    {          
      int           
	numberOfSplits = readMultifurcatingTree(treeFile, smallTree, adef, TRUE);

      if(numberOfSplits > 0)
	{
	  unsigned int
	    entryCount = 0,
	    k,
	    j,	
	    *masked    = (unsigned int *)rax_calloc(vLength, sizeof(unsigned int)),
	    *smallTreeMask = (unsigned int *)rax_calloc(vLength, sizeof(unsigned int));

	  hashtable
	    *rehash = initHashTable(tr->mxtips * 2 * 2);

	  double
	    rf,
	    maxRF;

	  int 
	    bCounter = 0,  
	    bips,
	    firstTaxon,
	    taxa = 0;

	  if(numberOfTreesAnalyzed % 100 == 0)
	    printBothOpen("Small tree %d has %d tips and %d bipartitions\n", i, smallTree->ntips, numberOfSplits);    

	  /* compute the maximum RF distance for computing the relative RF distance later-on */
	  
	  /* note that here we need to pay attention, since the RF distance is not normalized 
	     by 2 * (n-3) but we need to account for the fact that the multifurcating small tree 
	     will potentially contain less bipartitions. 
	     Hence the normalization factor is obtained as 2 * numberOfSplits, where numberOfSplits is the number of bipartitions
	     in the small tree.
	  */
	  
	  maxRF = (double)(2 * numberOfSplits);
	  
	  /* now set up a bit mask where only the bits are set to one for those 
	     taxa that are actually present in the small tree we just read */
	  
	  /* note that I had to apply some small changes to this function to make it work for 
	     multi-furcating trees ! */

	  setupMask(smallTreeMask, smallTree->start,       smallTree->mxtips);
	  setupMask(smallTreeMask, smallTree->start->back, smallTree->mxtips);

	  /* now get the index of the first taxon of the small tree.
	     we will use this to unambiguously store the bipartitions 
	  */
	  
	  firstTaxon = smallTree->start->number;
	  
	  /* make sure that this bit vector is set up correctly, i.e., that 
	     it contains as many non-zero bits as there are taxa in this small tree 
	  */
	  
	  for(j = 0; j < vLength; j++)
	    taxa += BIT_COUNT(smallTreeMask[j]);
	  assert(taxa == smallTree->ntips);
	  
	  /* now re-hash the big tree by applying the above bit mask */
	  
	  
	  /* loop over hash table */
	  
	  for(k = 0, entryCount = 0; k < h->tableSize; k++)	     
	    {    
	      if(h->table[k] != NULL)
		{
		  entry *e = h->table[k];
		  
		  /* we resolve collisions by chaining, hence the loop here */
		  
		  do
		    {
		      unsigned int 
			*bitVector = e->bitVector; 
		      
		      hashNumberType 
			position;
		      
		      int 
			count = 0;
		      
		      /* double check that our tree mask contains the first taxon of the small tree */
		      
		      assert(smallTreeMask[(firstTaxon - 1) / MASK_LENGTH] & mask32[(firstTaxon - 1) % MASK_LENGTH]);
		      
		      /* if the first taxon is set then we will re-hash the bit-wise complement of the 
			 bit vector.
			 The count variable is used for a small optimization */
		      
		      if(bitVector[(firstTaxon - 1) / MASK_LENGTH] & mask32[(firstTaxon - 1) % MASK_LENGTH])		    
			{
			  //hash complement
			  
			  for(j = 0; j < vLength; j++)
			    {
			      masked[j] = (~bitVector[j]) & smallTreeMask[j];			     
			      count += BIT_COUNT(masked[j]);
			    }
			}
		      else
			{
			  //hash this vector 
			  
			  for(j = 0; j < vLength; j++)
			    {
			      masked[j] = bitVector[j] & smallTreeMask[j];  
			      count += BIT_COUNT(masked[j]);      
			    }
			}
		      
		      /* note that padding the last bits is not required because they are set to 0 automatically by smallTreeMask */	
		      
		      /* make sure that we will re-hash  the canonic representation of the bipartition 
			 where the bit for firstTaxon is set to 0!
		      */
		      
		      assert(!(masked[(firstTaxon - 1) / MASK_LENGTH] & mask32[(firstTaxon - 1) % MASK_LENGTH]));
		      
		      /* only if the masked bipartition of the large tree is a non-trivial bipartition (two or more bits set to 1 
			 will we re-hash it */
		      
		      if(count > 1)
			{
			  /* compute hash */
			  position = oat_hash((unsigned char *)masked, sizeof(unsigned int) * vLength);
			  position = position % rehash->tableSize;
			  
			  /* re-hash to the new hash table that contains the bips of the large tree, pruned down 
			     to the taxa contained in the small tree
			  */
			  insertHashPlausibility(masked, rehash, vLength, position);
			}		
		      
		      entryCount++;
		      
		      e = e->next;
		    }
		  while(e != NULL);
		}
	    }
	  
	  /* make sure that we tried to re-hash all bipartitions of the original tree */
	  
	  assert(entryCount == (unsigned int)(tr->mxtips - 3));
	  
	  /* now traverse the small tree and count how many bipartitions it shares 
	     with the corresponding induced tree from the large tree */
	  
	  /* the following function also had to be modified to account for multi-furcating trees ! */
	  
	  bips = bitVectorTraversePlausibility(bitVectors, smallTree->start->back, smallTree->mxtips, vLength, rehash, &bCounter, firstTaxon, smallTree, TRUE);
	  
	  /* compute the relative RF */
	  
	  rf = (double)(2 * (numberOfSplits - bips)) / maxRF;           
	  
	  assert(numberOfSplits >= bips);

	  assert(rf <= 1.0);
	  
	  avgRF += rf;
	  
	  if(numberOfTreesAnalyzed % 100 == 0)
	    printBothOpen("Relative RF tree %d: %f\n\n", i, rf);

	  fprintf(rfFile, "%d %f\n", i, rf);
	  
	  /* I also modified this assertion, we nee to make sure here that we checked all non-trivial splits/bipartitions 
	     in the multi-furcating tree whech can be less than n - 3 ! */
	  
	  assert(bCounter == numberOfSplits);         
	  
	  /* free masks and hast table for this iteration */
	  
	  rax_free(smallTreeMask);
	  rax_free(masked);
	  freeHashTable(rehash);
	  rax_free(rehash);
	  numberOfTreesAnalyzed++;
	}
    }

  printBothOpen("Number of small trees skipped: %d\n\n", tr->numberOfTrees - numberOfTreesAnalyzed);
  
  printBothOpen("Average RF distance %f\n\n", avgRF / (double)numberOfTreesAnalyzed);

  printBothOpen("Total execution time: %f secs\n\n", gettime() - masterTime);

  printBothOpen("\nFile containing all %d pair-wise RF distances written to file %s\n\n", numberOfTreesAnalyzed, rfFileName);

  

  fclose(treeFile);
  fclose(rfFile);    
  
  /* free the data structure used for parsing the potentially multi-furcating tree */

  freeMultifurcations(smallTree);
  rax_free(smallTree);

  freeBitVectors(bitVectors, 2 * tr->mxtips);
  rax_free(bitVectors);
  
  freeHashTable(h);
  rax_free(h);
}