richman.cpp
来自「本手机游戏richman运行于Nokia 9210 Communicator手机」· C++ 代码 · 共 1,228 行 · 第 1/3 页
CPP
1,228 行
{
case ' ':
ChoosePerson=1;
AppBitMap->Reset();
AppBitMap=LoadMyBitmapL(0);
break;
case EKeyRightArrow:
Player=Player%4+1; //++
break;
case EKeyLeftArrow:
Player=(Player+2)%4+1; //--
break;
}
return;
}
if(PersonGo==0 && Arrived==0) //before go
{
if(PersonThisTurn==Player) //if is the player's turn
{
switch(Key)
{
case ' ':
if(PersonGo==0)
{
PersonGo=1;
Step=(Math::FRand(iSeed)*6)+1;
saizicnt=6;
waitsaizi=3;
break;
}
default:
break;
}
}
else //if is the computer's turn
{
if(PersonGo==0)
{
PersonGo=1;
Step=(Math::FRand(iSeed)*6)+1;
saizicnt=6;
waitsaizi=3;
}
}
}
if(CanBuyLand && ThisTurnFinished==0 && Arrived==1) //arrived and can buy land,check if buy the land
{
if(PersonThisTurn==Player) //if is the player's turn
{
switch(Key)
{
case ' ': //buy the land
if(KeyChoose)
{
if(Land[LOCATION][0]==PersonThisTurn) //update
{
if(Land[LOCATION][1]<4)
{
Land[LOCATION][7]=Land[LOCATION][7]*2;
Land[LOCATION][1]++;
}
}
if(Land[LOCATION][0]==0)
{
Land[LOCATION][0]=PersonThisTurn;
PROPERTY-=LAND_VALUE;
Land[LOCATION][1]++;
}
}
TurnInitial();
return;
break;
case EKeyLeftArrow:
KeyChoose=1;
break;
case EKeyRightArrow:
KeyChoose=0;
break;
}
}
else //if is the computer's turn can buy land
{
if(Key==' ' || WaitTimer==5) //wait space key
{
if(Land[LOCATION][0]==PersonThisTurn) //update
{
if(Land[LOCATION][1]<4)
{
Land[LOCATION][7]=Land[LOCATION][7]*2;
Land[LOCATION][1]++;
}
}
if(Land[LOCATION][0]==0)
{
Land[LOCATION][0]=PersonThisTurn;
PROPERTY-=LAND_VALUE;
Land[LOCATION][1]++;
}
TurnInitial();
WaitTimer=0;
return;
}
else
{
WaitTimer++;
return;
}
}
}
if(CanBuyLand==0 && ThisTurnFinished==0 && Arrived==1)
{
if(Key==' ' && PersonThisTurn==Player) //player cannot buy land wait SpaceKey
{
if(IsLand(LOCATION)) //give money
{
PROPERTY-=LAND_VALUE/2;
Person[Land[LOCATION][0]][0]+=LAND_VALUE/2;
}
TurnInitial();
return;
}
if(PersonThisTurn!=Player) //computer cannot buy land
{
if(Key==' ' || WaitTimer==5)
{
if(IsLand(LOCATION)) //give money
{
PROPERTY-=LAND_VALUE/2;
Person[Land[LOCATION][0]][0]+=LAND_VALUE/2;
}
WaitTimer=0;
TurnInitial();
return;
}
else
{
WaitTimer++;
}
}
}
}
void CExampleAppView::DoPeriodTask()
{
ThisTurn();
Key=0;
TimerCount++;
if(BeforeStart && ChoosePerson)
{
Refresh(); //Refresh the BackScreen
}
else if(BeforeStart && !ChoosePerson)
{
DrawChoose();
}
else if(!BeforeStart && !ChoosePerson)
{
iBackBufferGc->SetBrushColor(TRgb(0,0,0));
iBackBufferGc->Clear();
iBackBufferGc->BitBlt(TPoint(246,0), testbmp);
}
screenMemory=ScrrenMemoryBak;
BufferAdd=(TUint16*)iBackBufferBitmap->DataAddress();
DrawDeferred(); // Update the screen
CWindowGc& gc = SystemGc();
gc.Activate(*DrawableWindow());
gc.Deactivate();
}
void CExampleAppView::DrawChoose()
{
int i;
TRect sourceRect;
TBuf <60> KTemp1;
iBackBufferGc->BitBlt(TPoint(0,0), AppBitMap);
for(i=0;i<PERSON_NUM;i++)
{
sourceRect.SetRect(TPoint(0,0),SpriteBitMap[i]->SizeInPixels());
iBackBufferGc->BitBltMasked( TPoint(i*100+180-SpriteBitMap[i]->SizeInPixels().iWidth/2,50), SpriteBitMap[i],sourceRect, SpriteMaskBitMap[i], EFalse);
}
sourceRect.SetRect(TPoint(0,0),Finger->SizeInPixels());
iBackBufferGc->BitBltMasked(TPoint(Player*100+65,97), Finger,sourceRect, FingerMask, EFalse);
KTemp1=KPersonName[Player-1];
iBackBufferGc->DrawText(KTemp1,TPoint(TextLocationX+5,TextLocationY+60));
KTemp1=KSays[Player-1][0];
iBackBufferGc->DrawText(KTemp1,TPoint(TextLocationX+32,TextLocationY+80));
iBackBufferGc->BitBlt(TPoint(TextLocationX,TextLocationY+65),PicFace[Player-1]);
}
void CExampleAppView::Refresh()
{
TInt i;
if(PersonGo==2)
{
Arrived=1;
}
if(waitsaizi==0 && Step>0)
{
LOCATION=(LOCATION+1)%LandNum;
Step--;
if(Step==0)
{
PersonGo=2;
if(Land[LOCATION][0]==0 && IsLand(LOCATION) )
{
CanBuyLand=1;
}
else if(Land[LOCATION][0]==PersonThisTurn && IsLand(LOCATION) )
{
if(Land[LOCATION][1]<4)
{
CanBuyLand=2;
}
}
else
{
CanBuyLand=0;
}
}
}
if(waitsaizi<=0 || waitsaizi==3)
{
/////////////////////////////////////////////////////////
/////////initial backbuffer
BitAdd=(TUint16*)AppBitMap->DataAddress();
BufferAdd=(TUint16*)iBackBufferBitmap->DataAddress();
for(i=0;i<640*200;i++) *BufferAdd++=*BitAdd++;
/////////////////////////////////////////////////////////
DrawGo();
DrawHouseAndPerson();
DrawText();
}
if(waitsaizi)
{
DrawSaiZi();
}
}
void CExampleAppView::DrawText()
{
TBuf <60> KTemp1;
TBuf <60> KTemp2;
TInt i;
Ranking();
if(!Arrived)
iBackBufferGc->BitBlt(TPoint(TextLocationX,TextLocationY-8),PicFace[PersonThisTurn-1]);
for(i=0;i<PERSON_NUM;i++)
{
KTemp1.Num(RankProperty[i]);
iBackBufferGc->DrawText(KTemp1,TPoint(TextLocationX+310,TextLocationY-10+i*15));
iBackBufferGc->BitBlt(TPoint(TextLocationX+290,TextLocationY-22+i*15),PicFaceSmall[RankPerson[i]-1]);
}
if(Arrived)
{
if(CanBuyLand)
{
if(PersonThisTurn==Player) //the player buy land
{
if(KeyChoose)
{
iBackBufferGc->BitBlt(TPoint(YesOrNoLocationX,YesOrNoLocationY),PicYes );
}
else
{
iBackBufferGc->BitBlt(TPoint(YesOrNoLocationX,YesOrNoLocationY),PicNo );
}
KTemp1=KInfo[0].Mid(WhichCity(LOCATION)*(CITYNAMELENGTH),CITYNAMELENGTH);
iBackBufferGc->DrawText(KTemp1,TPoint(TextLocationX,TextLocationY));
KTemp1=KInfo[1];
KTemp2.Num(LAND_VALUE);
KTemp1+=KTemp2;
KTemp1+=KInfo[2];
iBackBufferGc->DrawText(KTemp1,TPoint(TextLocationX,TextLocationY+16));
if(CanBuyLand==1)
KTemp1=KInfo[3];
else
KTemp1=KInfo[6];
iBackBufferGc->DrawText(KTemp1,TPoint(TextLocationX,TextLocationY+32));
}
else //the computer buy land
{
KTemp1=KPersonName[PersonThisTurn-1];
KTemp1+=KInfo[10];
KTemp1+=KInfo[0].Mid(WhichCity(LOCATION)*(CITYNAMELENGTH),CITYNAMELENGTH);
if(CanBuyLand==1)
KTemp1+=KInfo[7];
else
KTemp1+=KInfo[11];
KTemp2.Num(LAND_VALUE);
KTemp1+=KTemp2;
KTemp1+=KInfo[2];
iBackBufferGc->DrawText(KTemp1,TPoint(TextLocationX,TextLocationY+30));
iBackBufferGc->BitBlt(TPoint(TextLocationX,TextLocationY-8),PicFace[PersonThisTurn-1]);
KTemp1=KSays[PersonThisTurn-1][0];
iBackBufferGc->DrawText(KTemp1,TPoint(TextLocationX+32,TextLocationY+8));
}
}
else if(IsLand(LOCATION)) //give money
{
KTemp1=KPersonName[PersonThisTurn-1];
KTemp1+=KInfo[8];
KTemp2.Num(LAND_VALUE/2);
KTemp1+=KTemp2;
KTemp1+=KInfo[2];
KTemp1+=KInfo[9];
KTemp1+=KPersonName[Land[LOCATION][0]-1];
iBackBufferGc->DrawText(KTemp1,TPoint(TextLocationX,TextLocationY+30));
iBackBufferGc->BitBlt(TPoint(TextLocationX,TextLocationY-8),PicFace[PersonThisTurn-1]);
KTemp1=KSays[PersonThisTurn-1][1];
iBackBufferGc->DrawText(KTemp1,TPoint(TextLocationX+32,TextLocationY+8));
}
else if(!IsLand(LOCATION)) //special
{
Special(LOCATION);
}
}
}
void CExampleAppView::DrawSaiZi()
{
TRect sourceRect;
if(saizicnt)
{
saizicnt--;
sourceRect.SetRect(TPoint(0,0),PicSaiZi[saizisort[saizicnt]]->SizeInPixels());
iBackBufferGc->BitBltMasked( TPoint(84, 76), PicSaiZi[saizisort[saizicnt]],sourceRect, PicSaiZim[saizisort[saizicnt]], EFalse);
}
else
{
if(waitsaizi)
{
waitsaizi--;
sourceRect.SetRect(TPoint(0,0),PicSaiZi[Step-1]->SizeInPixels());
iBackBufferGc->BitBltMasked( TPoint(84, 76), PicSaiZi[Step-1],sourceRect, PicSaiZim[Step-1], EFalse);
}
}
}
void CExampleAppView::DrawGo()
{
TRect sourceRect;
if(PersonGo==0 && Arrived==0 && PersonThisTurn==Player)
{
sourceRect.SetRect(TPoint(0,0),PicGo->SizeInPixels());
iBackBufferGc->BitBltMasked( TPoint(84, 76), PicGo,sourceRect, PicGom, EFalse);
}
}
void CExampleAppView::DrawHouseAndPerson()
{
TInt Loop,i;
TRect sourceRect;
for(Loop=0;Loop<18;Loop++)
{
for(i=0;i<4;i++)
{
if(Person[i+1][1]==Loop)
{
sourceRect.SetRect(TPoint(0,0),SpriteBitMap[i]->SizeInPixels());
iBackBufferGc->BitBltMasked( TPoint(4+Land[Person[i+1][1]][2]-SpriteBitMap[i]->SizeInPixels().iWidth/2, Land[Person[i+1][1]][3]-42), SpriteBitMap[i],sourceRect, SpriteMaskBitMap[i], EFalse);
}
}
if(Land[Loop][0] && IsLand(Loop))
{
switch(Land[Loop][1])
{
case 1:
sourceRect.SetRect(TPoint(0,0),House[Land[Loop][0]-1]->SizeInPixels());
iBackBufferGc->BitBltMasked( TPoint(Land[Loop][4]-House[Land[Loop][0]-1]->SizeInPixels().iWidth/2, Land[Loop][5]-House[Land[Loop][0]-1]->SizeInPixels().iHeight+15), House[Land[Loop][0]-1],sourceRect, Housem[Land[Loop][0]-1], EFalse);
break;
case 2:
sourceRect.SetRect(TPoint(0,0),AHouse2[Land[Loop][0]-1]->SizeInPixels());
iBackBufferGc->BitBltMasked( TPoint(Land[Loop][4]-AHouse2[Land[Loop][0]-1]->SizeInPixels().iWidth/2, Land[Loop][5]-AHouse2[Land[Loop][0]-1]->SizeInPixels().iHeight+18), AHouse2[Land[Loop][0]-1],sourceRect, AHouse2m, EFalse);
break;
case 3:
sourceRect.SetRect(TPoint(0,0),AHouse3[Land[Loop][0]-1]->SizeInPixels());
iBackBufferGc->BitBltMasked( TPoint(Land[Loop][4]-AHouse3[Land[Loop][0]-1]->SizeInPixels().iWidth/2, Land[Loop][5]-AHouse3[Land[Loop][0]-1]->SizeInPixels().iHeight+18), AHouse3[Land[Loop][0]-1],sourceRect, AHouse3m, EFalse);
break;
case 4:
sourceRect.SetRect(TPoint(0,0),AHouse4[Land[Loop][0]-1]->SizeInPixels());
iBackBufferGc->BitBltMasked( TPoint(Land[Loop][4]-AHouse4[Land[Loop][0]-1]->SizeInPixels().iWidth/2, Land[Loop][5]-AHouse4[Land[Loop][0]-1]->SizeInPixels().iHeight+18), AHouse4[Land[Loop][0]-1],sourceRect, AHouse4m, EFalse);
break;
}
}
}
for(Loop=18;Loop<22;Loop++)
{
for(i=0;i<4;i++)
{
if(Person[i+1][1]==Loop)
{
sourceRect.SetRect(TPoint(0,0),SpriteBitMap[i]->SizeInPixels());
iBackBufferGc->BitBltMasked( TPoint(4+Land[Person[i+1][1]][2]-SpriteBitMap[i]->SizeInPixels().iWidth/2, Land[Person[i+1][1]][3]-42), SpriteBitMap[i],sourceRect, SpriteMaskBitMap[i], EFalse);
}
}
if(Land[Loop][0] && IsLand(Loop))
{
switch(Land[Loop][1])
{
case 1:
sourceRect.SetRect(TPoint(0,0),House[Land[Loop][0]-1]->SizeInPixels());
iBackBufferGc->BitBltMasked( TPoint(Land[Loop][4]-House[Land[Loop][0]-1]->SizeInPixels().iWidth/2, Land[Loop][5]-House[Land[Loop][0]-1]->SizeInPixels().iHeight+15), House[Land[Loop][0]-1],sourceRect, Housem[Land[Loop][0]-1], EFalse);
break;
case 2:
sourceRect.SetRect(TPoint(0,0),AHouse2[Land[Loop][0]-1]->SizeInPixels());
iBackBufferGc->BitBltMasked( TPoint(Land[Loop][4]-AHouse2[Land[Loop][0]-1]->SizeInPixels().iWidth/2, Land[Loop][5]-AHouse2[Land[Loop][0]-1]->SizeInPixels().iHeight+18), AHouse2[Land[Loop][0]-1],sourceRect, AHouse2m, EFalse);
break;
case 3:
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?