* Add a plasma effect on the cards back
This commit is contained in:
jean.chalard
2009-05-30 14:06:52 +00:00
parent 5de26cc509
commit b4d040b263
13 changed files with 145 additions and 51 deletions
+29 -31
View File
@@ -33,7 +33,7 @@ MTGAbility * AIMomirPlayer::getMomirAbility(){
}
int AIMomirPlayer::momir(){
if (!game->hand->nb_cards) return 0; //nothing to discard :/
if (!game->hand->nb_cards) return 0; //nothing to discard :/
int result = 0;
int opponentCreatures = getCreaturesInfo(opponent(), INFO_NBCREATURES);
int myCreatures = getCreaturesInfo(this, INFO_NBCREATURES );
@@ -68,9 +68,9 @@ int AIMomirPlayer::computeActions(){
Another gift from Alex Majlaton on my first day playing Momir, and it has served me well ever since. It goes a little something like this: (a) if you are on the play, hit your Two through Four, skip your Five, and then hit all the way to Eight; (b) if you are on the draw and your opponent skips his One, you make Two through Eight; (c) if you are on the draw and your opponent hits a One, you match him drop-for-drop for the rest of the game.
You skip your Five on the play because it is the weakest drop. There are plenty of serviceable guys there, but very few bombs compared to other drops
the general rule is this: if you want to get to Eight, you have to skip two drops on the play and one drop on the draw.
the general rule is this: if you want to get to Eight, you have to skip two drops on the play and one drop on the draw.
*/
GameObserver * g = GameObserver::GetInstance();
GameObserver * g = GameObserver::GetInstance();
Player * p = g->currentPlayer;
if (!(g->currentlyActing() == this)) return 0;
if (chooseTarget()) return 1;
@@ -81,38 +81,36 @@ GameObserver * g = GameObserver::GetInstance();
}else if (p == this && g->mLayers->stackLayer()->count(0,NOT_RESOLVED) == 0){ //standard actions
CardDescriptor cd;
MTGCardInstance * card = NULL;
//No mana, try to get some
getPotentialMana();
//No mana, try to get some
getPotentialMana();
switch(currentGamePhase){
case Constants::MTG_PHASE_FIRSTMAIN:
if (canPutLandsIntoPlay && (potentialMana->getConvertedCost() <8 || game->hand->nb_cards > 1) ){
//Attempt to put land into play
cd.init();
cd.setColor(Constants::MTG_COLOR_LAND);
card = cd.match(game->hand);
if (card){
MTGAbility * putIntoPlay = g->mLayers->actionLayer()->getAbility(MTGAbility::PUT_INTO_PLAY);
AIAction * a = NEW AIAction(putIntoPlay,card); //TODO putinplay action
clickstream.push(a);
return 1;
}
}
momir();
return 1;
break;
case Constants::MTG_PHASE_SECONDMAIN:
selectAbility();
return 1;
break;
default:
return AIPlayerBaka::computeActions();
break;
}
}else{
return AIPlayerBaka::computeActions();
if (canPutLandsIntoPlay && (potentialMana->getConvertedCost() <8 || game->hand->nb_cards > 1) ){
//Attempt to put land into play
cd.init();
cd.setColor(Constants::MTG_COLOR_LAND);
card = cd.match(game->hand);
if (card){
MTGAbility * putIntoPlay = g->mLayers->actionLayer()->getAbility(MTGAbility::PUT_INTO_PLAY);
AIAction * a = NEW AIAction(putIntoPlay,card); //TODO putinplay action
clickstream.push(a);
return 1;
}
}
momir();
return 1;
break;
case Constants::MTG_PHASE_SECONDMAIN:
selectAbility();
return 1;
break;
default:
return AIPlayerBaka::computeActions();
break;
}
}
return AIPlayerBaka::computeActions();
}
/*
+58
View File
@@ -0,0 +1,58 @@
#include "../include/GameApp.h"
#include "../include/MTGCard.h"
#include "../include/CardEffect.h"
PIXEL_TYPE CardEffect::surface[] = {};
CardEffect::CardEffect()
{
backTexture = GameApp::CommonRes->GetQuad("back")->mTex;
backThumbTexture = GameApp::CommonRes->GetQuad("back_thumb")->mTex;
for (int i = sizeof(palette)/sizeof(palette[0]) - 1; i >= 0; --i)
{
sineTable1[i] = 127 + 127 * sinf(2*M_PI*((float)i)/256.0) * sinf(2*M_PI*((float)i)/256.0);
sineTable2[i] = 127 + 127 * sinf(M_PI * sinf(2*M_PI*((float)i)/256.0));
palette[i] = ARGB(((unsigned char)(191 + 64 * (sinf(M_PI*sinf(2*M_PI*((float)i)/256.0)/2)))),
0,
((unsigned char)(64 + 64 * (cosf(M_PI*sinf(2*M_PI*((float)i)/256.0)/2)))),
(unsigned char)(255 * (0.5 + sinf(2*M_PI*((float)i)/256.0)/2) * (0.5 + sinf(2*M_PI*((float)i)/256.0)/2))
);
}
}
CardEffect::~CardEffect()
{
}
void CardEffect::UpdateSmall(float dt)
{
static float t = 0;
t += 3*dt;
unsigned char c = (unsigned char)(5*t);
for (int j = MTG_MINIIMAGE_HEIGHT - 1; j >= 0; --j)
for (int i = MTG_MINIIMAGE_WIDTH - 1; i >= 0; --i)
{
unsigned int r = c + sineTable1[0xFF & (c + i*2)] + sineTable1[0xFF & ((j+i)*sineTable1[c]/128)];
r %= 255;
surface[MTG_MINIIMAGE_WIDTH*j+i] = palette[r];
}
backThumbTexture->UpdateBits(0, 0, MTG_MINIIMAGE_WIDTH, MTG_MINIIMAGE_HEIGHT, surface);
}
void CardEffect::UpdateBig(float dt)
{
static float t = 0;
t += 3*dt;
unsigned char c = (unsigned char)(9*t);
for (int j = MTG_IMAGE_HEIGHT - 1; j >= 0; --j)
for (int i = MTG_IMAGE_WIDTH - 1; i >= 0; --i)
{
unsigned int r = 2*c + sineTable2[0xFF & (i/2+j/2)] + sineTable1[0xFF & (j/2*(j/3+sineTable2[c])/256)];
r %= 255;
surface[MTG_IMAGE_WIDTH*j+i] = palette[r];
}
backTexture->UpdateBits(0, 0, MTG_IMAGE_WIDTH, MTG_IMAGE_HEIGHT, surface);
}
+3 -3
View File
@@ -92,7 +92,7 @@ void GameApp::Create()
CommonRes->CreateTexture("sets/back.jpg");
CommonRes->CreateQuad("back", "sets/back.jpg", 0, 0, 200, 285);
CommonRes->CreateTexture("sets/back_thumb.jpg");
CommonRes->CreateQuad("back_thumb", "sets/back_thumb.jpg", 0, 0, 45, 64);
CommonRes->CreateQuad("back_thumb", "sets/back_thumb.jpg", 0, 0, MTG_MINIIMAGE_WIDTH, MTG_MINIIMAGE_HEIGHT);
CommonRes->CreateTexture("graphics/particles.png");
CommonRes->CreateQuad("particles", "graphics/particles.png", 0, 0, 32, 32);
@@ -145,6 +145,8 @@ void GameApp::Create()
mCurrentState = NULL;
mNextState = mGameStates[GAME_STATE_MENU];
effect = new CardEffect();
char buf[512];
sprintf(buf, "size of MTGCardInstance : %i\n" , sizeof(MTGCardInstance));
OutputDebugString(buf);
@@ -219,8 +221,6 @@ void GameApp::Update()
return;
}
float dt = mEngine->GetDelta();
if (dt > 35.0f) // min 30 FPS ;)
dt = 35.0f;
+5 -1
View File
@@ -328,6 +328,7 @@ void GameStateDuel::Update(float dt)
}
}
}
mParent->effect->UpdateSmall(dt);
game->Update(dt);
if (game->gameOver){
credits->compute(mPlayers[0],mPlayers[1], mParent);
@@ -354,15 +355,18 @@ void GameStateDuel::Update(float dt)
}
break;
case DUEL_STATE_MENU:
mParent->effect->UpdateSmall(dt);
menu->Update(dt);
break;
case DUEL_STATE_CANCEL:
mParent->effect->UpdateSmall(dt);
menu->Update(dt);
if (menu->closed)
mGamePhase = DUEL_STATE_PLAY;
break;
case DUEL_STATE_BACK_TO_MAIN_MENU:
menu->Update(dt);
mParent->effect->UpdateSmall(dt);
menu->Update(dt);
if (menu->closed)
mParent->SetNextState(GAME_STATE_MENU);
break;
+3 -4
View File
@@ -34,8 +34,7 @@ void GameStateShop::Start()
bgTexture = JRenderer::GetInstance()->LoadTexture("graphics/shop.jpg", TEX_TYPE_USE_VRAM);
mBg = NEW JQuad(bgTexture, 0, 0, 400, 280); // Create background quad for rendering.
backTexture = JRenderer::GetInstance()->LoadTexture("sets/back.jpg", TEX_TYPE_USE_VRAM);
mBack = NEW JQuad(backTexture, 0, 0, 200, 285); // Create background quad for rendering.
mBack = GameApp::CommonRes->GetQuad("back");
JRenderer::GetInstance()->ResetPrivateVRAM();
JRenderer::GetInstance()->EnableVSync(true);
@@ -79,8 +78,6 @@ void GameStateShop::End()
{
JRenderer::GetInstance()->EnableVSync(false);
SAFE_DELETE(shop);
SAFE_DELETE(mBack);
SAFE_DELETE(backTexture);
SAFE_DELETE(bgTexture);
SAFE_DELETE(mBg);
SAFE_DELETE(menu);
@@ -92,6 +89,8 @@ void GameStateShop::Destroy(){
void GameStateShop::Update(float dt)
{
mParent->effect->UpdateSmall(dt);
mParent->effect->UpdateBig(dt);
if (mStage == STAGE_SHOP_MENU){
if (menu){
menu->Update(dt);
+2 -3
View File
@@ -2,6 +2,7 @@
cards in play, graveyard, library, games phases, Players avatars
*/
#include <math.h>
#include "../include/config.h"
#include "../include/MTGGuiPlay.h"
#include "../include/MTGCardInstance.h"
@@ -66,6 +67,7 @@ MTGGuiPlay::MTGGuiPlay(int id, GameObserver * _game):PlayGuiObjectController(id,
mBg2 = NULL;
GameApp::systemError = "error Loading Texture mBgTex2 in MTGGuiPlay intialization";
}
alphaBg[0] = 0;
AddPlayersGuiInfo();
}
@@ -250,11 +252,8 @@ void MTGGuiPlay::updateCards(){
setTargettingCardPosition(cardGui, 1, !player0Mode);
}
}
void MTGGuiPlay::AddPlayersGuiInfo(){
//init with the players objects
if (mCount == 0){