J :
* Add a plasma effect on the cards back
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
OBJS = objs/ActionElement.o objs/ActionLayer.o objs/ActionStack.o objs/AIMomirPlayer.o objs/AIPlayer.o objs/AIStats.o objs/Blocker.o objs/CardGui.o objs/CardDescriptor.o objs/CardDisplay.o objs/ConstraintResolver.o objs/Counters.o objs/Credits.o objs/Damage.o objs/DamagerDamaged.o objs/DamageResolverLayer.o objs/DeckDataWrapper.o objs/DeckStats.o objs/DuelLayers.o objs/ExtraCost.o objs/GameApp.o objs/GameLauncher.o objs/GameObserver.o objs/GameOptions.o objs/GameStateDuel.o objs/GameStateMenu.o objs/GameStateOptions.o objs/GameStateShop.o objs/GuiCardsController.o objs/GuiLayers.o objs/Logger.o objs/ManaCost.o objs/ManaCostHybrid.o objs/MenuItem.o objs/MTGAbility.o objs/MTGCardInstance.o objs/MTGCard.o objs/MTGDeck.o objs/MTGDefinitions.o objs/MTGGamePhase.o objs/MTGGameZones.o objs/MTGGuiHand.o objs/MTGGuiPlay.o objs/MTGRules.o objs/OptionItem.o objs/PhaseRing.o objs/Player.o objs/PlayerData.o objs/PlayGuiObjectController.o objs/PlayGuiObject.o objs/PriceList.o objs/ShopItem.o objs/SimpleMenu.o objs/SimpleMenuItem.o objs/Subtypes.o objs/TargetChooser.o objs/TargetsList.o objs/TextScroller.o objs/TexturesCache.o objs/Token.o objs/Translate.o objs/utils.o objs/WEvent.o
|
||||
OBJS = objs/ActionElement.o objs/ActionLayer.o objs/ActionStack.o objs/AIMomirPlayer.o objs/AIPlayer.o objs/AIStats.o objs/Blocker.o objs/CardGui.o objs/CardDescriptor.o objs/CardDisplay.o objs/CardEffect.o objs/ConstraintResolver.o objs/Counters.o objs/Credits.o objs/Damage.o objs/DamagerDamaged.o objs/DamageResolverLayer.o objs/DeckDataWrapper.o objs/DeckStats.o objs/DuelLayers.o objs/ExtraCost.o objs/GameApp.o objs/GameLauncher.o objs/GameObserver.o objs/GameOptions.o objs/GameStateDuel.o objs/GameStateMenu.o objs/GameStateOptions.o objs/GameStateShop.o objs/GuiCardsController.o objs/GuiLayers.o objs/Logger.o objs/ManaCost.o objs/ManaCostHybrid.o objs/MenuItem.o objs/MTGAbility.o objs/MTGCardInstance.o objs/MTGCard.o objs/MTGDeck.o objs/MTGDefinitions.o objs/MTGGamePhase.o objs/MTGGameZones.o objs/MTGGuiHand.o objs/MTGGuiPlay.o objs/MTGRules.o objs/OptionItem.o objs/PhaseRing.o objs/Player.o objs/PlayerData.o objs/PlayGuiObjectController.o objs/PlayGuiObject.o objs/PriceList.o objs/ShopItem.o objs/SimpleMenu.o objs/SimpleMenuItem.o objs/Subtypes.o objs/TargetChooser.o objs/TargetsList.o objs/TextScroller.o objs/TexturesCache.o objs/Token.o objs/Translate.o objs/utils.o objs/WEvent.o
|
||||
DEPS = $(patsubst objs/%.o, deps/%.d, $(OBJS))
|
||||
|
||||
RESULT = $(shell psp-config --psp-prefix 2> Makefile.cache)
|
||||
|
||||
26
projects/mtg/include/CardEffect.h
Normal file
26
projects/mtg/include/CardEffect.h
Normal file
@@ -0,0 +1,26 @@
|
||||
#ifndef _CARDEFFECT_H_
|
||||
#define _CARDEFFECT_H_
|
||||
|
||||
#include <JGE.h>
|
||||
#include "Effects.h"
|
||||
|
||||
class CardEffect : public Effect
|
||||
{
|
||||
public:
|
||||
CardEffect();
|
||||
~CardEffect();
|
||||
private:
|
||||
static PIXEL_TYPE surface[MTG_IMAGE_WIDTH*MTG_IMAGE_HEIGHT];
|
||||
unsigned char sineTable1[256];
|
||||
unsigned char sineTable2[256];
|
||||
PIXEL_TYPE palette[256];
|
||||
JTexture * backTexture;
|
||||
JTexture * backThumbTexture;
|
||||
|
||||
public:
|
||||
void UpdateSmall(float dt);
|
||||
void UpdateBig(float dt);
|
||||
};
|
||||
|
||||
|
||||
#endif // _CARDEFFECT_H_
|
||||
9
projects/mtg/include/Effects.h
Normal file
9
projects/mtg/include/Effects.h
Normal file
@@ -0,0 +1,9 @@
|
||||
#ifndef _EFFECTS_H_
|
||||
#define _EFFECTS_H_
|
||||
|
||||
class Effect
|
||||
{
|
||||
|
||||
};
|
||||
|
||||
#endif // _EFFECTS_H_
|
||||
@@ -33,6 +33,8 @@
|
||||
|
||||
#include "../include/TexturesCache.h"
|
||||
|
||||
#include "../include/CardEffect.h"
|
||||
|
||||
#define MAX_STATE 6
|
||||
|
||||
|
||||
@@ -62,12 +64,13 @@ class GameApp: public JApp
|
||||
GameState* mNextState;
|
||||
GameState* mGameStates[MAX_STATE];
|
||||
|
||||
|
||||
public:
|
||||
int players[2];
|
||||
MTGAllCards * collection;
|
||||
int gameType;
|
||||
TexturesCache * cache;
|
||||
CardEffect *effect;
|
||||
|
||||
|
||||
GameApp();
|
||||
virtual ~GameApp();
|
||||
|
||||
@@ -56,7 +56,6 @@ class GameStateDeckViewer: public GameState, public JGuiListener
|
||||
|
||||
int colorFilter;
|
||||
JMusic * bgMusic;
|
||||
JTexture * backTex;
|
||||
JQuad * backQuad;
|
||||
SimpleMenu * welcome_menu;
|
||||
JLBFont * mFont;
|
||||
@@ -182,9 +181,7 @@ class GameStateDeckViewer: public GameState, public JGuiListener
|
||||
pspIcons[i]->SetHotSpot(16,16);
|
||||
}
|
||||
|
||||
|
||||
backTex = JRenderer::GetInstance()->LoadTexture("sets/back.jpg", TEX_TYPE_USE_VRAM);
|
||||
backQuad = NEW JQuad(backTex, 0, 0, 200, 285); // Create quad for rendering.
|
||||
backQuad = GameApp::CommonRes->GetQuad("back");
|
||||
|
||||
//menuFont = NEW JLBFont("graphics/f3",16);
|
||||
menuFont = GameApp::CommonRes->GetJLBFont("graphics/f3");
|
||||
@@ -238,8 +235,6 @@ class GameStateDeckViewer: public GameState, public JGuiListener
|
||||
JSoundSystem::GetInstance()->StopMusic(GameApp::music);
|
||||
SAFE_DELETE(GameApp::music);
|
||||
}
|
||||
SAFE_DELETE(backTex);
|
||||
SAFE_DELETE(backQuad);
|
||||
SAFE_DELETE(welcome_menu);
|
||||
SAFE_DELETE(menu);
|
||||
SAFE_DELETE(pspIconsTexture);
|
||||
@@ -275,6 +270,7 @@ class GameStateDeckViewer: public GameState, public JGuiListener
|
||||
|
||||
virtual void Update(float dt)
|
||||
{
|
||||
mParent->effect->UpdateBig(dt);
|
||||
hudAlpha = 255-(last_user_activity * 500);
|
||||
if (hudAlpha < 0) hudAlpha = 0;
|
||||
if (sellMenu){
|
||||
|
||||
@@ -24,7 +24,6 @@ class GameStateShop: public GameState, public JGuiListener
|
||||
JQuad * mBg;
|
||||
JTexture * bgTexture;
|
||||
JQuad * mBack;
|
||||
JTexture * backTexture;
|
||||
SimpleMenu * menu;
|
||||
int mStage;
|
||||
char starterBuffer[128], boosterBuffer[128];
|
||||
|
||||
@@ -7,6 +7,9 @@
|
||||
#define MTG_IMAGE_WIDTH 200
|
||||
#define MTG_IMAGE_HEIGHT 285
|
||||
|
||||
#define MTG_MINIIMAGE_WIDTH 45
|
||||
#define MTG_MINIIMAGE_HEIGHT 64
|
||||
|
||||
|
||||
#define MAX_TYPES_PER_CARD 10
|
||||
|
||||
|
||||
@@ -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
projects/mtg/src/CardEffect.cpp
Normal file
58
projects/mtg/src/CardEffect.cpp
Normal 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);
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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,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){
|
||||
|
||||
Reference in New Issue
Block a user