CEnemyDemon::CEnemyDemon()
{
    COptions *op = COptions::GetInstance();
    CSGD_EventSystem *pES = CSGD_EventSystem::GetInstance();

    SetHP(25 * op->GetDifficulty());
    SetVelX(100.0f * op->GetDifficulty());
    SetVelY(100.0f * op->GetDifficulty());
    SetXFlip(-1);
    SetHeight(64);
    SetWidth(64);
    SetPosX(500);
    SetPosY(500);
    SetType(ACTOR_ENEMY);
    SetPower(5 * op->GetDifficulty());
    SetScoreValue(100 * op->GetDifficulty());
    SetHit(false);

    rEnemyRect.top = 65;
    rEnemyRect.bottom = 123;
    rEnemyRect.left = 0;
    rEnemyRect.right = 60;

    m_nSoundID = CSGD_WaveManager::GetInstance()->LoadWave("Resource/sounds/JoA_Bark.wav");
    CSGD_WaveManager::GetInstance()->SetVolume(m_nSoundID,COptions::GetInstance()->GetSFXVolume()-40);


}
CObject_Appletree::CObject_Appletree(int GHandle, double x, double y, int Width, int Height, unsigned int Type) : CObject_Enemy(GHandle, x, y, Width, Height, Type)
{
	GraphHandle = ResourceManager::getResourceManager()->GetRes(GHandle);
	Stand	= new CSprite(GetResourceWithKey(IMAGE_OBJECT_APPLETREE_STAND), 1, 0, 0, 1, 1, 358, 482, 100, TRUE);
	Hit		= new CSprite(GetResourceWithKey(IMAGE_OBJECT_APPLETREE_HIT), 1, 0, 0, 1, 1, 358, 482, 100, TRUE);
	Death	= new CSprite(GetResourceWithKey(IMAGE_OBJECT_APPLETREE_DEAD), 7, 0, 0, 7, 1, 2506, 482, 65, TRUE);
	Poison	= new CSprite(GetResourceWithKey(IMAGE_OBJECT_APPLETREE_POISON), 8, 0, 0, 8, 1, 3200, 480, 120, TRUE);
	Apple[0]= new CSprite(GetResourceWithKey(IMAGE_OBJECT_APPLE_BREAK), 6, 0, 0, 6, 1, 696, 108, 50, TRUE);
	Apple[1]= new CSprite(GetResourceWithKey(IMAGE_OBJECT_APPLE_BREAK), 6, 0, 0, 6, 1, 696, 108, 50, TRUE);
	Break[0]= new CSprite(GetResourceWithKey(IMAGE_OBJECT_APPLE_BREAK), 6, 0, 0, 6, 1, 696, 108, 64, TRUE);
	Break[1]= new CSprite(GetResourceWithKey(IMAGE_OBJECT_APPLE_BREAK), 6, 0, 0, 6, 1, 696, 108, 64, TRUE);
	Boom[0]	= new CSprite(GetResourceWithKey(IMAGE_OBJECT_APPLE_BOOM), 7, 0, 0, 7, 1, 1610, 230, 128, TRUE);
	Boom[1]	= new CSprite(GetResourceWithKey(IMAGE_OBJECT_APPLE_BOOM), 7, 0, 0, 7, 1, 1610, 230, 128, TRUE);

	b_left = true;
	b_right = false;

	Center = WorldX + 133;
	
	RecognizeRange = 550;
	AttackRange = 225;
	//PatrolRange = -1;

	SetMove(false);
	SetAttack(false);
	SetHit(false);

	AttackDelay = 270;
	AttackCount = -1;
	HeroKnockbackCount = -1;
	KnockbackCount = -1;
	HitCount = -1;

	Stat_ST = 40;
	Damage = Stat_ST * 0.5f;
	Stat_HP = 8;
	MaxHP = Stat_HP * 3;
	HP = MaxHP;
	Speed = 0;

	Exp = 0;

	tempY[0] = (int)fDrawY;
	tempY[1] = (int)fDrawY;
	b_apple[0] = false;
	b_apple[1] = false;

}
CEnemyPsycrow::CEnemyPsycrow()
{
	CSGD_EventSystem *pES = CSGD_EventSystem::GetInstance();
	CSGD_TextureManager *pTM = CSGD_TextureManager::GetInstance();
	COptions *op = COptions::GetInstance();

	pES->RegisterClient("psycrow fire", this);
	pES->RegisterClient("state transition 1", this);
	pES->RegisterClient("state transition 2", this);
	pES->RegisterClient("state transition 3", this);
	pES->RegisterClient("state transition 4", this);

	m_nState = PSYCROW_STATE1;
	m_nSoundID = CSGD_WaveManager::GetInstance()->LoadWave("Resource/sounds/JoA_Squawk.wav");
	CSGD_WaveManager::GetInstance()->SetVolume(m_nSoundID, op->GetSFXVolume() - 40);
	m_fFireReady = 5.0f;
	m_fHitTimer = 0.4f;
	m_nOffset = 0;
	bIsFired = false;
	m_fFiringTimer = 0.5f;
	m_fSineFloat = 3.14f;
	m_nColor = 255;
	m_nScale = 1.5f;

	SetHP(250 * op->GetDifficulty());
	SetVelX(75 * op->GetDifficulty());
	SetVelY(0.0f);
	SetXFlip(-1);
	SetHeight(84);
	SetWidth(70);
	SetPosX(320);
	SetPosY(240);
	SetPower(0);
	SetType(ACTOR_ENEMY);
	SetScoreValue(1000 * op->GetDifficulty());
	SetHit(false);
	pBullet = NULL;

	bIsFiring = false;

}
CEnemyBusiness::CEnemyBusiness()
{
	CSGD_EventSystem *pES = CSGD_EventSystem::GetInstance();
	CSGD_TextureManager *pTM = CSGD_TextureManager::GetInstance();
	COptions *op = COptions::GetInstance();
	CSGD_WaveManager *pWM = CSGD_WaveManager::GetInstance();

	pES->RegisterClient("businessman fire", this);

	SetHP(50 *op->GetDifficulty());
	SetVelX(-50.0f * op->GetDifficulty());
	SetVelY(0.0f);
	SetXFlip(-1);
	SetHeight(63);
	SetWidth(86);
	SetPosX(1000);
	SetPosY(220);
	SetPower(0);
	SetType(ACTOR_ENEMY);
	SetScoreValue(200 * op->GetDifficulty());
	SetHit(false);
	pBullet = NULL;

	bIsFiring = false;

	m_fFireReady = 5.0f;
	m_fHitTimer = 1.0f;
	m_nOffset = 0;
	m_fFiringTimer = 1.0f;

	rEnemyRect.top = 18;
	rEnemyRect.bottom = 61;
	rEnemyRect.left = 2;
	rEnemyRect.right = 54;

	m_nSoundID = pWM->LoadWave("Resource/sounds/JoA_Scream.wav");
	pWM->SetVolume(m_nSoundID,op->GetSFXVolume() - 25);
	

}
void CEnemyBusiness::Update(float fElapsedTime)
{

	CSGD_ObjectManager *pOM = CSGD_ObjectManager::GetInstance();
	CSGD_MessageSystem *pMS = CSGD_MessageSystem::GetInstance();
	CSGD_EventSystem *pES= CSGD_EventSystem::GetInstance();
	CGame *theGame = CGame::GetInstance();

	SetPosX(GetPosX() + GetVelX() * fElapsedTime);
	SetPosY(GetPosY() + GetVelY() * fElapsedTime);

	rCollisionRect.left = GetPosX();
	rCollisionRect.right = GetPosX() + GetWidth();
	rCollisionRect.top = GetPosY();
	rCollisionRect.bottom = GetPosY() + GetHeight();
	SetCollisionRect(rCollisionRect);

	DWORD timer = GetTickCount();

	if (GetHit())
	{
		m_nOffset = 32;
		m_fHitTimer = 1.0f;
		SetVelX(0);
		rEnemyRect.left = 442;
		rEnemyRect.right = 463;
	}

	else if (!GetHit() && m_fHitTimer <= 0)
	{
		m_nOffset = 0;
		m_fFireReady -= fElapsedTime;
		SetVelX(GetXFlip() * -100);
		if (timer % 700 <= 100)
		{
			rEnemyRect.left = 2;
			rEnemyRect.right = 54;
		}
		else if (timer % 700 > 100 && timer % 700 <= 200)
		{
			rEnemyRect.left = 58;
			rEnemyRect.right = 115;
		}
		else if (timer % 700 > 200 && timer % 700 <= 300)
		{
			rEnemyRect.left = 119;
			rEnemyRect.right = 163;
		}
		else if (timer % 700 > 300 && timer % 700 <= 400)
		{
			rEnemyRect.left = 700;
			rEnemyRect.right = 753;
		}
		else if (timer % 700 > 400 && timer % 700 <= 500)
		{
			rEnemyRect.left = 756;
			rEnemyRect.right = 795;
		}
		else if (timer % 700 > 500 && timer % 700 <= 600)
		{
			rEnemyRect.left = 798;
			rEnemyRect.right = 850;
		}
		else if (timer % 700 > 600)
		{
			rEnemyRect.left = 853;
			rEnemyRect.right = 899;
		}
	}

	if (m_fFireReady <=0 && !GetHit() && GetHP() > 0)
		pES->SendEvent("businessman fire",&fElapsedTime);

	if (bIsFiring)
	{
		rEnemyRect.left = 329;
		rEnemyRect.right = 397;
		m_fFiringTimer -= fElapsedTime;
		SetVelX(0);
	}

	if (m_fFiringTimer <= 0)
	{
		bIsFiring = false;
		m_fFiringTimer = 1.0f;
	}

	if (GetPosX() < -32)
	{
		SetVelX(abs(GetVelX() * -1));
		SetXFlip(-abs(GetXFlip() * -1));
	}
	else if (GetPosX() > 640)
	{
		SetVelX(-abs(GetVelX() * -1));
		SetXFlip(abs(GetXFlip() * -1));
	}
	else if (GetPosY() > 480)
		SetVelY(-abs(GetVelY() * -1));
	else if (GetPosY() < -32)
		SetVelY(abs(GetVelY() * -1));

	m_fHitTimer -= fElapsedTime;

	SetHit(false);

	if (GetHP() <= 0)
	{
		CSGD_WaveManager::GetInstance()->Play(m_nSoundID,0);

		CSGD_EventSystem::GetInstance()->SendEvent("spawn powerups", NULL);
		pMS->SendMsg(new CDestroyMessage(this));

	}

}
void CEnemyDemon::Update(float fElapsedTime)
{

    CSGD_ObjectManager *pOM = CSGD_ObjectManager::GetInstance();
    CSGD_MessageSystem *pMS = CSGD_MessageSystem::GetInstance();
    CGame *theGame = CGame::GetInstance();

    SetPosX(GetPosX() + GetVelX() * fElapsedTime);
    SetPosY(GetPosY() + GetVelY() * fElapsedTime);

    rCollisionRect.left = GetPosX();
    rCollisionRect.right = GetPosX() + GetWidth();
    rCollisionRect.top = GetPosY();
    rCollisionRect.bottom = GetPosY() + GetWidth();
    SetCollisionRect(rCollisionRect);

    if (GetPosX() < -32)
    {
        SetVelX(abs(GetVelX() * -1));
        SetXFlip(-abs(GetXFlip() * -1));
    }
    else if (GetPosX() > 640)
    {
        SetVelX(-abs(GetVelX() * -1));
        SetXFlip(abs(GetXFlip() * -1));
    }
    else if (GetPosY() > 480)
        SetVelY(-abs(GetVelY() * -1));
    else if (GetPosY() < -32)
        SetVelY(abs(GetVelY() * -1));


    DWORD timer = GetTickCount();

    if (abs(GetPosX() - CPlayerCharacter::GetInstance()->GetPosX()) < 128 && abs(GetPosY() - CPlayerCharacter::GetInstance()->GetPosY()) < 128)
        bIsClose = true;
    else
        bIsClose = false;

    if (!bIsClose)
    {
        if (timer % 525 <= 75)
        {
            rEnemyRect.left = 0;
            rEnemyRect.right = 48;
        }
        else if (timer % 525 > 75 && timer % 525 <= 150)
        {
            rEnemyRect.left = 51;
            rEnemyRect.right = 90;
        }
        else if (timer % 525 > 150 && timer % 525 <= 225)
        {
            rEnemyRect.left = 93;
            rEnemyRect.right = 138;
        }
        else if (timer % 525 > 225 && timer % 525 <= 300)
        {
            rEnemyRect.left = 142;
            rEnemyRect.right = 185;
        }
        else if (timer % 525 > 300 && timer % 525 <= 375)
        {
            rEnemyRect.left = 188;
            rEnemyRect.right = 234;
        }
        else if (timer % 525 > 375 && timer % 525 <= 450)
        {
            rEnemyRect.left = 237;
            rEnemyRect.right = 282;
        }
        else if (timer % 525 > 450)
        {
            rEnemyRect.left = 286;
            rEnemyRect.right = 332;
        }
    }
    else if (bIsClose)
    {
        if (timer % 600 <= 75)
        {
            rEnemyRect.left = 335;
            rEnemyRect.right = 372;
        }
        else if (timer % 600 > 75 && timer % 600 <= 150)
        {
            rEnemyRect.left = 375;
            rEnemyRect.right = 407;
        }
        else if (timer % 600 > 150 && timer % 600 <= 225)
        {
            rEnemyRect.left = 410;
            rEnemyRect.right = 445;
        }
        else if (timer % 600 > 225 && timer % 600 <= 300)
        {
            rEnemyRect.left = 448;
            rEnemyRect.right = 481;
        }
        else if (timer % 600 > 300 && timer % 600 <= 375)
        {
            rEnemyRect.left = 484;
            rEnemyRect.right = 515;
        }
        else if (timer % 600 > 375 && timer % 600 <= 450)
        {
            rEnemyRect.left = 518;
            rEnemyRect.right = 554;
            CSGD_WaveManager::GetInstance()->Play(m_nSoundID,0);

        }
        else if (timer % 600 > 450 && timer % 600 <= 525)
        {
            rEnemyRect.left = 558;
            rEnemyRect.right = 592;
        }
        else if (timer % 600 > 525)
        {
            rEnemyRect.left = 595;
            rEnemyRect.right = 636;
        }
    }
    SetHit(false);

    if (GetHP() <= 0)
    {
        CSGD_EventSystem::GetInstance()->SendEvent("spawn powerups", NULL);
        pMS->SendMsg(new CDestroyMessage(this));
    }

}
Esempio n. 7
0
//-------------------------------------------------------------------
// 関数名 : キーボード更新
//
// 引数   : なし
// 返り値 : なし
//-------------------------------------------------------------------	
void Player::ControlKeyBorad( void )
{
	//--  移動 前  --//	
	if( GET_INPUT_KEYBOARD()->GetPress( DIK_W ) == true )
	{
		pad_move_._y = 1 ;
	}

	//--  移動 後  --//
	if( GET_INPUT_KEYBOARD()->GetPress( DIK_S ) == true )
	{
		pad_move_._y = -1 ;
	}

	//--  移動 左  --//
	if( GET_INPUT_KEYBOARD()->GetPress( DIK_A ) == true )
	{
		pad_move_._x = -1 ;
	}

	//--  移動 右  --//
	if( GET_INPUT_KEYBOARD()->GetPress( DIK_D ) == true )
	{
		pad_move_._x = 1 ;
	}

	if( GET_INPUT_MOUSE()->GetTrigger( InputMouse::MOUSE_KEY::RIGHT ) == true )
	{
		if( state_ != STATE::AIM )
		{
			anime_ = ANIME::WAIT ;
			state_ = STATE::AIM ;
		}
		else
		{
			state_ = STATE::WAIT ;
		}
	}

	//--  エイム  --//
	if( state_ == STATE::AIM )
	{
		//--  アクション  --//
		if( GET_INPUT_KEYBOARD()->GetTrigger( DIK_SPACE ) == true )
		{
			if( weapon_ == WEAPON::LAUNCHER )
			{
				if( launcher_timer_ > 420 )
				{
					action_ = true ;
					launcher_timer_ = 0 ;
				}
			}
			else if( weapon_ == WEAPON::HOE )
			{
				action_ = true ;
			}
		}

		//--  アクション  --//
		if( GET_INPUT_KEYBOARD()->GetPress( DIK_SPACE ) == true )
		{
			if( weapon_ == WEAPON::GUN )
			{
				if( gun_timer_ > 10 )
				{
					action_ = true ;
					gun_timer_ = 0 ;
				}
			}
		}
	}

	//--  武器取り出し  --//
	if( GET_INPUT_KEYBOARD()->GetTrigger( DIK_E ) == true )
	{
		take_out_ = true ;
	}

	if( GET_INPUT_KEYBOARD()->GetTrigger( DIK_7 ) == true )
	{
		SetHit( true );
	}
}
Esempio n. 8
0
int main ( int argc, char** argv )
{
    // initialize SDL video
    if ( SDL_Init( SDL_INIT_VIDEO ) < 0 )
    {
        printf( "Unable to init SDL: %s\n", SDL_GetError() );
        return 1;
    }

    // make sure SDL cleans up before exit
    atexit(SDL_Quit);

    // create a new window
    SDL_Surface* screen = SDL_SetVideoMode(800, 600, 24,
                                           SDL_SWSURFACE);
    if ( !screen )
    {
        printf("Unable to set 640x480 video: %s\n", SDL_GetError());
        return 1;
    }

    SDL_WM_SetCaption("Raw Viewer","Raw Viewer");

    // load an image
    SDL_Surface* buffer = SDL_CreateRGBSurface(SDL_SWSURFACE,600,524,32,0,0,0,0);

    fl=fopen(argv[1],"rb");
    fseek(fl,0,SEEK_END);
    Max=ftell(fl);

    Render(buffer,rejim,WIDT,HIGH,DX);


    // program main loop
    bool done = false;
    while (!done)
    {
        // message processing loop
        FlushHits();
        SDL_Event event;
        while (SDL_PollEvent(&event))
        {
            // check for messages
            switch (event.type)
            {
                // exit if the window is closed
            case SDL_QUIT:
                done = true;
                break;

                // check for keypresses
            case SDL_KEYDOWN:
            {
                SetHit(event.key.keysym.sym);
                break;
            }
            } // end switch
        } // end of message processing
        UpdateKeyboard();

        // DRAWING STARTS HERE

        if (KeyDown(SDLK_ESCAPE))
            done=true;


        // clear screen
        SDL_FillRect(screen, 0, SDL_MapRGB(screen->format, 0, 0, 0));

        SDL_BlitSurface(buffer,0,screen,0);

        lineColor(screen,0,524,600,524,0xFFFFFFFF);
        lineColor(screen,600,0,600,524,0xFFFFFFFF);

        char buf[255];
        sprintf(buf,"Offset:%X",Offs);
        stringColor(screen,700,10,buf,0xFFFFFFFF);
        sprintf(buf,"Width:%d",WIDT);
        stringColor(screen,700,20,buf,0xFFFFFFFF);

        rectangleColor(screen,663,7,670,509,0xFF0000FF);
        FillRect(screen,665,9,4,501*(Offs/(float)Max),0x00FF00);//rectangleColor(screen,664,8,669,8+500*Offs/Max,0x00FF00FF);
        if (WIDT>150)
        {
            rectangleColor(screen,9,549,511,556,0xFF0000FF); //Rect  9,549,502,7,0
            FillRect(screen,10,550,500*DX/(WIDT-150),5,0x00FF00);//	Rect  10,550,500*(Float(DX)/Float(widt-150)),5,1
        }

        switch (rejim)
        {
        case 1:
            sprintf(buf,"1 Bit mode");
            break;
        case 2:
            sprintf(buf,"2 Bit mode");
            break;
        case 3:
            sprintf(buf,"4 Bit mode");
            break;
        case 4:
            sprintf(buf,"8 Bit mode");
            break;
        case 5:
            sprintf(buf,"16 Bit mode RGBA5551");
            break;
        case 6:
            sprintf(buf,"16 Bit mode RGBA4444");
            break;
        case 7:
            sprintf(buf,"16 Bit mode RGB565");
            break;
        case 8:
            sprintf(buf,"16 Bit mode BGRA5551");
            break;
        case 9:
            sprintf(buf,"16 Bit mode BGRA4444");
            break;
        case 10:
            sprintf(buf,"16 Bit mode BGR565");
            break;
        case 11:
            sprintf(buf,"24 Bit mode RGB");
            break;
        case 12:
            sprintf(buf,"24 Bit mode BGR");
            break;
        }

        stringColor(screen,5,580,buf,0xFFFFFFFF);


        if (KeyHit(SDLK_SPACE))
        {
            setka=!setka;
            Render(buffer,rejim,WIDT,HIGH,DX);
        }



        if (KeyDown(SDLK_PERIOD))
        {
            WIDT++;
            DX=0;
            if (WIDT<1)
                WIDT =1;
            Render(buffer,rejim,WIDT,HIGH,DX);
        }
        if (KeyDown(SDLK_COMMA))
        {
            WIDT--;
            DX=0;
            if (WIDT<1)
                WIDT =1;
            Render(buffer,rejim,WIDT,HIGH,DX);
        }
        if (KeyDown(SDLK_SEMICOLON))
        {
            WIDT+=10;
            DX=0;
            if (WIDT<1)
                WIDT =1;
            Render(buffer,rejim,WIDT,HIGH,DX);
        }
        if (KeyDown(SDLK_l))
        {
            WIDT-=10;
            DX=0;
            if (WIDT<1)
                WIDT =1;
            Render(buffer,rejim,WIDT,HIGH,DX);
        }
        if (KeyDown(SDLK_LEFTBRACKET))
        {
            WIDT+=100;
            DX=0;
            if (WIDT<1)
                WIDT =1;
            Render(buffer,rejim,WIDT,HIGH,DX);
        }
        if (KeyDown(SDLK_p))
        {
            WIDT-=100;
            DX=0;
            if (WIDT<1)
                WIDT =1;
            Render(buffer,rejim,WIDT,HIGH,DX);
        }



        if (MouseDown(1))
        {

            if (MouseX()>663 && MouseX()<670 && MouseY()>7 && MouseY()<507)
            {
                Offs=(float)Max*((MouseY()-8.0))/500.0;
                Render(buffer,rejim,WIDT,HIGH,DX);
            }


            if (WIDT>150)
            {
                if (MouseX()>9 && MouseX()<511 && MouseY()>549 && MouseY()<556)
                {
                    DX=(WIDT -150)*((MouseX()-10)/500.0);
                    Render(buffer,rejim,WIDT,HIGH,DX);
                }
            }
        }
        if (MouseDown(3))
        {
            HIGH=MouseY()/4;
            if (HIGH<1)
                HIGH=1;

            if (HIGH> 130)
                HIGH=130;
            Render(buffer,rejim,WIDT,HIGH,DX);
        }


        if (KeyHit(SDLK_1))
        {
            rejim=1;
            Render(buffer,rejim,WIDT,HIGH,DX);
        }
        if (KeyHit(SDLK_2))
        {
            rejim=2;
            Render(buffer,rejim,WIDT,HIGH,DX);
        }
        if (KeyHit(SDLK_3))
        {
            rejim=3;
            Render(buffer,rejim,WIDT,HIGH,DX);
        }
        if (KeyHit(SDLK_4))
        {
            rejim=4;
            Render(buffer,rejim,WIDT,HIGH,DX);
        }
        if (KeyHit(SDLK_5))
        {
            rejim=5;
            Render(buffer,rejim,WIDT,HIGH,DX);
        }
        if (KeyHit(SDLK_6))
        {
            rejim=6;
            Render(buffer,rejim,WIDT,HIGH,DX);
        }
        if (KeyHit(SDLK_7))
        {
            rejim=7;
            Render(buffer,rejim,WIDT,HIGH,DX);
        }
        if (KeyHit(SDLK_8))
        {
            rejim=8;
            Render(buffer,rejim,WIDT,HIGH,DX);
        }
        if (KeyHit(SDLK_9))
        {
            rejim=9;
            Render(buffer,rejim,WIDT,HIGH,DX);
        }
        if (KeyHit(SDLK_0))
        {
            rejim=10;
            Render(buffer,rejim,WIDT,HIGH,DX);
        }

        if (KeyHit(SDLK_MINUS))
        {
            rejim=11;
            Render(buffer,rejim,WIDT,HIGH,DX);
        }

        if (KeyHit(SDLK_EQUALS))
        {
            rejim=12;
            Render(buffer,rejim,WIDT,HIGH,DX);
        }

        if (KeyDown(SDLK_RIGHT))
        {
            Offs++;
            Render(buffer,rejim,WIDT,HIGH,DX);
        }
        if (KeyDown(SDLK_LEFT))
        {
            Offs--;
            Render(buffer,rejim,WIDT,HIGH,DX);
        }

        if (rejim<5)
        {
            if (KeyDown(SDLK_DOWN))
            {
                Offs+=WIDT;
                Render(buffer,rejim,WIDT,HIGH,DX);
            }
            if (KeyDown(SDLK_UP))
            {
                Offs-=WIDT;
                Render(buffer,rejim,WIDT,HIGH,DX);
            }
            if (KeyDown(SDLK_PAGEUP))
            {
                Offs-=WIDT*10;
                Render(buffer,rejim,WIDT,HIGH,DX);
            }
            if (KeyDown(SDLK_PAGEDOWN))
            {
                Offs+=WIDT*10;
                Render(buffer,rejim,WIDT,HIGH,DX);
            }
            if (KeyDown(SDLK_HOME))
            {
                Offs-=WIDT*100;
                Render(buffer,rejim,WIDT,HIGH,DX);
            }
            if (KeyDown(SDLK_END))
            {
                Offs+=WIDT*100;
                Render(buffer,rejim,WIDT,HIGH,DX);
            }
        }
        else if (rejim < 11)
        {
            if (KeyDown(SDLK_DOWN))
            {
                Offs+=WIDT*2;
                Render(buffer,rejim,WIDT,HIGH,DX);
            }
            if (KeyDown(SDLK_UP))
            {
                Offs-=WIDT*2;
                Render(buffer,rejim,WIDT,HIGH,DX);
            }
            if (KeyDown(SDLK_PAGEUP))
            {
                Offs-=WIDT*20;
                Render(buffer,rejim,WIDT,HIGH,DX);
            }
            if (KeyDown(SDLK_PAGEDOWN))
            {
                Offs+=WIDT*20;
                Render(buffer,rejim,WIDT,HIGH,DX);
            }
            if (KeyDown(SDLK_HOME))
            {
                Offs-=WIDT*200;
                Render(buffer,rejim,WIDT,HIGH,DX);
            }
            if (KeyDown(SDLK_END))
            {
                Offs+=WIDT*200;
                Render(buffer,rejim,WIDT,HIGH,DX);
            }
        }
        else if (rejim < 13)
        {
            if (KeyDown(SDLK_DOWN))
            {
                Offs+=WIDT*3;
                Render(buffer,rejim,WIDT,HIGH,DX);
            }
            if (KeyDown(SDLK_UP))
            {
                Offs-=WIDT*3;
                Render(buffer,rejim,WIDT,HIGH,DX);
            }
            if (KeyDown(SDLK_PAGEUP))
            {
                Offs-=WIDT*30;
                Render(buffer,rejim,WIDT,HIGH,DX);
            }
            if (KeyDown(SDLK_PAGEDOWN))
            {
                Offs+=WIDT*30;
                Render(buffer,rejim,WIDT,HIGH,DX);
            }
            if (KeyDown(SDLK_HOME))
            {
                Offs-=WIDT*300;
                Render(buffer,rejim,WIDT,HIGH,DX);
            }
            if (KeyDown(SDLK_END))
            {
                Offs+=WIDT*300;
                Render(buffer,rejim,WIDT,HIGH,DX);
            }
        }


        // DRAWING ENDS HERE


        // finally, update the screen :)
        SDL_Flip(screen);
        SDL_Delay(10);
    } // end main loop

    fclose(fl);

    return 0;
}
void CObject_Appletree::Update()
{
	Center = WorldX + GetWidth()/2;
	SetAttackBox(0, 0, 0, 0);

	if(HeroForEnemy->GetWorldX()+100 < Center && !b_Attack)	// Hero가 왼쪽에 있을 때
	{
		b_left = true;
		b_right = false;
	}
	else if(HeroForEnemy->GetWorldX()+100 > Center && !b_Attack)
	{
		b_left = false;
		b_right = true;
	}

	// 인식범위 설정
	int RcnzX = Center;
	if(b_left) {
		RcnzX -= RecognizeRange;
	}
	else if(b_right) {
		RcnzX += RecognizeRange;
	}
	
	// 공격범위 설정
	int AtkX = Center;
	if(b_left) {
		AtkX -= AttackRange;
	}
	else if(b_right) {
		AtkX += AttackRange;
	}

	// 인식범위 내에서의 행동따윈 필요없다.

	// 공격범위 내에서의 행동
	if(GetHP() > 0)
	{
		if(HeroForEnemy->GetWorldX()+100 > AtkX && b_left)
		{
			if(AttackCount == -1 ) {
				SetAttack(true);
				AttackCount = 0;
			}
			if(Poison->GetCount() >= 1 && Poison->GetCount() <= 2) {
				SetAttackBox((int)GetDrawX()+30, (int)GetDrawY()+250, 191, 220);
			}

			for(int i=0; i<2; i++)
			{
				if(Break[i]->GetCount() >=1 && Break[i]->GetCount() <= 3) {
					SetAttackBox((int)GetDrawX()+25, (int)GetDrawY()+400, 180, 100);
				}
			}

			b_apple[0] = true;
		}
		else if(HeroForEnemy->GetWorldX()+100 < AtkX && b_right)
		{
			if(AttackCount == -1 ) {
				SetAttack(true);
				AttackCount = 0;
			}
			if(Poison->GetCount() >= 1 && Poison->GetCount() <= 2) {
				SetAttackBox((int)GetDrawX()+30, (int)GetDrawY()+250, 250, 220);
			}
			
		}

		if(AttackCount != -1) {
			AttackCount++;
		}
		
		if(Poison->GetCount() >= 6) {
			Poison->SetCount(0);
			SetAttack(false);
		}
		

		if(AttackCount > AttackDelay) {
			AttackCount = -1;
			Poison->SetCount(0);
			SetAttack(false);
		}
	}



	
	// 충돌박스 설정
	SetBoundBox((int)GetDrawX()+100, (int)GetDrawY()+50, 158, 400);
	
	// Hero와의 충돌판정
	if(GetHP() > 0)
	{
		if(CCollision::GetCollision()->Box_n_Box(
			HeroForEnemy->GetBoundX()-1, HeroForEnemy->GetBoundY(), HeroForEnemy->GetBoundX()+HeroForEnemy->GetBoundWidth()+1, HeroForEnemy->GetBoundY()+HeroForEnemy->GetBoundHeight(),
			GetBoundX(), GetBoundY(), GetBoundX()+GetBoundWidth(), GetBoundY()+GetBoundHeight()))
		{
			if(HeroForEnemy->GetWorldX()+100 < Center)	// Hero가 왼쪽에 있을 때
			{
				//HeroForEnemy->MoveTo(GetWorldX() + (int)((GetWidth()-GetBoundWidth())/2) - HeroForEnemy->GetWidth() + (int)((HeroForEnemy->GetWidth() - HeroForEnemy->GetBoundWidth())/2), HeroForEnemy->GetWorldY());
				HeroForEnemy->MoveTo(GetWorldX() + (int)((GetWidth()-GetBoundWidth())/2) - 115, HeroForEnemy->GetWorldY());
			}
			
			else if(HeroForEnemy->GetWorldX()+100 >= Center)	// Hero가 오른쪽에 있을 때
			{
				HeroForEnemy->MoveTo(GetWorldX() + GetWidth() - (int)((GetWidth()-GetBoundWidth())/2) - (int)((HeroForEnemy->GetWidth()-HeroForEnemy->GetBoundWidth())/2), HeroForEnemy->GetWorldY());
			}
			
		}
	}

	
	// Hero에게 공격판정
	if(CCollision::GetCollision()->Box_n_Box(
		HeroForEnemy->GetBoundX(), HeroForEnemy->GetBoundY(), HeroForEnemy->GetBoundX()+HeroForEnemy->GetBoundWidth(), HeroForEnemy->GetBoundY()+HeroForEnemy->GetBoundHeight(),
		GetAttackX(), GetAttackY(), GetAttackX()+GetAttackWidth(), GetAttackY()+GetAttackHeight()))
	{
		if(!HeroForEnemy->GetHit())
		{
			int dmg = (int)GetDmg();
			if(b_left)
			{
				if(HeroForEnemy->GetWay() == 1 && HeroForEnemy->GetGuard()) {
					dmg = (int)(dmg * 0.3f);
					HeroForEnemy->SetGuardHit(TRUE);
				}
			}
			else if(b_right)
			{
				if(HeroForEnemy->GetWay() == 0 && HeroForEnemy->GetGuard()) {
					dmg = (int)(dmg * 0.3f);
					HeroForEnemy->SetGuardHit(TRUE);
				}
			}
			HeroForEnemy->SetHP(HeroForEnemy->GetHP() - dmg);
			HeroForEnemy->SetHit(true);
			//SetAttack(false);
			if(HeroKnockbackCount == -1)
			{
				HeroKnockbackCount = 0;
			}
		}
	}
	
	// 넉백
	if(HeroKnockbackCount != -1)
	{
		if(HeroForEnemy->GetWorldX()+100 < Center)		// Hero가 왼쪽에 있을 때
		{
			if(HeroForEnemy->GetGuard()) {
				HeroForEnemy->MoveTo(HeroForEnemy->GetWorldX()-2, HeroForEnemy->GetWorldY());
			}
			else {
				HeroForEnemy->MoveTo(HeroForEnemy->GetWorldX()-3, HeroForEnemy->GetWorldY());
			}
		}
		else if(HeroForEnemy->GetWorldX()+100 > Center)	// Hero가 오른쪽에 있을 때
		{
			if(HeroForEnemy->GetGuard()) {
				HeroForEnemy->MoveTo(HeroForEnemy->GetWorldX()+2, HeroForEnemy->GetWorldY());
			}
			else {
				HeroForEnemy->MoveTo(HeroForEnemy->GetWorldX()+3, HeroForEnemy->GetWorldY());
			}
		}

		if(HeroKnockbackCount >= 15) {
			HeroKnockbackCount = -1;
			Hit->SetCount(0);
		}
		else {
			HeroKnockbackCount++;
		}
	}
	
	// Hero에게 피격판정
	if(GetHP() > 0)
	{
		if(CCollision::GetCollision()->Box_n_Box(
			HeroForEnemy->GetAttackX(), HeroForEnemy->GetAttackY(), HeroForEnemy->GetAttackX()+HeroForEnemy->GetAttackWidth(), HeroForEnemy->GetAttackY()+HeroForEnemy->GetAttackHeight(),
			GetBoundX(), GetBoundY(), GetBoundX()+GetBoundWidth(), GetBoundY()+GetBoundHeight()) ||
			CCollision::GetCollision()->Box_n_Box(
			HeroForEnemy->GetSkillX(), HeroForEnemy->GetSkillY(), HeroForEnemy->GetSkillX()+HeroForEnemy->GetSkillWidth(), HeroForEnemy->GetSkillY()+HeroForEnemy->GetSkillHeight(),
			GetBoundX(), GetBoundY(), GetBoundX()+GetBoundWidth(), GetBoundY()+GetBoundHeight()) )
		{
			b_apple[1] = true;
			Poison->SetCount(0);
			SetHit(true);
			if(HitCount == -1) {
				HitCount = 0;

				SetHP(GetHP() - HeroForEnemy->GetDmg());
			}

			if(KnockbackCount == -1) {
				KnockbackCount = 0;
			}
		}
		/*
		if(KnockbackCount != -1)
		{
			if(HeroForEnemy->GetWorldX()+100 < Center)		// Hero가 왼쪽에 있을 때
			{
				MoveTo(GetWorldX()+2, GetWorldY());

			}
			else if(HeroForEnemy->GetWorldX()+100 > Center)	// Hero가 오른쪽에 있을 때
			{
				MoveTo(GetWorldX()-2, GetWorldY());
			}

			if(KnockbackCount >= 10) {
				KnockbackCount = -1;
			}
			else {
				KnockbackCount++;
			}
		}

		if(GetHP() <= 0)
		{
			HeroForEnemy->SetExp(HeroForEnemy->GetExp() + GetExp());
		}
		*/
		if(HitCount >= 0)
		{
			HitCount++;
			if(HitCount >= 20) {
				HitCount = -1;
				SetHit(false);
				//HitEffect->SetCount(0);
			}
		}
	}
	/*
	// 벽
	if(GetWorldX() < -76)
	{
		WorldX = -76;
	}
	*/
	if(GetHP() < 0)
	{
		Opacity -= 6;
		b_Move = false;
		b_Attack = false;
	}
}