Пример #1
0
/*
   read level & print its map
*/
void PrintLevel( BCINT episode, BCINT mission)
{
   ReadLevelData( episode, mission);
   /* define map center */
   MapCenterX = (MapMinX + MapMaxX) / 2;
   MapCenterY = (MapMinY + MapMaxY) / 2;

   /* initialize, scale & draw the page */
   InitPage( episode, mission, ( UserLvlNm != NULL ? UserLvlNm : LevelName ));

   InitScale( MapMaxX - MapMinX, MapMaxY - MapMinY,
	      ( UserLvlNm != NULL ? UserLvlNm : LevelName ));
   if (FlagAutoZoom && (FlagName || FlagLegend))
   {
      BCINT n;
      for (n = 0; n < NumVertexes; n++)
	 /* rough & fine check for covering name or legend areas */
	 if (Vertexes[ n].y > MapCenterY)
	    if (CheckScale( Vertexes[ n].x, Vertexes[ n].y))
	       break; /* for */
      if (n < NumVertexes)
	 AdjustScale( MapMaxX - MapMinX, MapMaxY - MapMinY);
   }

   PrintMap();
   TermPage();

   /* clean up & free space */
   ForgetLevelData();
}
Пример #2
0
/*
	Calc minimum Scale according to current screen size
*/
void SetScaleMin ()
{
	float MinScaleX = (float)ScrMaxX / (float)MAP_X_SIZE;
	float MinScaleY = (float)ScrMaxY / (float)MAP_Y_SIZE;

	// Minimum scale is maximum of x and y minimum scales
	ScaleMin = MinScaleX > MinScaleY ? MinScaleX : MinScaleY;
	AdjustScale ();
}
Пример #3
0
/*
	Increment Scale and adjust ScaleNum and ScaleDen
*/
void IncScale()
{
	if ( Scale < 1.0)
		Scale = 1.0f / ((1.0f / Scale) - 1.0f);
	else
		Scale = Scale + 1.0f;

	// Check Scale is not too big
	AdjustScale();
}
Пример #4
0
/*
	Decrement Scale and adjust ScaleNum and ScaleDen
*/
void DecScale()
{
	if (Scale <= 1.0)
		Scale = 1.0f / ((1.0f / Scale) + 1.0f);
	else
		Scale = Scale - 1.0f;

	// Check scale is not too small
	AdjustScale();
}
Пример #5
0
HRESULT KRLTarget::Show(int nForceRelationType)
{
	int nRetCode = false;
	HRESULT hr = E_FAIL;
	HRESULT hrResult = E_FAIL;
    KRLMonoAnimationParam MonoAnimationParam;
	RL_FORCE_RELATION nRLForceRelation = ForceRelationGWToRL(nForceRelationType);
    IKG3DModel* p3DModel = NULL;

	nRetCode = nRLForceRelation >= 0 && nRLForceRelation < RL_FORCE_RELATION_COUNT;
	KGLOG_PROCESS_ERROR(nRetCode);

	if (m_nRLForceRelation != nRLForceRelation)
	{
		if (m_ap3DModel[nRLForceRelation])
		{
			hr = Hide();
			KGLOG_COM_PROCESS_ERROR(hr);
		}

		m_nRLForceRelation = nRLForceRelation;

        p3DModel = m_ap3DModel[m_nRLForceRelation];
		KG_PROCESS_SUCCESS(p3DModel == NULL);

        hr = KModel::SetPosition(p3DModel, m_vPosition);
        KGLOG_COM_PROCESS_ERROR(hr);

        hr = KModel::AppendRenderEntity(m_pRLScene->m_p3DScene, p3DModel, FALSE);
		KGLOG_COM_PROCESS_ERROR(hr);

        MonoAnimationParam.dwPlayType = ENU_ANIMATIONPLAY_ONCE;
        MonoAnimationParam.nTrackType = ANICTL_PRIMARY;
        MonoAnimationParam.fSpeed = 1.0f;
        MonoAnimationParam.nOffsetTime = 0;
        MonoAnimationParam.dwTweenTime = 0;
        MonoAnimationParam.pUserdata = NULL;
        MonoAnimationParam.szFilePath = _T("");
        MonoAnimationParam.fStartTime = g_pRL->m_fTime;

		hr = KModel::PlayMonoAnimation(p3DModel, MonoAnimationParam);
		KGLOG_COM_PROCESS_ERROR(hr);
	}

	hr = AdjustScale();
	KGLOG_COM_PROCESS_ERROR(hr);

Exit1:
	hrResult = S_OK;
Exit0:
	return hrResult;
}
Пример #6
0
Trap::Trap(dxManager* dx, char* name, float xPos, float yPos) : ICollidable(dx)
{

    //get a ref to the dxmanager display device to make sprites here
    ID3D10Device* pD3DDevice = dx->getPD3DDevice();

    activated = false;
    startX = xPosition = xPos;
    startY = yPosition = yPos;
    isDangerous = true;
    moveDist = 0;
    crossHairCountdown = 0;
    tileSize = 1; //how wide the tiles are; will be set if important using setTileSize
    moveDirection = 1;
    //if it's a saw...
    if(strcmp(name,"Images/saw1.png") == 0)
    {
        numAnimations = 2;
        animationArrayT = new SimpleSprite*[numAnimations];
        trapType = 0;
        stepTime = 10;

        WCHAR* spriteNames[] = {L"Images/saw1.png", L"Images/saw2.png"};

        //load saw sprites
        for (int i = 0; i < numAnimations; i ++)
        {
            dx->MakeSprite(spriteNames[i], &animationArrayT[i]);
            animationArrayT[i]->Visible = false;
            animationArrayT[i]->SetPosition(xPos, yPos, 0);
        }
        mySprite = animationArrayT[0];
        mySprite->Visible = true;
        moveDist = 2;
        SetWidthHeight();
    }

    //if its a flame trap
    else if(strcmp(name,"Images/flame1.png") == 0)
    {
        numAnimations = 2;
        animationArrayT = new SimpleSprite*[numAnimations];
        trapType = 1;
        //stepTime = 3000; //3 seconds between switching states; currently being set in maploader instead

        WCHAR* spriteNameA[] = {L"Images/flame1.png", L"Images/flame2.png"};

        //load sprites
        for (int i = 0; i < numAnimations; i ++)
        {
            dx->MakeSprite(spriteNameA[i], &animationArrayT[i]);
            animationArrayT[i]->Visible = false;
            animationArrayT[i]->SetPosition(xPos, yPos, 0);
        }
        mySprite = animationArrayT[0];
        mySprite->Visible = true;
        isDangerous = false; //starts as off
        SetWidthHeight();
    }
    else if(strcmp(name,"Images/Turret.png") == 0)
    {
        numAnimations = 1;
        animationArrayT = new SimpleSprite*[numAnimations];
        trapType = 3;
        stepTime = 3000; //3 seconds between switching states; currently being set in maploader instead

        WCHAR* spriteNameA[] = {L"Images/Turret.png"};

        //load sprites
        for (int i = 0; i < numAnimations; i ++)
        {
            dx->MakeSprite(spriteNameA[i], &animationArrayT[i]);
            animationArrayT[i]->Visible = false;
            animationArrayT[i]->SetPosition(xPos, yPos, 0);
        }
        mySprite = animationArrayT[0];
        mySprite->Visible = true;
        AdjustScale(2.0f,2.0f);
        isDangerous = false; //turret doesnt damage, but needs to be true to do collide

        SetWidthHeight();
    }
    else if(strcmp(name,"crosshairs") == 0)
    {
        numAnimations = 5;
        animationArrayT = new SimpleSprite*[numAnimations];
        trapType = 4;
        stepTime = 200; //0.2 seconds between switching frames

        WCHAR* spriteNameA[] = {L"Images/crosshairs.png",L"Images/crosshairs2.png",L"Images/explode1.png",L"Images/explode2.png",L"Images/explode3.png"};

        //load sprites
        for (int i = 0; i < numAnimations; i ++)
        {
            dx->MakeSprite(spriteNameA[i], &animationArrayT[i]);
            animationArrayT[i]->Visible = false;
            animationArrayT[i]->SetPosition(xPos, yPos, 0);
        }
        mySprite = animationArrayT[0];
        mySprite->Visible = false; //starts out invisible
        isDangerous = false; //starts out inactive
        SetWidthHeight();
    }
    else if(strcmp(name,"Images/spikes.png") == 0)
    {
        numAnimations = 1;
        animationArrayT = new SimpleSprite*[numAnimations];
        trapType = 2;
        //stepTime = 3000; //3 seconds between switching states; currently being set in maploader instead

        WCHAR* spriteNameA[] = {L"Images/spikes.png"};

        //load sprites
        for (int i = 0; i < numAnimations; i ++)
        {
            dx->MakeSprite(spriteNameA[i], &animationArrayT[i]);
            animationArrayT[i]->Visible = false;
            animationArrayT[i]->SetPosition(xPos, yPos, 0);
        }
        mySprite = animationArrayT[0];
        mySprite->Visible = true;
        SetWidthHeight();
    }
    else if(strcmp(name,"Images/spikesHang.png") == 0)
    {
        numAnimations = 1;
        animationArrayT = new SimpleSprite*[numAnimations];
        trapType = 2;
        //stepTime = 3000; //3 seconds between switching states; currently being set in maploader instead

        WCHAR* spriteNameA[] = {L"Images/spikesHang.png"};

        //load sprites
        for (int i = 0; i < numAnimations; i ++)
        {
            dx->MakeSprite(spriteNameA[i], &animationArrayT[i]);
            animationArrayT[i]->Visible = false;
            animationArrayT[i]->SetPosition(xPos, yPos, 0);
        }
        mySprite = animationArrayT[0];
        mySprite->Visible = true;
        SetWidthHeight();
    }

    movingIndex = 0;
    prevTime = GetCurrentTime();

}