Jump to content

Photo

Throwing Object


  • Please log in to reply
2 replies to this topic

#1 cavthena

cavthena

    Apprentice

  • Members
  • Real Name:Clayton
  • Location:I wish I knew

Posted 18 June 2017 - 12:58 AM

I'm having a problem with an FFC that allows for throwing objects. The code works if Link throws his object left or right. The object travels until it hits the ground, which is faked by using the Y axis. However if the object is thrown up or down it will speed off at the speed of Light to oblivion and I can't figure out why.

 

FFC snip-it that handles thrown objects.

//Throw
		Game->PlaySound(LL_SFX_THROW);
		direction = Link->Dir;
		lockY = Link->Y;
		if(!bomb)
		{
			for(frames = 0; frames < 28; frames++) //31
			{	
				if(direction == DIR_UP)
					this->Y -= 3;
				else if(direction == DIR_DOWN)
					this->Y += 3;
				else if(direction == DIR_LEFT)
				{
					this->X -= 3;
					if(this->Y < lockY)
						this->Y = this->Y+(0.02*1.4*Pow(frames, 2));
				}
				else if(direction == DIR_RIGHT)
				{
					this->X += 3;
					if(this->Y < lockY)
						this->Y = this->Y+(0.02*1.4*Pow(frames, 2));
				}
			
				if((this->Y >= lockY && (direction != DIR_DOWN || direction != DIR_UP)) || frames >= 27)
					break;
			
				//Draw object.
				Screen->DrawCombo(3, this->X, this->Y, combo, this->TileWidth, this->TileHeight, cset, -1, -1, 0, 0, 0, 1, 0, true, OP_OPAQUE);
				if(this->TileWidth >= 2 && this->TileHeight >= 2)
					Screen->DrawCombo(3, this->X, this->Y, LL_SHADOW_LARGE, this->TileWidth, this->TileHeight, 11, -1, -1, 0, 0, 0, 1, 0, true, OP_TRANS);
					
				if(frames < 15)
					WaitNoAction();
			}
			
			//Create LWeapon for object.
			Game->PlaySound(SFX_POTBREAK);
			object = CreateLWeaponAt(LW_ARROW, this->X, this->Y);
			object->Damage = 2;
			object->DeadState = 10;
		}


#2 Deedee

Deedee

    Bug Frog Dragon Girl

  • Moderators
  • Real Name:Deedee
  • Pronouns:She / Her, They / Them
  • Location:Canada

Posted 18 June 2017 - 01:11 AM

(direction != DIR_DOWN || direction != DIR_UP)

You should be using && here instead of ||, since it'll always be true, cause if it's DIR_DOWN, then it's not DIR_UP, and vice versa.



#3 cavthena

cavthena

    Apprentice

  • Members
  • Real Name:Clayton
  • Location:I wish I knew

Posted 18 June 2017 - 01:28 AM

Oops yeah I'll fix that. I did find the problem, was missing a wait frame. It wasn't Math laughing at my code this time.  :doh:




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users