diff --git a/Assets/Images/Game/Stages/GreenHill/bg.png b/Assets/Images/Game/Stages/GreenHill/bg.png new file mode 100644 index 0000000..2430283 Binary files /dev/null and b/Assets/Images/Game/Stages/GreenHill/bg.png differ diff --git a/Assets/Images/Game/Stages/GreenHill/mainstage.png b/Assets/Images/Game/Stages/GreenHill/mainstage.png new file mode 100644 index 0000000..e554542 Binary files /dev/null and b/Assets/Images/Game/Stages/GreenHill/mainstage.png differ diff --git a/Assets/Images/Menus/StageSelect/greenhill.png b/Assets/Images/Menus/StageSelect/greenhill.png new file mode 100644 index 0000000..162dc8d Binary files /dev/null and b/Assets/Images/Menus/StageSelect/greenhill.png differ diff --git a/Assets/Music/Sonic the Hedgehog/Green Hill Zone.mp3 b/Assets/Music/Sonic the Hedgehog/Green Hill Zone.mp3 new file mode 100644 index 0000000..e17be97 Binary files /dev/null and b/Assets/Music/Sonic the Hedgehog/Green Hill Zone.mp3 differ diff --git a/Global.h b/Global.h new file mode 100644 index 0000000..f363c4a --- /dev/null +++ b/Global.h @@ -0,0 +1,158 @@ + +#include "../Game.h" +#include "SmashForwards.h" +#include "Player.h" +#include "Stage.h" +#include "HUD.h" + +#pragma once + +namespace SmashBros +{ + class Global + { + friend class Game; + friend class GameScreen; + public: + static const int possPlayers = 4; + static const int possTeams = 4; + + static long worldTime; + + static int*players; + + static Player**characters; + static byte*currentTeams; + static int*scores; + static int*KOs; + static int*deaths; + static int*winners; + static int*teamWinners; + static Stage*currentStage; + + static HUD*hud; + + static int charAmount; + + static int*selectedChar; + static int selectedStage; + + static ArrayList stageVotes; + static boolean peerReadyToPlay; + static boolean selfReadyToPlay; + static boolean peerLoaded; + static boolean selfLoaded; + static String P2PMessage; + + static boolean gamePlaying; + static boolean gameFinished; + + static boolean suddenDeath; + static ArrayList suddenDeathPlayers; + + static boolean smashBallOnField; + static boolean playerHasSmashBall; + + static boolean*CPU; + static int timeLimit; + static int stockAmount; + static int gameMode; + static int gameType; + static boolean teamBattle; + static long timeAmount; + + static boolean*itemsOn; + static ArrayList itemsActive; + + static int maxLives; + static int minLives; + + static int maxTime; + static int minTime; + + static const int TYPE_TRAINING = 0; + static const int TYPE_GROUPBRAWL = 1; + + static const int MODE_FREEFORALL = 0; + static const int MODE_TIME_LIMIT = 1; + static const int MODE_STOCK = 2; + + static const byte TEAM_RED = 1; + static const byte TEAM_BLUE = 2; + static const byte TEAM_GREEN = 3; + static const byte TEAM_YELLOW = 4; + + static const int totalCharacters = 7; + static const int totalItems = 6; + static const int totalStages = 5; + + //CHARACTER CONSTANTS + static const int CHAR_MARIO = 1; + static const int CHAR_ICHIGO = 2; + static const int CHAR_SONIC = 3; + static const int CHAR_FOX = 4; + static const int CHAR_PIKACHU = 5; + static const int CHAR_LINK = 6; + static const int CHAR_SAMUS = 7; + + //STAGE CONSTANTS + static const int STAGE_FRACTALSTAGE = 0; + static const int STAGE_HILLSIDEBATTLEGROUND = 1; + static const int STAGE_BATTLEFIELDBRAWL = 2; + static const int STAGE_FINALDESTINATION = 3; + static const int STAGE_HYRULETEMPLE = 4; + static const int STAGE_CORNERIA = 5; + + //ITEM CONSTANTS + static const int ITEM_CUSTOM = 0; + static const int ITEM_SMASHBALL = 1; + static const int ITEM_RAYGUN = 2; + static const int ITEM_HEARTCONTAINER = 3; + static const int ITEM_BEAMSWORD = 4; + static const int ITEM_SUPERMUSHROOM = 5; + static const int ITEM_POISONMUSHROOM = 6; + + static void onReturnToMenu(); + + static String getDirText(byte dir); + static String getAddonsFolder(); + + static long getWorldTime(); + + static void Update(long gameTime); + + static String getPlayerName(int playerNo); + + static boolean isInSuddenDeath(byte playerNo); + + static void scorePoint(byte pNum); + + static void UnloadGame(); + static void LoadGame(); + + static Player*getPlayerActor(int pNum); + static String getItemName(int itemNo); + + static boolean checkWinners(byte pNum); + + static void finishBrawl(); + + static void finishGame(); + static void finishGameSoloTraining(); + static void finishGameSuddenDeath(); + + private: + static void init(); + + static void createHUD(); + + static void createPlayers(); + + static boolean checkWinnersFreeForAll(byte pNum); + static boolean checkWinnersSuddenDeath(byte pNum); + + static void finishGameFreeForAll(); + static void finishGameTeam(); + }; +} + diff --git a/Loader.cpp b/Loader.cpp new file mode 100644 index 0000000..118dd57 --- /dev/null +++ b/Loader.cpp @@ -0,0 +1,391 @@ + +#include "Loader.h" + +#include "Game/Characters/Mario.h" +#include "Game/Characters/Sonic.h" +#include "Game/Characters/Ichigo.h" +#include "Game/Characters/Fox.h" +#include "Game/Characters/Pikachu.h" +#include "Game/Characters/Link.h" + +#include "Game/Stages/FractalStage.h" +#include "Game/Stages/HillsideBattleground.h" +#include "Game/Stages/BattlefieldBrawl.h" +#include "Game/Stages/FinalDestinationBrawl.h" +#include "Game/Stages/HyruleTemple.h" +#include "Game/Stages/Corneria.h" + +#ifndef SMASHBROS_SCRIPT_DISABLE +#include "../ScriptModule/ScriptManager.h" +#include "../ScriptModule/modules/SmashBros/inherit/lib_sb_inherit_Stage.h" +#endif //SMASHBROS_SCRIPT_DISABLE + +namespace SmashBros +{ + String CharacterLoader::getMenuFilename(int charNo) + { + switch(charNo) + { + case Global::CHAR_MARIO: + return "mario.png"; + + case Global::CHAR_ICHIGO: + return "ichigo.png"; + + case Global::CHAR_SONIC: + return "sonic.png"; + + case Global::CHAR_FOX: + return "fox.png"; + + case Global::CHAR_PIKACHU: + return "pikachu.png"; + + case Global::CHAR_LINK: + return "link.png"; + + default: + if(charNo <= Global::totalCharacters) + { + return "random.png"; + } + else + { + //TODO implement getting of Scripted Players here. + return "random.png"; + } + break; + } + } + + String CharacterLoader::getFolder(int charNo) + { + return (String)"Images/Game/Characters/" + getName(charNo); + } + + String CharacterLoader::getName(int charNo) + { + switch(charNo) + { + default: + return ""; + + case Global::CHAR_MARIO: + return "Mario"; + + case Global::CHAR_ICHIGO: + return "Ichigo"; + + case Global::CHAR_SONIC: + return "Sonic"; + + case Global::CHAR_FOX: + return "Fox"; + + case Global::CHAR_PIKACHU: + return "Pikachu"; + + case Global::CHAR_LINK: + return "Link"; + } + } + + String CharacterLoader::getIconPath(int charNo) + { + return (String)"Images/Menus/CharacterSelect/icons/" + getMenuFilename(charNo); + } + + String CharacterLoader::getPreviewPath(int charNo) + { + return (String)"Images/Menus/CharacterSelect/previews/" + getMenuFilename(charNo); + } + + Player* CharacterLoader::createPlayer(float x1, float y1, byte playerNo, byte team,int charNum) + { + Player*p = null; + Console::WriteLine((String)"creating character " + charNum); + switch(charNum) + { + case Global::CHAR_MARIO: + p = new Mario(x1,y1,playerNo,team); + p->charNo = Global::CHAR_MARIO; + break; + + case Global::CHAR_ICHIGO: + p = new Ichigo(x1,y1,playerNo,team); + p->charNo = Global::CHAR_ICHIGO; + break; + + case Global::CHAR_SONIC: + p = new Sonic(x1,y1,playerNo,team); + p->charNo = Global::CHAR_SONIC; + break; + + case Global::CHAR_FOX: + p = new Fox(x1,y1,playerNo,team); + p->charNo = Global::CHAR_FOX; + break; + + case Global::CHAR_PIKACHU: + p = new Pikachu(x1,y1,playerNo,team); + p->charNo = Global::CHAR_PIKACHU; + break; + + case Global::CHAR_LINK: + p = new Link(x1,y1,playerNo,team); + p->charNo = Global::CHAR_LINK; + } + return p; + } + + ArrayList CharacterLoader::getWinnersScreenAnimations(int charNo) + { + int win_fps = 1; + int win_rows = 1; + int win_cols = 1; + + int winhold_fps = 1; + int winhold_rows = 1; + int winhold_cols = 1; + + int lose_fps = 4; + int lose_rows = 2; + int lose_cols = 1; + + switch(charNo) + { + case Global::CHAR_MARIO: + win_fps = 8; + win_rows = 8; + break; + + case Global::CHAR_ICHIGO: + win_fps = 6; + win_rows = 5; + lose_fps = 8; + lose_rows = 4; + break; + + case Global::CHAR_SONIC: + win_fps = 5; + win_rows = 6; + lose_fps = 8; + lose_rows = 4; + break; + + case Global::CHAR_FOX: + win_fps = 8; + win_rows = 6; + break; + + case Global::CHAR_PIKACHU: + win_fps = 6; + winhold_fps = 6; + winhold_rows = 10; + break; + + case Global::CHAR_LINK: + win_fps = 8; + win_rows = 4; + break; + } + + String charFolder = getFolder(charNo); + + ArrayList animations; + + Animation* win = new Animation("win", win_fps, win_rows, win_cols); + win->addFrame(charFolder + "/win.png"); + animations.add(win); + + Animation* winhold = new Animation("win_hold", winhold_fps, winhold_rows, winhold_cols); + winhold->addFrame(charFolder + "/win_hold.png"); + animations.add(winhold); + + Animation* lose = new Animation("lose", lose_fps, lose_rows, lose_cols); + lose->addFrame(charFolder + "/lose.png"); + animations.add(lose); + + return animations; + } + + + + //StageLoader + + + +#ifndef SMASHBROS_SCRIPT_DISABLE + ArrayList StageLoader::scriptEntities = ArrayList(); + ArrayList StageLoader::disabledScriptEntities = ArrayList(); + + void StageLoader::loadScriptEntities(const String& path) + { + ArrayList folders = FileTools::getFoldersInDirectory(path); + for(int i=0; iloadFromFile(path + '/' + folderName, errorMessage); + if(success) + { + bool success = ScriptModule::ScriptManager::loadScriptEntity(*info, errorMessage); + if(success) + { + AssetManager::loadImage(info->getPath() + '/' + info->getIcon()); + scriptEntities.add(info); + } + else + { + Game::showMessage("Error", (String)"Unable to load ScriptModule \"" + folderName + "\": " + errorMessage); + delete info; + } + } + else + { + Game::showMessage("Error", (String)"Unable to load ScriptModule \"" + folderName + "\": " + errorMessage); + delete info; + } + } + } + + for(int i=0; igetMainScript().name.compare(info2->getMainScript().name) == 1) + { + scriptEntities.set(j-1, info2); + scriptEntities.set(j, info1); + } + else if(info1->getCreator().compare(info2->getCreator()) == 1) + { + scriptEntities.set(j-1, info2); + scriptEntities.set(j, info1); + } + else if(info1->getVersion().compare(info2->getVersion()) == 1) + { + scriptEntities.set(j-1, info2); + scriptEntities.set(j, info1); + } + } + } + } + + void StageLoader::unloadScriptEntities() + { + for(int i=0; igetPath() + '/' + info->getIcon()); + delete info; + } + scriptEntities.clear(); + } + + void StageLoader::setDisabledScriptEntities(const ArrayList& disabled) + { + disabledScriptEntities = disabled; + } + + ArrayList StageLoader::getScriptEntities() + { + ArrayList entities; + for(int i=0; i Global::totalStages) + { + //TODO add loading of scripted stages + int scriptStageNum = stageNum - Global::totalStages - 1; + ArrayList entities = getScriptEntities(); + ScriptModule::ScriptEntityInfo* entityInfo = entities.get(scriptStageNum); + String scriptPath = entityInfo->getPath() + '/' + entityInfo->getMainScript().script; + ScriptModule::ScriptData* scriptData = ScriptModule::ScriptManager::getScriptData(scriptPath); + SCRIPTMGR_ERRORHANDLE(return SCRIPTEDCLASS_NEWFUNCTION_CALL(Stage)(scriptData, x1, y1, std::vector());, "TemplateStage.chai", ) + } +#endif //SMASHBROS_SCRIPT_DISABLE + return null; + } + return null; + } +} diff --git a/Source/SmashBros/Game/Stages/GreenHill.cpp b/Source/SmashBros/Game/Stages/GreenHill.cpp new file mode 100644 index 0000000..e45ad7e --- /dev/null +++ b/Source/SmashBros/Game/Stages/GreenHill.cpp @@ -0,0 +1,66 @@ + +#include "GreenHill.h" + +namespace SmashBros +{ + GreenHill::GreenHill(float x1, float y1) : Stage(x1, y1) + { + setSpawnPoint(0, 0,0); + setSpawnPoint(1, 115, -70); + setSpawnPoint(2, -115, -70); + setSpawnPoint(3, 0,-135); + setSpawnPoint(4, 0, -35); + + bottomViewBorder = 276; + topViewBorder = -276; + leftViewBorder = -400; + rightViewBorder = 400; + + topBorder = -420; + + setItemBoundaries(-200, -225, 200, 60); + + loadGameElements(); + loadPlatforms(); + loadHangPoints(); + + setBackground("Images/Game/Stages/GreenHill/bg.png"); + setBackgroundScale(1.45); + setBackgroundType(BG_FIXED); + + //this.setWireframeColor(Color.blue); + //this.showWireframes(true); + + MusicManager::loadSong("Green Hill Zone"); + } + + GreenHill::~GreenHill() + { + // + } + + void GreenHill::loadGameElements() + { + GameElement*bg; + + bg = new GameElement(0,30); + Animation*anim = new Animation("normal", 1,1,1); + anim->addFrame("Images/Game/Stages/GreenHill/mainstage.png"); + bg->addAnimation(anim); + bg->changeAnimation("normal", FORWARD); + addElement(bg); + } + + void GreenHill::loadPlatforms() + { + } + + void GreenHill::loadHangPoints() + { + } + + void GreenHill::Draw(Graphics2D&g, long gameTime) + { + Stage::Draw(g, gameTime); + } +} diff --git a/Source/SmashBros/Game/Stages/GreenHill.h b/Source/SmashBros/Game/Stages/GreenHill.h new file mode 100644 index 0000000..fb21dbe --- /dev/null +++ b/Source/SmashBros/Game/Stages/GreenHill.h @@ -0,0 +1,21 @@ + +#include "../../Stage.h" + +#pragma once + +namespace SmashBros +{ + class GreenHill : public Stage + { + private: + void loadGameElements(); + void loadPlatforms(); + void loadHangPoints(); + + public: + GreenHill(float x1, float y1); + virtual ~GreenHill(); + + virtual void Draw(Graphics2D&g, long gameTime); + }; +} diff --git a/Source/SmashBros/Global.h b/Source/SmashBros/Global.h index b830bb3..06c1c2a 100755 --- a/Source/SmashBros/Global.h +++ b/Source/SmashBros/Global.h @@ -84,7 +84,7 @@ namespace SmashBros static const int totalCharacters = 6; static const int totalItems = 6; - static const int totalStages = 5; + static const int totalStages = 6; //CHARACTER CONSTANTS static const int CHAR_MARIO = 1; @@ -101,6 +101,7 @@ namespace SmashBros static const int STAGE_FINALDESTINATION = 3; static const int STAGE_HYRULETEMPLE = 4; static const int STAGE_CORNERIA = 5; + static const int STAGE_GREENHILL = 6; //ITEM CONSTANTS static const int ITEM_CUSTOM = 0; diff --git a/Source/SmashBros/Loader.cpp b/Source/SmashBros/Loader.cpp index 118dd57..4d3b8fc 100755 --- a/Source/SmashBros/Loader.cpp +++ b/Source/SmashBros/Loader.cpp @@ -14,6 +14,7 @@ #include "Game/Stages/FinalDestinationBrawl.h" #include "Game/Stages/HyruleTemple.h" #include "Game/Stages/Corneria.h" +#include "Game/Stages/GreenHill.h" #ifndef SMASHBROS_SCRIPT_DISABLE #include "../ScriptModule/ScriptManager.h" @@ -341,6 +342,9 @@ namespace SmashBros case Global::STAGE_CORNERIA: return "corneria.png"; + + case Global::STAGE_GREENHILL: + return "greenhill.png"; } } @@ -370,6 +374,9 @@ namespace SmashBros case Global::STAGE_CORNERIA: return new Corneria(x1,y1); + + case Global::STAGE_GREENHILL: + return new GreenHill(x1,y1); default: #ifndef SMASHBROS_SCRIPT_DISABLE diff --git a/Source/SmashBros/Menus/Menus.cpp b/Source/SmashBros/Menus/Menus.cpp index 1fc2095..318edad 100755 --- a/Source/SmashBros/Menus/Menus.cpp +++ b/Source/SmashBros/Menus/Menus.cpp @@ -197,6 +197,7 @@ namespace SmashBros MusicManager::addSong("Zelda Theme", "Music/Legend of Zelda/Main Theme.ogg"); MusicManager::addSong("Zelda Theme Remix", "Music/Legend of Zelda/Main Theme Remix.ogg"); + MusicManager::addSong("Green Hill Zone", "Music/Sonic the Hedgehog/Green Hill Zone.mp3"); MusicManager::loadSong("Main Theme");