@ -338,49 +338,184 @@ void VirusAttack::InitializeLevelData(){
positions . erase ( positions . begin ( ) + randomIndex ) ;
types . erase ( types . begin ( ) + randomIndex2 ) ;
}
collectionPoints . push_back ( CPData { { 8 * 24 , 1 * 24 } , 0 , MemoryType : : HEALTH } ) ;
collectionPoints . push_back ( CPData { { 10 * 24 , 1 * 24 } , 0 , MemoryType : : HEALTH } ) ;
collectionPoints . push_back ( CPData { { 32 * 24 , 12 * 24 } , 0 , MemoryType : : HEALTH } ) ;
collectionPoints . push_back ( CPData { { 20 * 24 , 32 * 24 } , 0 , MemoryType : : HEALTH } ) ;
collectionPoints . push_back ( CPData { { 9 * 24 , 1 * 24 } , 0 , MemoryType : : PROCEDURE } ) ;
collectionPoints . push_back ( CPData { { 1 * 24 , 7 * 24 } , - PI / 2 , MemoryType : : PROCEDURE } ) ;
collectionPoints . push_back ( CPData { { 16 * 24 , 16 * 24 } , 0 , MemoryType : : PROCEDURE } ) ;
collectionPoints . push_back ( CPData { { 36 * 24 , 1 * 24 } , - PI / 2 , MemoryType : : PROCEDURE } ) ;
collectionPoints . push_back ( CPData { { 1 * 24 , 3 * 24 } , - PI / 2 , MemoryType : : RANGE } ) ;
collectionPoints . push_back ( CPData { { 1 * 24 , 6 * 24 } , - PI / 2 , MemoryType : : ATKSPD } ) ;
collectionPoints . push_back ( CPData { { 1 * 24 , 11 * 24 } , - PI / 2 , MemoryType : : MOVESPD } ) ;
collectionPoints . push_back ( CPData { { 1 * 24 , 22 * 24 } , - PI / 2 , MemoryType : : RANGE } ) ;
collectionPoints . push_back ( CPData { { 6 * 24 , 16 * 24 } , - PI / 2 , MemoryType : : ATKSPD } ) ;
collectionPoints . push_back ( CPData { { 1 * 24 , 32 * 24 } , - PI / 2 , MemoryType : : MOVESPD } ) ;
collectionPoints . push_back ( CPData { { ( 48 - 1 ) * 24 , ( 48 - 4 ) * 24 } , PI / 2 , MemoryType : : RANGE } ) ;
collectionPoints . push_back ( CPData { { ( 48 - 1 ) * 24 , ( 48 - 7 ) * 24 } , PI / 2 , MemoryType : : ATKSPD } ) ;
collectionPoints . push_back ( CPData { { ( 48 - 1 ) * 24 , ( 48 - 12 ) * 24 } , PI / 2 , MemoryType : : MOVESPD } ) ;
collectionPoints . push_back ( CPData { { ( 48 - 1 ) * 24 , ( 48 - 23 ) * 24 } , PI / 2 , MemoryType : : RANGE } ) ;
collectionPoints . push_back ( CPData { { ( 48 - 6 ) * 24 , ( 48 - 17 ) * 24 } , PI / 2 , MemoryType : : ATKSPD } ) ;
collectionPoints . push_back ( CPData { { ( 48 - 1 ) * 24 , ( 48 - 33 ) * 24 } , PI / 2 , MemoryType : : MOVESPD } ) ;
collectionPoints . push_back ( CPData { { ( 48 - 8 ) * 24 , ( 48 - 2 ) * 24 } , PI , MemoryType : : HEALTH } ) ;
collectionPoints . push_back ( CPData { { ( 48 - 10 ) * 24 , ( 48 - 2 ) * 24 } , PI , MemoryType : : HEALTH } ) ;
collectionPoints . push_back ( CPData { { ( 48 - 32 ) * 24 , ( 48 - 13 ) * 24 } , PI , MemoryType : : HEALTH } ) ;
collectionPoints . push_back ( CPData { { ( 48 - 20 ) * 24 , ( 48 - 33 ) * 24 } , PI , MemoryType : : HEALTH } ) ;
collectionPoints . push_back ( CPData { { ( 48 - 9 ) * 24 , ( 48 - 2 ) * 24 } , PI , MemoryType : : PROCEDURE } ) ;
collectionPoints . push_back ( CPData { { ( 48 - 1 ) * 24 , ( 48 - 8 ) * 24 } , PI / 2 , MemoryType : : PROCEDURE } ) ;
collectionPoints . push_back ( CPData { { ( 48 - 16 ) * 24 , ( 48 - 17 ) * 24 } , PI , MemoryType : : PROCEDURE } ) ;
collectionPoints . push_back ( CPData { { ( 48 - 36 ) * 24 , ( 48 - 2 ) * 24 } , PI / 2 , MemoryType : : PROCEDURE } ) ;
for ( int i = 0 ; i < 5 ; i + + ) {
units . push_back ( { UnitType : : MemoryAllocator , vf2d { 44 * 24 , 44 * 24 } , false } ) ;
}
units . push_back ( { UnitType : : Turret , vf2d { 42 * 24 , 42 * 24 } , false } ) ;
units . push_back ( { UnitType : : LeftShifter , vf2d { 42 * 24 , 44 * 24 } , false } ) ;
units . push_back ( { UnitType : : LeftShifter , vf2d { 42 * 24 , 44 * 24 } , false } ) ;
units . push_back ( { UnitType : : Corrupter , vf2d { 42 * 24 , 44 * 24 } , false } ) ;
units . push_back ( { UnitType : : RightShifter , vf2d { 42 * 24 , 44 * 24 } , false } ) ;
units . push_back ( { UnitType : : RightShifter , vf2d { 45 * 24 , 41 * 24 } , false } ) ;
units . push_back ( { UnitType : : RAMBank , vf2d { 44 * 24 , 44 * 24 } , false } ) ;
units . push_back ( { UnitType : : Refresher , vf2d { 2 * 24 , 42 * 24 } , false } ) ;
units . push_back ( { UnitType : : MemoryGuard , vf2d { 7 * 24 , 44 * 24 } , false } ) ;
units . push_back ( { UnitType : : LeftShifter , vf2d { 2 * 24 , 44 * 24 } , false } ) ;
units . push_back ( { UnitType : : LeftShifter , vf2d { 2 * 24 , 44 * 24 } , false } ) ;
units . push_back ( { UnitType : : Corrupter , vf2d { 2 * 24 , 44 * 24 } , false } ) ;
units . push_back ( { UnitType : : RightShifter , vf2d { 2 * 24 , 44 * 24 } , false } ) ;
units . push_back ( { UnitType : : RightShifter , vf2d { 5 * 24 , 41 * 24 } , false } ) ;
units . push_back ( { UnitType : : RAMBank , vf2d { 4 * 24 , 44 * 24 } , false } ) ;
}
}
# pragma endregion
# pragma region Stage 7
{
//Stage 7 data.
LevelName stage = STAGE7 ;
levelData [ stage ] . name = stage ;
levelData [ stage ] . cameraStart = { 96 , 96 } ;
levelData [ stage ] . worldZoom = { 1 , 1 } ;
levelData [ stage ] . size = { 64 , 64 } ;
levelData [ stage ] . levelColor = DARK_RED ;
levelData [ stage ] . bgm = Sound : : BOSS2 ;
levelData [ stage ] . scenarioIndex = int ( stage ) ;
levelData [ stage ] . availableMemory = 960 ;
levelData [ stage ] . player_starting_resources = { 5 , 5 , 5 , 5 , 5 } ;
levelData [ stage ] . enemy_starting_resources = { 5 , 5 , 5 , 5 , 5 } ;
{
std : : vector < UnitData > & units = levelData [ stage ] . unitPlacement ;
std : : vector < CPData > & collectionPoints = levelData [ stage ] . cpPlacement ;
units . push_back ( { UnitType : : RAMBank , vf2d { 4 * 24 , 4 * 24 } , true } ) ;
for ( int i = 0 ; i < 5 ; i + + ) {
units . push_back ( { UnitType : : MemoryAllocator , vf2d { 4 * 24 , 6 * 24 } , true } ) ;
}
std : : vector < vf2d > positions = {
{ { 8 , 1 } , { 10 , 1 } , { 32 , 12 } , { 20 , 32 } , { 9 , 1 } , { 1 , 7 } , { 16 , 16 }
, { 36 , 1 } , { 1 , 3 } , { 1 , 6 } , { 1 , 11 } , { 1 , 22 } , { 6 , 16 } , { 1 , 32 }
, { 14 , 16 } , { 27 , 29 } , { 14 , 12 } , { 7 , 36 } , { 16 , 30 } , { 22 , 19 } , { 39 , 40 } }
} ;
std : : vector < MemoryType > types = {
{ MemoryType : : HEALTH , MemoryType : : HEALTH , MemoryType : : HEALTH , MemoryType : : HEALTH , MemoryType : : PROCEDURE ,
MemoryType : : PROCEDURE , MemoryType : : PROCEDURE , MemoryType : : PROCEDURE , MemoryType : : RANGE ,
MemoryType : : ATKSPD , MemoryType : : MOVESPD , MemoryType : : RANGE , MemoryType : : ATKSPD , MemoryType : : MOVESPD ,
MemoryType : : HEALTH , MemoryType : : HEALTH , MemoryType : : PROCEDURE ,
MemoryType : : PROCEDURE , MemoryType : : ATKSPD , MemoryType : : MOVESPD , MemoryType : : RANGE , }
} ;
if ( positions . size ( ) ! = types . size ( ) ) {
throw ;
}
while ( positions . size ( ) > 0 ) {
int randomIndex = rand ( ) % positions . size ( ) ;
int randomIndex2 = rand ( ) % types . size ( ) ;
float finalDir = 0 ;
if ( positions [ randomIndex ] . x < levelData [ stage ] . size . x / 2 ) {
if ( positions [ randomIndex ] . y < positions [ randomIndex ] . x ) {
finalDir = 0 ;
} else {
finalDir = - PI / 2 ;
}
} else {
if ( positions [ randomIndex ] . y > positions [ randomIndex ] . x ) {
finalDir = PI ;
} else {
finalDir = PI / 2 ;
}
}
collectionPoints . push_back ( CPData { positions [ randomIndex ] * 24 , finalDir , types [ randomIndex2 ] } ) ;
collectionPoints . push_back ( CPData { ( levelData [ stage ] . size - positions [ randomIndex ] - vf2d { 1 , 1 } ) * 24 , float ( finalDir + PI ) , types [ randomIndex2 ] } ) ;
positions . erase ( positions . begin ( ) + randomIndex ) ;
types . erase ( types . begin ( ) + randomIndex2 ) ;
}
units . push_back ( { UnitType : : Turret , vf2d { 52 * 24 , 52 * 24 } , false } ) ;
units . push_back ( { UnitType : : LeftShifter , vf2d { 52 * 24 , 54 * 24 } , false } ) ;
units . push_back ( { UnitType : : LeftShifter , vf2d { 52 * 24 , 54 * 24 } , false } ) ;
units . push_back ( { UnitType : : Corrupter , vf2d { 52 * 24 , 54 * 24 } , false } ) ;
units . push_back ( { UnitType : : RightShifter , vf2d { 52 * 24 , 54 * 24 } , false } ) ;
units . push_back ( { UnitType : : RightShifter , vf2d { 55 * 24 , 51 * 24 } , false } ) ;
units . push_back ( { UnitType : : RAMBank , vf2d { 54 * 24 , 54 * 24 } , false } ) ;
units . push_back ( { UnitType : : RAMBank , vf2d { 54 * 24 , 54 * 24 } , false } ) ;
for ( int i = 0 ; i < 5 ; i + + ) {
units . push_back ( { UnitType : : MemoryAllocator , vf2d { 54 * 24 , 54 * 24 } , false } ) ;
}
units . push_back ( { UnitType : : Turret , vf2d { 53 * 24 , 22 * 24 } , false } ) ;
units . push_back ( { UnitType : : RAMBank , vf2d { 54 * 24 , 24 * 24 } , false } ) ;
for ( int i = 0 ; i < 2 ; i + + ) {
units . push_back ( { UnitType : : MemoryAllocator , vf2d { 54 * 24 , 25 * 24 } , false } ) ;
}
units . push_back ( { UnitType : : RightShifter , vf2d { 53 * 24 , 24 * 24 } , false } ) ;
units . push_back ( { UnitType : : BitRestorer , vf2d { 54 * 24 , 25 * 24 } , false } ) ;
units . push_back ( { UnitType : : RightShifter , vf2d { 54 * 24 , 26 * 24 } , false } ) ;
}
}
# pragma endregion
# pragma region Stage 8
{
//Stage 8 data.
LevelName stage = STAGE8 ;
levelData [ stage ] . name = stage ;
levelData [ stage ] . cameraStart = { 96 , 96 } ;
levelData [ stage ] . worldZoom = { 1 , 1 } ;
levelData [ stage ] . size = { 64 , 64 } ;
levelData [ stage ] . levelColor = DARK_RED ;
levelData [ stage ] . bgm = Sound : : BOSS2 ;
levelData [ stage ] . scenarioIndex = int ( stage ) ;
levelData [ stage ] . availableMemory = 1280 ;
levelData [ stage ] . player_starting_resources = { 5 , 5 , 5 , 5 , 5 } ;
levelData [ stage ] . enemy_starting_resources = { 5 , 5 , 5 , 5 , 5 } ;
{
std : : vector < UnitData > & units = levelData [ stage ] . unitPlacement ;
std : : vector < CPData > & collectionPoints = levelData [ stage ] . cpPlacement ;
units . push_back ( { UnitType : : RAMBank , vf2d { 4 * 24 , 4 * 24 } , true } ) ;
for ( int i = 0 ; i < 5 ; i + + ) {
units . push_back ( { UnitType : : MemoryAllocator , vf2d { 4 * 24 , 6 * 24 } , true } ) ;
}
std : : vector < vf2d > positions = {
{ { 8 , 1 } , { 10 , 1 } , { 32 , 12 } , { 20 , 32 } , { 9 , 1 } , { 1 , 7 } , { 16 , 16 }
, { 36 , 1 } , { 1 , 3 } , { 1 , 6 } , { 1 , 11 } , { 1 , 22 } , { 6 , 16 } , { 1 , 32 }
, { 14 , 16 } , { 27 , 29 } , { 14 , 12 } , { 7 , 36 } , { 16 , 30 } , { 22 , 19 } , { 39 , 40 } }
} ;
std : : vector < MemoryType > types = {
{ MemoryType : : HEALTH , MemoryType : : HEALTH , MemoryType : : HEALTH , MemoryType : : HEALTH , MemoryType : : PROCEDURE ,
MemoryType : : PROCEDURE , MemoryType : : PROCEDURE , MemoryType : : PROCEDURE , MemoryType : : RANGE ,
MemoryType : : ATKSPD , MemoryType : : MOVESPD , MemoryType : : RANGE , MemoryType : : ATKSPD , MemoryType : : MOVESPD ,
MemoryType : : HEALTH , MemoryType : : HEALTH , MemoryType : : PROCEDURE ,
MemoryType : : PROCEDURE , MemoryType : : ATKSPD , MemoryType : : MOVESPD , MemoryType : : RANGE , }
} ;
if ( positions . size ( ) ! = types . size ( ) ) {
throw ;
}
while ( positions . size ( ) > 0 ) {
int randomIndex = rand ( ) % positions . size ( ) ;
int randomIndex2 = rand ( ) % types . size ( ) ;
float finalDir = 0 ;
if ( positions [ randomIndex ] . x < levelData [ stage ] . size . x / 2 ) {
if ( positions [ randomIndex ] . y < positions [ randomIndex ] . x ) {
finalDir = 0 ;
} else {
finalDir = - PI / 2 ;
}
} else {
if ( positions [ randomIndex ] . y > positions [ randomIndex ] . x ) {
finalDir = PI ;
} else {
finalDir = PI / 2 ;
}
}
collectionPoints . push_back ( CPData { positions [ randomIndex ] * 24 , finalDir , types [ randomIndex2 ] } ) ;
collectionPoints . push_back ( CPData { ( levelData [ stage ] . size - positions [ randomIndex ] - vf2d { 1 , 1 } ) * 24 , float ( finalDir + PI ) , types [ randomIndex2 ] } ) ;
positions . erase ( positions . begin ( ) + randomIndex ) ;
types . erase ( types . begin ( ) + randomIndex2 ) ;
}
units . push_back ( { UnitType : : Refresher , vf2d { 52 * 24 , 52 * 24 } , false } ) ;
units . push_back ( { UnitType : : RAMBank , vf2d { 54 * 24 , 54 * 24 } , false } ) ;
for ( int i = 0 ; i < 5 ; i + + ) {
units . push_back ( { UnitType : : MemoryAllocator , vf2d { 54 * 24 , 54 * 24 } , false } ) ;
}
units . push_back ( { UnitType : : RAMBank , vf2d { 40 * 24 , 36 * 24 } , false } ) ;
units . push_back ( { UnitType : : RAMBank , vf2d { 10 * 24 , 54 * 24 } , false } ) ;
}
}
# pragma endregion
}
bool VirusAttack : : OnUserCreate ( ) {
@ -401,6 +536,8 @@ bool VirusAttack::OnUserCreate(){
memoryAllocatorBox . SetVisible ( false ) ;
platformCreationBox . SetVisible ( false ) ;
restartBox . SetVisible ( false ) ;
completedBox . SetVisible ( false ) ;
creditsBox . SetVisible ( false ) ;
attackingLineModified . Create ( IMAGES [ ATTACKING_LINE ] - > Sprite ( ) - > width , IMAGES [ ATTACKING_LINE ] - > Sprite ( ) - > height , false , false ) ;
@ -411,8 +548,8 @@ bool VirusAttack::OnUserCreate(){
InitializeScenarios ( ) ;
InitializeLevelData ( ) ;
LoadLevel ( STAGE5 ) ;
levelToLoad = STAGE5 ;
LoadLevel ( STAGE1 ) ;
levelToLoad = STAGE1 ;
return true ;
}
@ -505,10 +642,10 @@ void VirusAttack::InitializeGUIs(){
unitCreationList . DisplayAllControls ( false ) ;
platformCreationList . DisplayAllControls ( false ) ;
campaignStartButton = new QuickGUI : : TransparentButton ( mainMenu , " Start Campaign " , { float ( ScreenWidth ( ) / 2 ) - 120.f , 80 + 47.5f * 0 + 10 } , { 240 , 24 } , CONSTANT : : INCREASE_VALUE_COLOR ) ;
audioToggleButton = new QuickGUI : : TransparentButton ( mainMenu , " Audio: On " , { float ( ScreenWidth ( ) / 2 ) - 120.f , 80 + 47.5f * 1 + 10 } , { 240 , 24 } , CONSTANT : : INCREASE_VALUE_COLOR ) ;
difficultyToggleButton = new QuickGUI : : TransparentButton ( mainMenu , " Difficulty: Normal " , { float ( ScreenWidth ( ) / 2 ) - 120.f , 80 + 47.5f * 2 + 10 } , { 240 , 24 } , CONSTANT : : INCREASE_VALUE_COLOR ) ;
creditsButton = new QuickGUI : : TransparentButton ( mainMenu , " Credits " , { float ( ScreenWidth ( ) / 2 ) - 120.f , 80 + 47.5f * 3 + 10 } , { 240 , 24 } , CONSTANT : : INCREASE_VALUE_COLOR ) ;
campaignStartButton = new QuickGUI : : TransparentButton ( mainMenu , " Start Campaign " , { float ( ScreenWidth ( ) / 2 ) - 120.f , 80 + 47.5f * 1 + 10 } , { 240 , 24 } , CONSTANT : : INCREASE_VALUE_COLOR ) ;
audioToggleButton = new QuickGUI : : TransparentButton ( mainMenu , " Audio: On " , { float ( ScreenWidth ( ) / 2 ) - 120.f , 80 + 47.5f * 2 + 10 } , { 240 , 24 } , CONSTANT : : INCREASE_VALUE_COLOR ) ;
difficultyToggleButton = new QuickGUI : : TransparentButton ( mainMenu , " Difficulty: Normal " , { float ( ScreenWidth ( ) / 2 ) - 120.f , 80 + 47.5f * 3 + 10 } , { 240 , 24 } , CONSTANT : : INCREASE_VALUE_COLOR ) ;
//creditsButton=new QuickGUI::TransparentButton(mainMenu,"Credits",{float(ScreenWidth()/2)-120.f,80+47.5f*3+10},{240,24},CONSTANT::INCREASE_VALUE_COLOR);
exitGameButton = new QuickGUI : : TransparentButton ( mainMenu , " Exit Game " , { float ( ScreenWidth ( ) / 2 ) - 120.f , 80 + 47.5f * 4 + 10 } , { 240 , 24 } , CONSTANT : : INCREASE_VALUE_COLOR ) ;
}
@ -946,9 +1083,11 @@ void VirusAttack::RenderCollectionPoints(CollectionPoint*cp){
bool VirusAttack : : OnUserUpdate ( float fElapsedTime ) {
UpdateMatrixTexture ( fElapsedTime ) ;
gameplayTime + = fElapsedTime ;
if ( gameplayTime > = 1 ) {
gameplayTime - - ;
gameSeconds + + ;
if ( state ! = GameState : : COMPLETED ) {
if ( gameplayTime > = 1 ) {
gameplayTime - - ;
gameSeconds + + ;
}
}
switch ( state ) {
# pragma region MAIN_MENU
@ -960,6 +1099,7 @@ bool VirusAttack::OnUserUpdate(float fElapsedTime){
state = GameState : : GAMEPLAY ;
RestartLevel ( ) ;
gameplayTime = 0 ;
gameSeconds = 0 ;
}
if ( audioToggleButton - > bPressed ) {
audioMode = ( audioMode + 1 ) % 3 ;
@ -981,6 +1121,20 @@ bool VirusAttack::OnUserUpdate(float fElapsedTime){
} break ;
}
}
if ( difficultyToggleButton - > bPressed ) {
flags . difficulty = ( flags . difficulty + 1 ) % 3 ;
switch ( flags . difficulty ) {
case 0 : {
difficultyToggleButton - > sText = " Difficulty: Easy " ;
} break ;
case 1 : {
difficultyToggleButton - > sText = " Difficulty: Normal " ;
} break ;
case 2 : {
difficultyToggleButton - > sText = " Difficulty: Hard " ;
} break ;
}
}
if ( exitGameButton - > bPressed ) {
SOUNDS [ Sound : : BUTTONSELECT ] - > PlayCentered ( ) ;
}
@ -1229,12 +1383,9 @@ bool VirusAttack::OnUserUpdate(float fElapsedTime){
# pragma endregion
# pragma region COMPLETED
case GameState : : COMPLETED : {
DrawPartialDecal ( { 0 , 0 } , GetScreenSize ( ) , IMAGES [ MATRIX ] - > Decal ( ) , randomBackgroundOffset + gametv . GetWorldOffset ( ) * ( vf2d { 32 , 32 } / vf2d ( GetScreenSize ( ) ) ) * gametv . GetWorldScale ( ) , { 32 , 32 } , Pixel { currentLevel - > levelColor . r , currentLevel - > levelColor . g , currentLevel - > levelColor . b , 164 } / 2 ) ;
} break ;
# pragma endregion
# pragma region CREDITS
case GameState : : CREDITS : {
DrawPartialDecal ( { 0 , 0 } , GetScreenSize ( ) , IMAGES [ MATRIX ] - > Decal ( ) , randomBackgroundOffset + gametv . GetWorldOffset ( ) * ( vf2d { 32 , 32 } / vf2d ( GetScreenSize ( ) ) ) * gametv . GetWorldScale ( ) , { 32 , 32 } , Pixel { currentLevel - > levelColor . r , currentLevel - > levelColor . g , currentLevel - > levelColor . b , 164 } / 2 ) ;
completedBox . Initialize ( " Thank you for playing Virus Attack! \n \n Completion Time: " + std : : to_string ( gameSeconds ) + " seconds \n \n Huge shoutout to the OLC community, javidx9 for the PGE, and all supporters! " ) ;
} break ;
# pragma endregion
}