Ejemplo n.º 1
0
uint8_t MD_PZone::getFirstChar(void)
// load the first char into the char buffer
// return 0 if there are no characters
{
	uint8_t len = 0;

	PRINTS("\ngetFirst");

	// initialise pointers and make sure we have a good string to process
	_pCurChar = _pText;
	if ((_pCurChar == NULL) || (*_pCurChar == '\0'))
	{
		_endOfText = true;
		return(0);
	}
	_endOfText = false;
	if (SFX(SCROLL_RIGHT))
		_pCurChar += strlen(_pText) - 1;

	// good string, get the first char into the current buffer
	len = makeChar(*_pCurChar);

	if (SFX(SCROLL_RIGHT))
		reverseBuf(_cBuf, len);
	
	moveTextPointer();

	return(len);
}
Ejemplo n.º 2
0
ItemEffect* getItemEffect(int itemID)
{
    const itemdata& data=itemsbuf[itemID];
    switch(data.family)
    {
    case itype_clock:
        return new ClockEffect(Link, data.misc1);
        
    case itype_nayruslove:
        if(get_bit(quest_rules,qr_MORESOUNDS))
        {
            return new NayrusLoveEffect(Link, data.misc1,
              sfxMgr.getSFX(data.usesound), sfxMgr.getSFX(data.usesound+1));
        }
        else
            return new NayrusLoveEffect(Link, data.misc1, SFX(0), SFX(0));
    }
    
    return 0;
}
Ejemplo n.º 3
0
uint8_t MD_PZone::getNextChar(void)
// load the next char into the char buffer
// return 0 if there are no characters
{
	uint8_t len = 0;

	PRINTS("\ngetNext ");

	if (_endOfText)
	return(0);

	len = makeChar(*_pCurChar);

	if (SFX(SCROLL_RIGHT))
	reverseBuf(_cBuf, len);

	moveTextPointer();

	return(len);
}
Ejemplo n.º 4
0
void MD_PZone::moveTextPointer(void)
// This method works when increment is done AFTER processing the character
// the _endOfText flag is set as a look ahead (ie, when the last character
// is still valid)
// We need to move a pointer forward or back, depending on the way we are
// travelling through the text buffer.
{
	PRINTS("\nMovePtr");

	if (SFX(SCROLL_RIGHT))
	{
		PRINTS(" --");
		_endOfText = (_pCurChar == _pText);
		_pCurChar--;
	}
	else
	{
		PRINTS(" ++");
		_pCurChar++;
		_endOfText = (*_pCurChar == '\0');
	}

	PRINT(": endOfText ", _endOfText);
}
Ejemplo n.º 5
0
void Player::simulation() {
	if( !onGround )
		speed.y += 9.8;
	
	/*if (timeLeftToShoot > 0)
		timeLeftToShoot -= 1/70;*/

	double legsPos = position.y + sizeBox.y/2;

	//CHECK BOUNDS
	if (position.x > 64*800-64) {
		position.x = 64*800-64;
		speed.x = min(.0f, speed.x);
	}
	if (position.x < -64*800+64) {
		position.x = 64-64*800;
		speed.x = max(.0f, speed.x);
	}


	double mhRight	= land->getHeightAtX(position.x+sizeBox.x/2);
	double mhRight2 = land->getHeightAtX(position.x+sizeBox.x/2+speed.x/10);
	double mhLeft	= land->getHeightAtX(position.x-sizeBox.x/2);
	double mhLeft2	= land->getHeightAtX(position.x-sizeBox.x/2+speed.x/10);
	double mhCenter = land->getHeightAtX(position.x);

	double maxHeight = double(ofGetScreenHeight()) - max( mhCenter, max( mhLeft, mhRight ));

	//check blocks (X)
	if ((mhLeft2 > mhCenter) && (speed.x < 0) && (legsPos > double(ofGetScreenHeight())-mhLeft2))
	{
		speed.x = 0;
	}
	else 
	if ((mhRight2 > mhCenter) && (speed.x > 0) && (legsPos > double(ofGetScreenHeight())-mhRight2))
	{
		speed.x = 0;
	}
	
	if (legsPos >= maxHeight) {
		if( speed.y > 0 )
			speed.y = 0;
		position.y = maxHeight - sizeBox.y/2;
		onGround = true;
		friction = 0.8f;
	} else {
		onGround = false;
		friction = 0.999f;
	}
	
	position = position + (speed/10);
	speed *= friction;
	
	if (abs(speed.length()) > 1.0f && timeNextWalkSound <= 0 && onGround)
	{
		timeNextWalkSound = 35.0f/(speed.x+100);
		SFX(iSfxWalkDirt + int(ofRandom(0,2))).play();
	}
	if (!onGround)
		timeNextWalkSound = 0;
	else
		timeNextWalkSound -= 1/ofGetFrameRate();

	if(isLive) {
		if(health <= 0) kill();
	}
}
Ejemplo n.º 6
0
void Player::takeDamge(int dmg, bool hostile)
{
	health-=dmg;
	SFX(iSfxPain + int(ofRandom(0,2))).play();
}