void CFinalBullet::Update(float eTime) {
	IScene::Update(eTime);
	pos.x += cos(rot)*speed*eTime;
	pos.y += sin(rot)*speed * eTime;
	if (pos.y > App::HEIGHT + 200) {
		this->parent->PopScene(this);
		return;
	}
	RECT bulletRect, playerRect, tempRect;
	bulletRect.left = pos.x + rotatingCenter.x - 1;
	bulletRect.right = pos.x + rotatingCenter.x + 1;
	bulletRect.top = pos.y + rotatingCenter.y - 1;
	bulletRect.bottom = pos.y + rotatingCenter.y + 1;
	CGameScene *gs = (CGameScene*)this->parent->parent;
	CPlayer *player = gs->m_pPlayer;
	playerRect.left = player->pos.x + 45;
	playerRect.right = player->pos.x + player->normalAni->width - 45;
	playerRect.top = player->pos.y;
	playerRect.bottom = player->pos.y + player->normalAni->height - 90;
	if (IntersectRect(&tempRect, &playerRect, &bulletRect) == true) {
		player->p_Blood -= 2;
		gs->PushEffect(pos.x + rotatingCenter.x, pos.y + rotatingCenter.y);
		this->parent->PopScene(this);
		return;
	}
}
Exemple #2
0
void CArrow::Update(float eTime)
{
	IScene::Update(eTime);
	pos.x += cos(rot) * speed * eTime;
	pos.y += sin(rot) * speed * eTime;
	if (pos.y > App::HEIGHT + 200)
	{
		this->parent->PopScene(this);
		return;
	}

	RECT arrowRect, playerRect, tempRect;
	//RECT ¼³Á¤
	arrowRect.left   = pos.x + rotatingCenter.x - 1;
	arrowRect.right  = pos.x + rotatingCenter.x + 1;
	arrowRect.top    = pos.y + rotatingCenter.y - 1;
	arrowRect.bottom = pos.y + rotatingCenter.y + 1;

	CGameScene *gs = (CGameScene*)this->parent->parent;
	CPlayer *player = gs->m_pPlayer;
	playerRect.left = player->pos.x;
	playerRect.right = player->pos.x + player->normalAni->width;
	playerRect.top = player->pos.y;
	playerRect.bottom = player->pos.y + player->normalAni->height;
	//
	if (IntersectRect(&tempRect, &playerRect, &arrowRect) == true)
	{
		CParticleSystem *p = gs->PushEffect(pos.x + rotatingCenter.x, pos.y + rotatingCenter.y);
		p->start();
		this->parent->PopScene(this);
		return;
	}
}
Exemple #3
0
bool CRoom::init(int boardType)
{	
	m_IsLoaded = false;
	CGameScene* scene = CGameScene::Instance();
	m_Field = CField::create(boardType);
	m_Turn = RT_FIRST_PLAYER;
	m_Type = RT_ONE_COMPUTER;
	m_State = RS_NONE;
	m_OldState = RS_NONE;
	scene->addChild(m_Field);
	m_ScorePlayer_1 = 0;
	m_ScorePlayer_2 = 0;
	m_Stack = new CStack();
	//m_Stack->CreateStack();
	m_DeckPlayer_1 = CDeck::create();
	//m_DeckPlayer_1->FirstInitEmptyCells(m_Stack);
	scene->addChild(m_DeckPlayer_1, CGameScene::OVER_GUI_LAYER);
	//m_DeckPlayer_2 = CDeck::create();
	//m_DeckPlayer_2->FirstInitEmptyCells(m_Stack);
	//scene->addChild(m_DeckPlayer_2, CGameScene::OVER_GUI_LAYER);
	m_ScorePointer_1 = CScorePointer::create();
	m_Field->GetFieldSprite()->addChild(m_ScorePointer_1, CScorePointer::ACTIVE_LAYER);
	m_ScorePointer_2 = CScorePointer::create();
	m_Field->GetFieldSprite()->addChild(m_ScorePointer_2, CScorePointer::ACTIVE_LAYER);
	m_Button = CRoomButton::create();
	m_Button->retain();
    //	scene->addChild(m_Button,CGameScene::GUI_LAYER);
	m_Id = -1;
	m_PassInARowCount = 0;
	m_FirstPlayerName = "Player 1";
	m_SecondPlayerName = "Player 2";
	return true;
}
Exemple #4
0
void CEnemy1::Update(float eTime)
{
	IEnemy::Update(eTime);
	CGameScene *gs = (CGameScene*)this->parent->parent;
	
	if (hp <= 0)
	{
		CParticleSystem *p = gs->PushEffect(pos.x + ani->width/2, pos.y + ani->height/2 + 55.0f);
		p->setScalep(4.0f, 5.0f);
		p->direction = -90;
		p->spread = 30;
		p->setSpeed(400.0f, 700.0f);
		p->start();


		CGSoundManager * sm = App::GetInstance()->g_pSoundManager;
		sm->Play(2);
		
		this->parent->PopScene(this);
		return;
	}

	time += eTime;
	time2 += eTime;
	if (pos.y < 50)
	{
		pos.y += 150 * eTime;
		if (pos.y > 50) pos.y = 50;
	}

	if (time > 3.0f)
	{
		gs->PushEffect(this->pos.x+20, this->pos.y + 140);
		gs->PushArrow(this->pos.x - 65, this->pos.y + 170, D3DX_PI / 2);
		gs->PushArrow(this->pos.x - 65, this->pos.y + 170, D3DX_PI / 2 - 0.4);
		gs->PushArrow(this->pos.x - 65, this->pos.y + 170, D3DX_PI / 2 + 0.4);
		time = 0.f;
	}

	if (time2 > 7.0f)
	{
		pos.y += 700 * eTime;
	}

	if (pos.y > App::HEIGHT)
	{
		this->parent->PopScene(this);
		return;
	}

}
Exemple #5
0
int main(int argc, const char * argv[]) {
    
    if (!glfwInit()) {
        std::cerr << "Error init glfw!" << std::endl;
        exit(EXIT_FAILURE);
    }
    
    CGameScene *gameScene = new CGameScene();
    
    gameScene->create(1024, 768, "Pacman Game", nullptr, nullptr);
    gameScene->init();
    double lastTime = glfwGetTime();
    double deltaTime = 0.f;
    while (!gameScene->getWindowState()) {
        gameScene->render();
        glfwPollEvents();
        deltaTime += (glfwGetTime() - lastTime) * FPS;
        lastTime = glfwGetTime();
        while (deltaTime >= 1.f) {
            gameScene->update();
            deltaTime--;
        }
        gameScene->setWindowState(glfwWindowShouldClose(gameScene->getWindow()));
    }
    delete gameScene;
    
    glfwTerminate();
    return 0;
}
Exemple #6
0
void CBuyBulletLayer::button_press(int tag)
{
    if (10013 == tag)
    {
        m_nFishGold -= 100;
        if (m_nFishGold<100)
        {
            m_nFishGold = 100;
        }

        SetFishGold(m_nFishGold);
        SetGameGold(m_nFishGold*m_lCellScore);
        m_sldNumber->set_value((double)(m_nFishGold-100)/400);
    }
    else if (10014 == tag)
    {
        m_nFishGold += 100;
        if (m_nFishGold>500)
        {
            m_nFishGold = 500;
        }

        SetFishGold(m_nFishGold);
        SetGameGold(m_nFishGold*m_lCellScore);
        m_sldNumber->set_value((double)(m_nFishGold-100)/400);
    }
    else if (10011 == tag)
    {
        m_nFishGold = 500;
       
        SetFishGold(m_nFishGold);
        SetGameGold(m_nFishGold*m_lCellScore);
        m_sldNumber->set_value((double)(m_nFishGold-100)/400);
    }
    else if (10010 == tag)
    {
        ShowWidnow(false);
    }
    else if (10012 == tag)
    {
        CMD_C_Buy_Bullet BuyBullet;
        BuyBullet.wCount = m_nFishGold;

        CGameScene *pGameScene = (CGameScene *)parent();
        pGameScene->GetClientKernel()->SendSocketData(MDM_GF_GAME, SUB_C_BUY_BULLET, &BuyBullet, sizeof(CMD_C_Buy_Bullet));
        m_bSendMessage = true;
        ShowWidnow(false);
    }
}
Exemple #7
0
//-----------------------------------------------------------------------------
//	Implementation
//-----------------------------------------------------------------------------
CCScene* CGameScene::scene()
{
	CGameScene* pScene = new CGameScene();
	if (pScene && pScene->init())
	{
		pScene->autorelease();
		return pScene;
	}
	else
	{
		delete pScene;
		pScene = NULL;
		return NULL;
	}
}
Exemple #8
0
void CBoss::Update(float eTime) {
	CGameScene *gs = (CGameScene*)this->parent;
	if (this->pos.y < 0) {
		this->pos.y += 500 * eTime;
		if (this->pos.y > 0) {
			pos.y = 0;
		}
	}
	if (this->blood < 0) {
		gs->StandBossCreate();
		gs->m_pBoss = nullptr;
		parent->PopScene(this);
		return;
	}
	cout << blood << endl;
}
Exemple #9
0
CCScene* CGameLogo::scene()
{
    CGameScene * scene = NULL;
    do 
    {
        // 'scene' is an autorelease object
        scene = new CGameScene();
        scene->autorelease();
        CC_BREAK_IF(! scene);

        // 'layer' is an autorelease object
        CGameLogo *layer = CGameLogo::node();
        CC_BREAK_IF(! layer);

        // add layer as a child to scene
        scene->addChild(layer);
    } while (0);

    // return the scene
    return scene;
}
Exemple #10
0
void CAccountLayer::button_press(int tag)
{      
    CGameScene *pGameScene = (CGameScene *)parent();

    if (tag == 10200)     
    {                      
          pGameScene->window_closed(0);
           Root::instance()->queue_end_rendering();		
    }
    else if (tag == 10201)
    {
         CMD_C_Account Account;
         Account.wChairID = pGameScene->GetMeChairID();

         pGameScene->GetClientKernel()->SendSocketData(MDM_GF_GAME, SUB_C_ACCOUNT, &Account, sizeof(CMD_C_Account));

         DisableWindow(true);
    }
    else if (tag == 10202)
    {
        ShowWidnow(false);
    }
}
Exemple #11
0
void CArrow::Update(float eTime)
{
	IScene::Update(eTime);
	CGameScene * gs = (CGameScene*)this->parent;
	CPlayer *player = gs->m_pPlayer;

	//this->rot = atan2((player->pos.y + player->normalAni->height / 2) - (this->pos.y + this->rotatingCenter.y), (player->pos.x + player->normalAni->width / 2) - (this->pos.x + this->rotatingCenter.x));

	pos.x += cos(rot) * speed * eTime;
	pos.y += sin(rot) * speed * eTime;

	if (pos.y > App::HEIGHT + ani->width){
		this->parent->PopScene(this);
		return;
	}

	RECT arrowRect;
	arrowRect.left = pos.x + this->rotatingCenter.x - 1;
	arrowRect.right = pos.x + this->rotatingCenter.x + 1;
	arrowRect.top = pos.y + this->rotatingCenter.y - 1;
	arrowRect.bottom = pos.y + this->rotatingCenter.y + 1;

	RECT playerRect;
	playerRect.left = player->pos.x + 10;
	playerRect.top = player->pos.y + 10;
	playerRect.right = player->pos.x + player->normalAni->width - 10;
	playerRect.bottom = player->pos.y + player->normalAni->height - 10;

	RECT tmpRect;
	if (IntersectRect(&tmpRect, &arrowRect, &playerRect))
	{
		gs->PushEffect(pos.x + this->rotatingCenter.x, pos.y + this->rotatingCenter.y);
		this->parent->PopScene(this);
		return;
	}

}
Exemple #12
0
void CRoomButton::ButtonClick(Ref * sender)
{
	CGameScene * scene = CGameScene::Instance();
	m_Button->stopActionByTag(BLINKING_ACTION_TAG);
	
	if(scene->IsChangingRooms())
	{
		return;
	}
	if(scene->GetPlayer()->IsRoomLoaded(m_Id))
	{
		scene->ChangeRoom(m_Id);
	}
	else
	{
		scene->ShowWaitingAnim();
		scene->GetPlayer()->LoadRoomData(m_ServerId);
	}
    
    //#ChatLayer
    CGameScene::Instance()->showChatRelatedThing();
}
Exemple #13
0
void CAccountLayer::draw()
{
    if (!visible_)
    {
        return;
    }

    __super::draw();

    CGameScene *pGameScene = (CGameScene *)parent();
    CClientKernel *pClientKernel = pGameScene->GetClientKernel();
    if ( !pClientKernel)
        return ;

    Point pt(position_absolute());
    Point ptDraw;
    std::ostringstream ostr;

    for (int i=0; i<4; i++)
    {
        ostr.str("");
        ostr << m_CaptureFishs[i];

        ptDraw.x_ = pt.x_ + 136+i*180;
        ptDraw.y_ = pt.y_ +104;

        DrawNumber(ostr.str(), ptDraw);
    }

    for (int i=0; i<4; i++)
    {
        ostr.str("");
        ostr << m_CaptureFishs[i+4];

        ptDraw.x_ = pt.x_ + 136+i*180;
        ptDraw.y_ = pt.y_ +104+74;

        DrawNumber(ostr.str(), ptDraw);
    }

    for (int i=0; i<4; i++)
    {
        ostr.str("");
        ostr << m_CaptureFishs[i+8];

        ptDraw.x_ = pt.x_ + 136+i*180;
        ptDraw.y_ = pt.y_ +104+148;

        DrawNumber(ostr.str(), ptDraw);
    }


     WORD wMeChairID = pGameScene->GetMeChairID();

     if (wMeChairID != INVALID_CHAIR)
     {
         int nFishGold = pGameScene->m_layRoles[wMeChairID]->GetFishGold();
         ostr.str("");
         ostr << nFishGold; 
         ptDraw.x_ = pt.x_ + 296;
         ptDraw.y_ = pt.y_ + 310;
         DrawNumber(ostr.str(), ptDraw);

         LONG lCellScore = pGameScene->m_layBuyBulletLayer->GetCellScore();

         ostr.str("");
         ostr << nFishGold*lCellScore; 
         ptDraw.x_ = pt.x_ + 500;
         ptDraw.y_ = pt.y_ + 310;
         DrawNumber(ostr.str(), ptDraw);



         const tagUserData *pUserData = pClientKernel->GetMeUserInfo();

         if (pUserData)
         {
             ostr.str("");
             ostr << 0; 
             ptDraw.x_ = pt.x_ + 240;
             ptDraw.y_ = pt.y_ + 352;
             DrawNumber(ostr.str(), ptDraw);

             ostr.str("");
             ostr << pUserData->lScore; 
             ptDraw.x_ = pt.x_ + 580;
             ptDraw.y_ = pt.y_ + 352;
             DrawNumber(ostr.str(), ptDraw);
         }



     }

     DWORD dwTime = (DWORD)time(NULL) - m_dwStartTime;

     if (dwTime >= 20)
     {
         ShowWidnow(false);
     }
     else
     {
         ostr.str("");
         ostr << 20-dwTime; 

         ptDraw.x_ = pt.x_ + 696;
         ptDraw.y_ = pt.y_ + 38;

         DrawTimer(ostr.str(), ptDraw);
     }
}
Exemple #14
0
bool CNetLayer::NetEnd(Node *node, int tag)
{
    Point ptNet;
    Point ptTNet;
    Point ptFish;
    Size szFish;
    Point ptDifference;
    Rect rcScreen(0,0,1280,738);
    float sint, cost;


    CGameScene *pGameScene = (CGameScene *)parent();
    CNetObjectExtend *pNetObjectExtend = (CNetObjectExtend *)node->node_extend();

    if (pNetObjectExtend->wChairID == pGameScene->GetMeChairID() || pGameScene->IsAndroidLogicChairID())
    {
        CMD_C_Cast_Net CastNet;
		CastNet.wChairID = pNetObjectExtend->wChairID;
        CastNet.cbCount = 0;

        ptNet = node->position();

        Nodes::iterator j=pGameScene->m_layFishObject->child_begin();
        for (; j!=pGameScene->m_layFishObject->child_end(); ++j)
        {
			if (CastNet.cbCount >= MAX_FISH_IN_NET)
			    break;

            CFishObjectExtend *pFishObjectExtend = (CFishObjectExtend *)(*j)->node_extend();

            if (pFishObjectExtend->wID == INVALID_WORD)
                continue;

            ptFish = (*j)->position();
            szFish = pFishObjectExtend->GetFishObjectSize();

            cost = std::cosf((*j)->rotation());
            sint = std::sinf((*j)->rotation());
            ptTNet.x_ = (ptNet.x_-ptFish.x_)*cost + (ptNet.y_-ptFish.y_)*sint;
            ptTNet.y_ = -(ptNet.x_-ptFish.x_)*sint + (ptNet.y_-ptFish.y_)*cost;

            if (CFishObjectExtend::ComputeCollision(szFish.width_, szFish.height_, pNetObjectExtend->GetNetRadius(), ptTNet.x_, ptTNet.y_ ))
            {
                CastNet.FishNetObjects[CastNet.cbCount].wID = pFishObjectExtend->wID;
                CastNet.FishNetObjects[CastNet.cbCount].wRoundID = pFishObjectExtend->wRoundID;
                CastNet.FishNetObjects[CastNet.cbCount].wType = pFishObjectExtend->FishType;
                CastNet.FishNetObjects[CastNet.cbCount].dwTime = pFishObjectExtend->dwTime;

                CastNet.cbCount++;
                
            }
        }

		CClientKernel *pClientKernel = pGameScene->GetClientKernel();

		if (pClientKernel != NULL)
			pClientKernel->SendSocketData(MDM_GF_GAME, SUB_C_CAST_NET, &CastNet, sizeof(CMD_C_Cast_Net)-(MAX_FISH_IN_NET-CastNet.cbCount)*sizeof(Fish_Net_Object));
    }

    remove_child(node);

    return true;
}