void CClientMeleeCollisionController::Update()
{
	for ( int iEachCollider = 0; iEachCollider < LTARRAYSIZE(m_MeleeColliders); ++iEachCollider )
	{
		UpdateCollider( m_MeleeColliders[iEachCollider] );
	}
}
Beispiel #2
0
bool Unit::Move(float dt)
{
	bool ret = true;
	C_Vec2<float> vel = currentVelocity * dt;

	//Continuous evaluation
	if (App->entityManager->continuous)
	{
		//TODO 3: Split the velocity in parts and check for the target
		
		//-------------------------------------------------------
		//Splitting the velocity into smaller pieces to check if the unit reaches the target
		float module = vel.GetModule();
		int steps = (int)floor(vel.GetModule() / targetRadius);
		C_Vec2<float> velStep = (vel.GetNormal() * targetRadius);
		C_Vec2<float> rest = vel - velStep * (float)steps;

		for (int i = 0; i < steps && ret; i++)
		{
			position.x += velStep.x;
			position.y += velStep.y;
			if (isTargetReached())
				ret = false;
		}
		if (ret)
		{
			position.x += rest.x;
			position.y += rest.y;
			if (isTargetReached())
				ret = false;
		}
		//-------------------------------------------------------
		
	}
	//Normal movement
	else
	{
		//TODO 1: Move the unit with the velocity obtained previously
		
		//------------------------------------------------------
		position.x += vel.x;
		position.y += vel.y;
		//-----------------------------------------------------
		
		if (isTargetReached())
			ret = false;
	}

	currentVelocity.position = desiredVelocity.position = position;
	UpdateCollider();

	return ret;
}
Beispiel #3
0
bool Unit::Start()
{
	currentVelocity.position = position;
	currentVelocity.y = currentVelocity.x = 1;

	currentVelocity.SetAngle(30);

	currentVelocity.Normalize();
	currentVelocity *= maxSpeed;
	
	UpdateCollider();

	texture = App->entityManager->GetTexture(type);
	return true;
}
Beispiel #4
0
void Npc::Update()
{	
	mTime = SDL_GetTicks(); // Gives time in milliseconds
	if (mHealth <= 0 && State() != AnimState::Death)
	{
		SetAnimState(AnimState::Death);
	}

	Position().x += mVelocity.x * mSpeed;
	Position().y -= mVelocity.y * mSpeed;

	UpdateAI();
	SetState();

	// Update Sprite
	mpSprite->Update();
	
	// Update Collider
	UpdateCollider();
	
	mPrevTime = mTime;	// Set previous time
}
Beispiel #5
0
void InitializePause(void (*DrawLevel)())
{
	float camX;
	Vec3 TextColor;
	
	CreatePauseSound(&BackgroundSnd, "Sounds/ShopTheme.mp3", LargeSnd);

	volumestring = (char *)MallocMyAlloc(5, sizeof(char));

	volumestring[0] = '1';
	volumestring[1] = '0';
	volumestring[2] = '0';
	volumestring[3] = (char)'%%';
	volumestring[4] = '\0';

	camX = GetCameraXPosition();
	//printf("%f\n", camX);
	pause = TRUE;
	PauseText = (Sprite *) CreateSprite("TextureFiles/Paused.png", 450, 156, 4000, 1, 1, camX, 420);

	//Background
	Vec3Set(&TextColor, 0, 0, 0);
	PauseBackground = (Sprite *) CreateSprite("TextureFiles/BlankPlatform.png", 1920, 1080, 1499, 1, 1, camX, 0);
	PauseBackground->Alpha = 0.5;
	PauseBackground->Tint = TextColor;

	//Volume sliders
	SFXSliderGuide = (Sprite *) CreateSprite("TextureFiles/VolumeSliderGuide.png", 492, 92, 4001, 1, 1, camX, 200);
	BGMSliderGuide = (Sprite *) CreateSprite("TextureFiles/VolumeSliderGuide.png", 492, 92, 4001, 1, 1, camX, 0);

	SFXSliderBack = (Sprite *) CreateSprite("TextureFiles/VolumeSliderBack.png", 552, 152, 4000, 1, 1, camX, 200);
	BGMSliderBack = (Sprite *) CreateSprite("TextureFiles/VolumeSliderBack.png", 552, 152, 4000, 1, 1, camX, 0);

	SFXSliderPos = SFXSliderGuide->Position.x - SFXSliderGuide->Width / 2 + SFXSliderGuide->Width * SFXVolume;
	BGMSliderPos = BGMSliderGuide->Position.x - BGMSliderGuide->Width / 2 + BGMSliderGuide->Width * BGMVolume;

	SFXSlider = CreateButton("TextureFiles/fox_head.png", SFXSliderPos, 200, 80, 80);
	SFXSlider->ButtonSprite->ZIndex = 4002;
	SFXSlider->ButtonCollider.width *= 3;
	SFXSlider->ButtonCollider.height = SFXSliderBack->Height;

	BGMSlider = CreateButton("TextureFiles/fox_head.png", BGMSliderPos, 0, 80, 80);
	BGMSlider->ButtonSprite->ZIndex = 4002;
	BGMSlider->ButtonCollider.width *= 3;
	BGMSlider->ButtonCollider.height = BGMSliderBack->Height;

	Vec3Set(&TextColor, 1, 1, 1);
	
	SFXText = CreateText(volumestring, (SFXSliderBack->Position.x + (SFXSliderBack->Width / 2)) + 50, 200, 100, TextColor, Left, Border);
	volumestring = VolumetoString(volumestring, SFXVolume * 100);
	volumestring = strcat(volumestring, "%");
	ChangeTextString(SFXText, volumestring);
	ChangeTextZIndex(SFXText, 4010);

	BGMText = CreateText(volumestring, (BGMSliderBack->Position.x + (BGMSliderBack->Width / 2)) + 50, 0, 100, TextColor, Left, Border);
	volumestring = VolumetoString(volumestring, BGMVolume * 100);
	volumestring = strcat(volumestring, "%");
	ChangeTextString(BGMText, volumestring);
	ChangeTextZIndex(BGMText, 4010);

	ChangeTextVisibility(SFXText);
	ChangeTextVisibility(BGMText);

	//Cheats check mark
	EnableCheats = (Sprite *) CreateSprite("TextureFiles/EnableCheats.png", 592, 106.4f, 4000, 1, 1, 180 + camX, -150);
	CheatsButton = CreateButton("TextureFiles/CheckBox.png", -250 + camX, -150, 100, 100);
	CheatsButton->ButtonSprite->ZIndex = 4000;
	UpdateCollider(&CheatsButton->ButtonCollider, 800, CheatsButton->ButtonCollider.height);
	CheatsButton->ButtonCollider.Position.x = camX + 100;
	CheckMark = (Sprite *) CreateSprite("TextureFiles/CheckMark.png", 200, 200, 4001, 1, 1, -250 + camX, -150);

	if(!Cheats)
		CheckMark->Visible = FALSE;

	//Look at mouse check mark
	EnableLookAt = (Sprite *) CreateSprite("TextureFiles/FaceMouse.png", 592, 106.4f, 4000, 1, 1, 180 + camX, -280);
	LookAtButton = CreateButton("TextureFiles/CheckBox.png", -250 + camX, -280, 100, 100);
	LookAtButton->ButtonSprite->ZIndex = 4000;
	UpdateCollider(&LookAtButton->ButtonCollider, 800, LookAtButton->ButtonCollider.height);
	LookAtButton->ButtonCollider.Position.x = camX + 100;
	LookAtCheckMark = (Sprite *) CreateSprite("TextureFiles/CheckMark.png", 200, 200, 4001, 1, 1, -250 + camX, -280);

	if(!LookAtMouse)
		LookAtCheckMark->Visible = FALSE;

	LevelToDraw = DrawLevel;

	SFXLabel = CreateText("SFX", SFXSliderBack->Position.x - SFXSliderBack->Width / 2, 200, 100, TextColor, Right, Border);
	BGMLabel = CreateText("BGM", BGMSliderBack->Position.x - BGMSliderBack->Width / 2, 0, 100, TextColor, Right, Border);
	TextAllVisible(SFXLabel);
	TextAllVisible(BGMLabel);
	ChangeTextZIndex(SFXLabel, 4003);
	ChangeTextZIndex(BGMLabel, 4003);

	// Check if we pause the map level or not
	if(GetCurrentState() == GS_MapLevel)
	{
		ResumeButton = CreateButton("TextureFiles/ResumeButton.png", -250 + camX, -400, 300, 112.5f);
		MainMenuButton = CreateButton("TextureFiles/MainMenuButton.png", 250 + camX, -400, 300, 112.5f);
	}
	else
	{
		ResumeButton = CreateButton("TextureFiles/ResumeButton.png", -400 + camX, -400, 300, 112.5f);
		RestartButton = CreateButton("TextureFiles/RestartButton.png", camX, -400, 300, 112.5f);	
		RestartButton->ButtonSprite->ZIndex = 4002;
		MainMenuButton = CreateButton("TextureFiles/GoToMapButton.png", 400 + camX, -400, 300, 112.5f);
	}

	ResumeButton->ButtonSprite->ZIndex = 4002;
	MainMenuButton->ButtonSprite->ZIndex = 4002;


	if(CurrentPlayer.PlayerActive)
	{
		CurrentPlayer.PlayerSpriteParts.Body->AnimationActive = 0;
		CurrentPlayer.PlayerSpriteParts.Body->CurrentFrame = 0;
		CurrentPlayer.PlayerSpriteParts.BlinkTimer = 0;
	}

	FoxInput_Update();
}