Exemple #1
0
void Enemy::init() {
	movsps =0;
	rnd = rand()%100; 
	life = 0;
	timeThrowing = 0;
	SetWidthHeight(ENEMY_WIDTH, ENEMY_HEIGHT);
	state = STATE_LOOKRIGHT;
	timecount =0;
	direction =0;
	points = ENEMY_POINTS;
}
//sets up the player and tells the person whether they're first or second
PlayerActor::PlayerActor(dxManager* dx, bool isRed, int playerNum) : Actor(dx)
{
	animationArray = new SimpleSprite*[numAnimations];
	//get a ref to the dxmanager display device to make sprites here
	ID3D10Device* pD3DDevice = dx->getPD3DDevice();

	playerNumber = playerNum;
	dxm = dx;
	
	int numPlayerSprites = 9;

	if(isRed)
	{
		WCHAR* spriteNames[] = {L"Images/RedWalk1.png", L"Images/RedWalk2.png", L"Images/RedWalk3.png"
		, L"Images/RedJump.png", L"Images/RedWalk1Left.png", L"Images/RedWalk2Left.png"
		, L"Images/RedWalk3Left.png", L"Images/RedJumpLeft.png", L"Images/RedPoof.png"};

		//load red sprites
		for (int i = 0; i < numPlayerSprites; i ++)
		{
			dx->MakeSprite(spriteNames[i], &animationArray[i]);
			animationArray[i]->Visible = false;
		}
	}
	else
	{
		WCHAR* spriteNames[] = {L"Images/BlueWalk1.png", L"Images/BlueWalk2.png", L"Images/BlueWalk3.png"
		, L"Images/BlueJump.png", L"Images/BlueWalk1Left.png", L"Images/BlueWalk2Left.png"
		, L"Images/BlueWalk3Left.png", L"Images/BlueJumpLeft.png", L"Images/BluePoof.png"};

		for (int i = 0; i < numPlayerSprites; i ++)
		{
			dx->MakeSprite(spriteNames[i], &animationArray[i]);
			animationArray[i]->Visible = false;
		}
	}

	//make the starting sprite the standing still, right sprite.
	mySprite = animationArray[1];
	SetWidthHeight();
	facingRight = true;
	moving = false;
	movingIndex = 0;

	//gravity variables
	xVelocity = 0;
	yVelocity = 0;
	isOnGround = true;
	canMove = true;
	dead = false;
	respawnTime = 2000;
	//jumpHeld = false;
	totalTimePassed = 0.0f;
}
Exemple #3
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();

}