@ -51,6 +51,10 @@ namespace cutscene{
NODE_COLLECT_CUTSCENE ,
PAN_OVER_TO_CROPS ,
RAINING_IN_DOME ,
AFTER_RAIN ,
WALK_TO_COMPUTER ,
INPUT_USERNAME ,
GO_OUTSIDE ,
} ;
}
@ -68,6 +72,13 @@ namespace battle{
} ;
}
namespace gameflag {
enum FLAG {
TUTORIAL_WALKED_OFF_FARM ,
} ;
}
# define MAX_TERMINAL_NAME_LENGTH 6
# define WIDTH 256
# define HEIGHT 224
# define ALPHA_SCREEN1 128
@ -141,9 +152,9 @@ class Object{
Animation * anim ;
vi2d spos ;
vi2d size ;
bool flipped ;
bool flipped = false ;
bool hascut = false ;
bool tempObj ;
bool tempObj = false ;
Object ( ) { } ;
Object ( Decal * spr ) {
this - > spr = spr ;
@ -297,6 +308,7 @@ public:
const float TARGET_RATE = 1 / 60.0 ;
std : : string MAP_NAME = " " ;
std : : string CUTSCENE_CONSOLE_TEXT = " " ;
bool GAME_FLAGS [ 128 ] = { } ;
int * * MAP = NULL ;
int MAP_WIDTH = - 1 ;
int MAP_HEIGHT = - 1 ;
@ -308,6 +320,7 @@ public:
int CUTSCENE_TIMER = 0 ;
bool CUTSCENE_FLAGS [ 8 ] ;
Object * CUTSCENE_OBJS [ 8 ] ;
int CUTSCENE_OBJ_INDICES [ 8 ] ;
bool messageBoxVisible = false ;
int messageBoxCursor ;
std : : string messageBoxSpeaker ;
@ -319,7 +332,7 @@ public:
int foodCount = 3 ;
bool oxygenMeterVisible = false ;
int oxygenQualityLevel = 34 ;
int plantState = 0b10010110101000101010100110101010 ;
int plantState = 0b01001010010100010101010010010101 ;
SplashScreen splash ;
Animation current_playerAnim ;
Animation playerAnim ;
@ -393,13 +406,17 @@ public:
vf2d PIXEL_SIZE ;
std : : vector < WEATHER_POWER * > MOVESET_SPIDEY ;
float PIXEL_EFFECT_TRANSPARENCY = 0.5 ;
int CUTSCENE_OBJ_COUNT = 0 ;
int TERMINAL_SELECTED_CHAR = 0 ;
std : : string TERMINAL_INPUT = " " ;
std : : string PLAYER_NAME = " ... " ;
Decal * DOME_DECAL , * FOOD_METER_DECAL , * OXYGEN_METER_DECAL , * PLANT_DECAL ,
* PLAYER_DECAL ,
* WEATHERNODE_EFFECT_DECAL , * POWER_HAILSTORM_DECAL , * POWER_HURRICANE_DECAL , * POWER_METEOR_SHOWER_DECAL , * POWER_METEOR_STORM_DECAL , * POWER_SNOWSTORM_DECAL ,
* SPIDEY_DECAL , * TARGETING_CIRCLE , * TARGETING_RANGE_CIRCLE , * HEALTHBAR_DECAL ,
* CONSUME_SNACK_DECAL , * CONSUME_MEAL_DECAL ;
* CONSUME_SNACK_DECAL , * CONSUME_MEAL_DECAL , * COMPUTER_DECAL ;
std : : map < std : : string , ObjectLoadInfo * > BASE_OBJECTS ;
std : : vector < Encounter > ENCOUNTERS ;
Encounter ENCOUNTER_SPIDEY_1 ;
@ -440,6 +457,7 @@ public:
TARGETING_CIRCLE = new Decal ( new Sprite ( " assets/targetCircle.png " ) ) ;
TARGETING_RANGE_CIRCLE = new Decal ( new Sprite ( " assets/targetRange.png " ) ) ;
HEALTHBAR_DECAL = new Decal ( new Sprite ( " assets/healthbar.png " ) ) ;
COMPUTER_DECAL = new Decal ( new Sprite ( " assets/computerSystem.png " ) ) ;
current_playerAnim . spr = PLAYER_DECAL ;
playerAnim . spr = PLAYER_DECAL ;
@ -540,6 +558,7 @@ public:
BASE_OBJECTS [ " METEORSHOWER_NODE " ] = new ObjectLoadInfo ( POWER_METEOR_SHOWER_DECAL , & POWER_METEOR_SHOWER_ANIMATION ) ;
BASE_OBJECTS [ " METEORSTORM_NODE " ] = new ObjectLoadInfo ( POWER_METEOR_STORM_DECAL , & POWER_METEOR_STORM_ANIMATION ) ;
BASE_OBJECTS [ " SNOWSTORM_NODE " ] = new ObjectLoadInfo ( POWER_SNOWSTORM_DECAL , & POWER_SNOWSTORM_ANIMATION ) ;
BASE_OBJECTS [ " COMPUTER " ] = new ObjectLoadInfo ( COMPUTER_DECAL ) ;
for ( int i = 0 ; i < MAX_PIXELS ; i + + ) {
@ -582,6 +601,7 @@ public:
//cout<<"You are standing over plant "<<getPlantId((int)PLAYER_COORDS[0],(int)PLAYER_COORDS[1])<<" in state "<<getPlantStatus((int)PLAYER_COORDS[0],(int)PLAYER_COORDS[1]);
if ( getPlantStatus ( ( int ) PLAYER_COORDS [ 0 ] , ( int ) PLAYER_COORDS [ 1 ] ) = = 2 ) {
setPlantStatus ( ( int ) PLAYER_COORDS [ 0 ] , ( int ) PLAYER_COORDS [ 1 ] , 0 ) ;
foodCount + + ;
}
}
} break ;
@ -615,6 +635,21 @@ public:
case cutscene : : NODE_COLLECT_CUTSCENE : {
EndCutscene ( ) ;
} break ;
case cutscene : : INPUT_USERNAME : {
if ( TERMINAL_SELECTED_CHAR < 26 & & TERMINAL_INPUT . length ( ) < MAX_TERMINAL_NAME_LENGTH ) {
TERMINAL_INPUT + = ( char ) ( ' A ' + TERMINAL_SELECTED_CHAR ) ;
if ( TERMINAL_INPUT . length ( ) = = MAX_TERMINAL_NAME_LENGTH ) {
TERMINAL_SELECTED_CHAR = 27 ;
}
} else
if ( TERMINAL_SELECTED_CHAR = = 26 & & TERMINAL_INPUT . length ( ) > 0 ) {
TERMINAL_INPUT . erase ( TERMINAL_INPUT . length ( ) - 1 ) ;
} else
if ( TERMINAL_SELECTED_CHAR = = 27 & & TERMINAL_INPUT . length ( ) > 0 ) {
PLAYER_NAME = TERMINAL_INPUT ;
PlayCutscene ( cutscene : : GO_OUTSIDE ) ;
}
} break ;
}
}
@ -698,6 +733,38 @@ public:
}
} break ;
}
} else {
switch ( CURRENT_CUTSCENE ) {
case cutscene : : INPUT_USERNAME : {
if ( GetKey ( W ) . bPressed | | GetKey ( UP ) . bPressed | | GetKey ( NP8 ) . bPressed ) {
TERMINAL_SELECTED_CHAR = TERMINAL_SELECTED_CHAR - 7 ;
if ( TERMINAL_SELECTED_CHAR < 0 ) {
TERMINAL_SELECTED_CHAR + = 28 ;
}
}
if ( GetKey ( D ) . bPressed | | GetKey ( RIGHT ) . bPressed | | GetKey ( NP6 ) . bPressed ) {
if ( ( TERMINAL_SELECTED_CHAR + 1 ) % 7 = = 0 ) {
TERMINAL_SELECTED_CHAR - = 6 ;
} else {
TERMINAL_SELECTED_CHAR + + ;
}
}
if ( GetKey ( A ) . bPressed | | GetKey ( LEFT ) . bPressed | | GetKey ( NP4 ) . bPressed ) {
if ( ( TERMINAL_SELECTED_CHAR - 1 ) % 7 = = 6 | | TERMINAL_SELECTED_CHAR - 1 < 0 ) {
TERMINAL_SELECTED_CHAR + = 6 ;
} else {
TERMINAL_SELECTED_CHAR - - ;
}
}
if ( GetKey ( S ) . bPressed | | GetKey ( DOWN ) . bPressed | | GetKey ( NP5 ) . bPressed | | GetKey ( NP2 ) . bPressed ) {
if ( TERMINAL_SELECTED_CHAR + 7 > = 28 ) {
TERMINAL_SELECTED_CHAR = ( TERMINAL_SELECTED_CHAR + 7 ) % 28 ;
} else {
TERMINAL_SELECTED_CHAR + = 7 ;
}
}
} break ;
}
}
SetDrawTarget ( nullptr ) ;
Clear ( BLANK ) ;
@ -759,6 +826,7 @@ public:
} break ;
case cutscene : : RAINING_IN_DOME : {
applyPixelEffect ( HURRICANE , GetMapFileCoords ( 7 , 11 ) ) ;
CUTSCENE_TIMER = 0 ;
} break ;
}
for ( int i = 0 ; i < 8 ; i + + ) {
@ -801,43 +869,59 @@ public:
}
if ( playerCanMove ( ) ) {
bool changed = false ;
bool animationchanged = false ;
bool positionModified = false ;
if ( GetKey ( D ) . bHeld | | GetKey ( RIGHT ) . bHeld | | GetKey ( NP6 ) . bHeld ) {
PLAYER_COORDS [ 0 ] = std : : clamp ( PLAYER_COORDS [ 0 ] + MOVE_SPD , 0.1 , ( double ) MAP_WIDTH ) ;
if ( MAP [ ( int ) PLAYER_COORDS [ 1 ] ] [ ( int ) std : : clamp ( PLAYER_COORDS [ 0 ] + MOVE_SPD , 0.1 , ( double ) MAP_WIDTH ) ] ! = 4 ) {
PLAYER_COORDS [ 0 ] = std : : clamp ( PLAYER_COORDS [ 0 ] + MOVE_SPD , 0.1 , ( double ) MAP_WIDTH ) ;
positionModified = true ;
}
//ConsoleClear();
//cout<<"("<<PLAYER_COORDS[0]<<","<<PLAYER_COORDS[1]<<+")";
if ( ! changed & & & current_playerAnim ! = & playerAnimWalkRight ) {
if ( ! animation changed& & & current_playerAnim ! = & playerAnimWalkRight ) {
changeAnimation ( playerAnimWalkRight ) ;
changed = true ;
animation changed= true ;
}
}
if ( GetKey ( A ) . bHeld | | GetKey ( LEFT ) . bHeld | | GetKey ( NP4 ) . bHeld ) {
PLAYER_COORDS [ 0 ] = std : : clamp ( PLAYER_COORDS [ 0 ] - MOVE_SPD , 0.1 , ( double ) MAP_WIDTH ) ;
if ( MAP [ ( int ) PLAYER_COORDS [ 1 ] ] [ ( int ) std : : clamp ( PLAYER_COORDS [ 0 ] - MOVE_SPD , 0.1 , ( double ) MAP_WIDTH ) ] ! = 4 ) {
PLAYER_COORDS [ 0 ] = std : : clamp ( PLAYER_COORDS [ 0 ] - MOVE_SPD , 0.1 , ( double ) MAP_WIDTH ) ;
positionModified = true ;
}
//ConsoleClear();
//cout<<"("<<PLAYER_COORDS[0]<<","<<PLAYER_COORDS[1]<<+")";
if ( ! changed & & & current_playerAnim ! = & playerAnimWalkLeft ) {
if ( ! animation changed& & & current_playerAnim ! = & playerAnimWalkLeft ) {
changeAnimation ( playerAnimWalkLeft ) ;
changed = true ;
animation changed= true ;
}
}
if ( GetKey ( W ) . bHeld | | GetKey ( UP ) . bHeld | | GetKey ( NP8 ) . bHeld ) {
PLAYER_COORDS [ 1 ] = std : : clamp ( PLAYER_COORDS [ 1 ] - MOVE_SPD , 0.1 , ( double ) MAP_HEIGHT ) ;
if ( MAP [ ( int ) std : : clamp ( PLAYER_COORDS [ 1 ] - MOVE_SPD , 0.1 , ( double ) MAP_HEIGHT ) ] [ ( int ) PLAYER_COORDS [ 0 ] ] ! = 4 ) {
PLAYER_COORDS [ 1 ] = std : : clamp ( PLAYER_COORDS [ 1 ] - MOVE_SPD , 0.1 , ( double ) MAP_HEIGHT ) ;
positionModified = true ;
}
//ConsoleClear();
//cout<<"("<<PLAYER_COORDS[0]<<","<<PLAYER_COORDS[1]<<+")";
if ( ! changed & & & current_playerAnim ! = & playerAnimWalkUp ) {
if ( ! animation changed& & & current_playerAnim ! = & playerAnimWalkUp ) {
changeAnimation ( playerAnimWalkUp ) ;
changed = true ;
animation changed= true ;
}
}
if ( GetKey ( S ) . bHeld | | GetKey ( DOWN ) . bHeld | | GetKey ( NP5 ) . bHeld | | GetKey ( NP2 ) . bHeld ) {
PLAYER_COORDS [ 1 ] = std : : clamp ( PLAYER_COORDS [ 1 ] + MOVE_SPD , 0.1 , ( double ) MAP_HEIGHT ) ;
if ( MAP [ ( int ) std : : clamp ( PLAYER_COORDS [ 1 ] + MOVE_SPD , 0.1 , ( double ) MAP_HEIGHT ) ] [ ( int ) PLAYER_COORDS [ 0 ] ] ! = 4 ) {
PLAYER_COORDS [ 1 ] = std : : clamp ( PLAYER_COORDS [ 1 ] + MOVE_SPD , 0.1 , ( double ) MAP_HEIGHT ) ;
positionModified = true ;
}
//ConsoleClear();
//cout<<"("<<PLAYER_COORDS[0]<<","<<PLAYER_COORDS[1]<<+")";
if ( ! changed & & & current_playerAnim ! = & playerAnimWalkDown ) {
if ( ! animation changed& & & current_playerAnim ! = & playerAnimWalkDown ) {
changeAnimation ( playerAnimWalkDown ) ;
changed = true ;
animation changed= true ;
}
}
if ( positionModified ) {
playerMoved ( ) ;
}
}
if ( playerCanMove ( ) ) {
@ -1110,6 +1194,91 @@ public:
PlayCutscene ( cutscene : : RAINING_IN_DOME ) ;
}
} break ;
case cutscene : : RAINING_IN_DOME : {
if ( CUTSCENE_TIMER % 60 = = 0 ) {
performCropUpdate ( 3 ) ;
}
if ( CUTSCENE_TIMER > = 60 * 6 ) {
PIXEL_EFFECT_TRANSPARENCY = ( 60 - ( CUTSCENE_TIMER - 60 * 6 ) ) / 60 ;
}
if ( CUTSCENE_TIMER > = 60 * 7 ) {
PlayCutscene ( cutscene : : AFTER_RAIN ) ;
}
} break ;
case cutscene : : AFTER_RAIN : {
if ( ! messageBoxVisible ) {
if ( ! CUTSCENE_FLAGS [ 0 ] ) {
DisplayMessageBox ( 2 ) ;
CUTSCENE_FLAGS [ 0 ] = true ;
} else
if ( ! CUTSCENE_FLAGS [ 1 ] ) {
DisplayMessageBox ( 3 ) ;
CUTSCENE_FLAGS [ 1 ] = true ;
foodMeterVisible = true ;
} else {
PLAYER_COORDS [ 0 ] = 13 ;
PLAYER_COORDS [ 1 ] = 4 ;
changeAnimation ( playerAnimLeft ) ;
EndCutscene ( ) ;
}
}
} break ;
case cutscene : : WALK_TO_COMPUTER : {
if ( ! messageBoxVisible ) {
if ( ! CUTSCENE_FLAGS [ 0 ] ) {
DisplayMessageBox ( 11 ) ;
CUTSCENE_FLAGS [ 0 ] = true ;
} else
if ( ! CUTSCENE_FLAGS [ 1 ] ) {
DisplayMessageBox ( 4 ) ;
CUTSCENE_FLAGS [ 1 ] = true ;
} else {
vi2d targetPos = GetMapFileCoords ( 19 , 4 ) ;
if ( CUTSCENE_OBJS [ 0 ] - > x < 19 ) {
CUTSCENE_OBJS [ 0 ] - > x + = MOVE_SPD ;
if ( CUTSCENE_OBJS [ 0 ] - > x > 19 ) {
CUTSCENE_OBJS [ 0 ] - > x = 19 ;
}
}
if ( CUTSCENE_OBJS [ 0 ] - > y < 4 ) {
CUTSCENE_OBJS [ 0 ] - > y + = MOVE_SPD ;
if ( CUTSCENE_OBJS [ 0 ] - > y > 4 ) {
CUTSCENE_OBJS [ 0 ] - > y = 4 ;
}
}
if ( CUTSCENE_OBJS [ 0 ] - > y > 4 ) {
CUTSCENE_OBJS [ 0 ] - > y - = MOVE_SPD ;
if ( CUTSCENE_OBJS [ 0 ] - > y < 4 ) {
CUTSCENE_OBJS [ 0 ] - > y = 4 ;
}
}
if ( MoveCameraTowardsPoint ( { 19 , 4 } ) ) {
if ( ! CUTSCENE_FLAGS [ 2 ] ) {
DisplayMessageBox ( 5 ) ;
CUTSCENE_FLAGS [ 2 ] = true ;
} else {
PlayCutscene ( cutscene : : INPUT_USERNAME ) ;
}
}
}
}
} break ;
case cutscene : : GO_OUTSIDE : {
if ( ! messageBoxVisible ) {
if ( ! CUTSCENE_FLAGS [ 0 ] ) {
CUTSCENE_FLAGS [ 0 ] = true ;
DisplayMessageBox ( 12 ) ;
} else
if ( ! CUTSCENE_FLAGS [ 1 ] ) {
CUTSCENE_FLAGS [ 1 ] = true ;
DisplayMessageBox ( 6 ) ;
} else {
PLAYER_COORDS [ 0 ] = 19 ;
PLAYER_COORDS [ 1 ] = 4 ;
EndCutscene ( ) ;
}
}
} break ;
}
switch ( GAME_STATE ) {
@ -1221,6 +1390,15 @@ public:
}
}
//Triggers when the player has successfully moved.
void playerMoved ( ) {
if ( ! GAME_FLAGS [ gameflag : : TUTORIAL_WALKED_OFF_FARM ] & & foodCount > 3 & & PLAYER_COORDS [ 0 ] > 12 ) {
GAME_FLAGS [ gameflag : : TUTORIAL_WALKED_OFF_FARM ] = true ;
PlayCutscene ( cutscene : : WALK_TO_COMPUTER ) ;
CUTSCENE_OBJS [ 0 ] = CreateObject ( { PLAYER_COORDS [ 0 ] , PLAYER_COORDS [ 1 ] } , PLAYER_DECAL , { 32 , 0 } , { 32 , 32 } , true ) ;
}
}
void drawGame ( ) {
switch ( GAME_STATE ) {
case CUTSCENE_1 : {
@ -1241,14 +1419,14 @@ public:
int meterYOffset = 2 ;
if ( CURRENT_CUTSCENE = = cutscene : : NONE ) {
if ( foodMeterVisible ) {
DrawStringDecal ( { WIDTH - 36 * 0.4 - GetTextSize ( std : : to_string ( foodCount ) ) . x * 1 - 8 , meterYOffset + 2 } , std : : to_string ( foodCount ) , BLUE , { 1 , 1 } ) ;
DrawStringDecal ( { WIDTH - 36 * 0.4 - GetTextSize ( std : : to_string ( foodCount ) ) . x * 1 - 7 , meterYOffset + 2 } , std : : to_string ( foodCount ) , BLACK , { 1 , 1 } ) ;
DrawStringDecal ( { WIDTH - 36 * 0.4 - GetTextSize ( std : : to_string ( foodCount ) ) . x * 1 - 8 , meterYOffset + 1 } , std : : to_string ( foodCount ) , BLACK , { 1 , 1 } ) ;
DrawStringDecal ( { WIDTH - 36 * 0.4 - GetTextSize ( std : : to_string ( foodCount ) ) . x * 1 - 7 , meterYOffset + 2 } , std : : to_string ( foodCount ) , WHITE , { 1 , 1 } ) ;
DrawDecal ( { WIDTH - 52 * 0.4 , meterYOffset } , FOOD_METER_DECAL , { 0.4 , 0.4 } ) ;
meterYOffset + = ( 2 + 48 * 0.4 ) ;
}
if ( oxygenMeterVisible ) {
DrawStringDecal ( { WIDTH - 36 * 0.4 - GetTextSize ( std : : to_string ( oxygenQualityLevel ) + " % " ) . x * 1 - 8 , meterYOffset + 2 } , std : : to_string ( oxygenQualityLevel ) + " % " , BLUE , { 1 , 1 } ) ;
DrawStringDecal ( { WIDTH - 36 * 0.4 - GetTextSize ( std : : to_string ( oxygenQualityLevel ) + " % " ) . x * 1 - 7 , meterYOffset + 2 } , std : : to_string ( oxygenQualityLevel ) + " % " , BLACK , { 1 , 1 } ) ;
DrawStringDecal ( { WIDTH - 36 * 0.4 - GetTextSize ( std : : to_string ( oxygenQualityLevel ) + " % " ) . x * 1 - 8 , meterYOffset + 1 } , std : : to_string ( oxygenQualityLevel ) + " % " , BLACK , { 1 , 1 } ) ;
DrawStringDecal ( { WIDTH - 36 * 0.4 - GetTextSize ( std : : to_string ( oxygenQualityLevel ) + " % " ) . x * 1 - 7 , meterYOffset + 2 } , std : : to_string ( oxygenQualityLevel ) + " % " , WHITE , { 1 , 1 } ) ;
DrawDecal ( { WIDTH - 52 * 0.4 , meterYOffset } , OXYGEN_METER_DECAL , { 0.4 , 0.4 } ) ;
meterYOffset + = ( 2 + 48 * 0.4 ) ;
}
@ -1337,6 +1515,10 @@ public:
FillRectDecal ( { 0 , 0 } , { WIDTH , HEIGHT } , Pixel ( 0 , 0 , 0 , 128 ) ) ;
DrawCard ( CUTSCENE_DISPLAYED_CARD ) ;
} break ;
case cutscene : : INPUT_USERNAME : {
FillRectDecal ( { 0 , 0 } , { WIDTH , HEIGHT } , Pixel ( 0 , 0 , 0 , 128 ) ) ;
DrawTerminal ( ) ;
} break ;
}
FillRectDecal ( { 0 , 0 } , { WIDTH , HEIGHT } , Pixel ( 0 , 0 , 0 , transparency ) ) ;
//FillRectDecal({WIDTH/2-2,HEIGHT/2-2},{4,4},WHITE);
@ -1411,14 +1593,46 @@ public:
DrawDecal ( pos , HEALTHBAR_DECAL , { width / 32 , 1 } , col ) ;
}
void DrawTerminal ( ) {
const int TERMINAL_WIDTH = 7 ;
for ( int i = 0 ; i < 26 ; i + + ) {
std : : string s ( 1 , ( char ) ( ' A ' + i ) ) ;
DrawStringDecal ( { ( 32 * ( i % TERMINAL_WIDTH ) ) + 16 , 16 * ( i / TERMINAL_WIDTH ) + HEIGHT / 2 } , s ) ;
}
std : : string backspace ( 1 , ( char ) ( ' < ' ) ) ;
DrawStringDecal ( { ( 32 * ( 26 % TERMINAL_WIDTH ) ) + 16 , 16 * ( 26 / TERMINAL_WIDTH ) + HEIGHT / 2 } , backspace ) ;
DrawStringDecal ( { ( 32 * ( 27 % TERMINAL_WIDTH ) ) + 16 , 16 * ( 27 / TERMINAL_WIDTH ) + HEIGHT / 2 } , " ENTER " ) ;
DrawStringDecal ( { ( 32 * ( ( TERMINAL_SELECTED_CHAR ) % TERMINAL_WIDTH ) ) + 8 , 16 * ( TERMINAL_SELECTED_CHAR / TERMINAL_WIDTH ) + HEIGHT / 2 } , " > " ) ;
std : : string terminal_name = TERMINAL_INPUT ;
for ( int i = 0 ; i < MAX_TERMINAL_NAME_LENGTH - TERMINAL_INPUT . length ( ) ; i + + ) {
terminal_name + = " * " ;
}
DrawStringDecal ( { WIDTH / 2 - GetTextSize ( terminal_name ) . x * 2 / 2 , HEIGHT / 3 - GetTextSize ( terminal_name ) . y * 2 / 2 } , terminal_name , olc : : WHITE , { 2.0 , 2.0 } ) ;
GradientFillRectDecal ( { 0 , 0 } , { WIDTH / 2 , HEIGHT / 2 } , { 20 , 28 , 22 , ALPHA_SCREEN1 } , { 20 , 28 , 22 , ALPHA_SCREEN1 } , { 20 , 28 , 22 , ALPHA_SCREEN2 } , { 20 , 28 , 22 , ALPHA_SCREEN1 } ) ;
GradientFillRectDecal ( { WIDTH / 2 , 0 } , { WIDTH / 2 , HEIGHT / 2 } , { 20 , 28 , 22 , ALPHA_SCREEN1 } , { 20 , 28 , 22 , ALPHA_SCREEN2 } , { 20 , 28 , 22 , ALPHA_SCREEN1 } , { 20 , 28 , 22 , ALPHA_SCREEN1 } ) ;
GradientFillRectDecal ( { 0 , HEIGHT / 2 } , { WIDTH / 2 , HEIGHT / 2 } , { 20 , 28 , 22 , ALPHA_SCREEN1 } , { 20 , 28 , 22 , ALPHA_SCREEN1 } , { 20 , 28 , 22 , ALPHA_SCREEN1 } , { 20 , 28 , 22 , ALPHA_SCREEN2 } ) ;
GradientFillRectDecal ( { WIDTH / 2 , HEIGHT / 2 } , { WIDTH / 2 , HEIGHT / 2 } , { 20 , 28 , 22 , ALPHA_SCREEN2 } , { 20 , 28 , 22 , ALPHA_SCREEN1 } , { 20 , 28 , 22 , ALPHA_SCREEN1 } , { 20 , 28 , 22 , ALPHA_SCREEN1 } ) ;
}
int getPlantId ( int x , int y ) {
return ( ( int ) x - 8 ) % 4 + ( ( int ) y - 2 ) * 4 ;
}
int getPlantStatusWithAbsoluteCoords ( int x , int y ) {
return plantState > > getPlantId ( x + 8 , y + 2 ) * 2 & 0b11 ;
}
//This uses MAP COORDS for determining bit location. The plants are offset by (X+8,Y+2)!! Use getPlantStatusWithAbsoluteCoords() to translate to map coords.
int getPlantStatus ( int x , int y ) {
return plantState > > getPlantId ( x , y ) * 2 & 0b11 ;
}
void setPlantStatusWithAbsoluteCoords ( int x , int y , char state ) {
setPlantStatus ( x + 8 , y + 2 , state ) ;
}
//This uses MAP COORDS for determining bit location. The plants are offset by (X+8,Y+2)!! Use setPlantStatusWithAbsoluteCoords() to translate to map coords.
void setPlantStatus ( int x , int y , char state ) {
int mask = 0b11111111111111111111111111111111 ;
mask - = 3 < < getPlantId ( x , y ) * 2 ;
@ -1446,6 +1660,18 @@ public:
void EndCutscene ( ) {
CURRENT_CUTSCENE = cutscene : : NONE ;
for ( int i = 0 ; i < 8 ; i + + ) {
for ( int j = 0 ; j < OBJECTS . size ( ) ; j + + ) {
if ( OBJECTS [ j ] = = CUTSCENE_OBJS [ i ] ) {
if ( CUTSCENE_OBJS [ i ] - > tempObj ) {
OBJECTS . erase ( OBJECTS . begin ( ) + j ) ;
std : : cout < < " Erased at position " < < j < < " . \n " ;
break ;
}
delete CUTSCENE_OBJS [ i ] ;
}
}
}
}
void DisplayMessageBox ( int dialogNumber ) {
@ -1454,7 +1680,7 @@ public:
std : : string split1 = STORY_DIALOG [ dialogNumber ] . substr ( 0 , STORY_DIALOG [ dialogNumber ] . find ( ' \n ' ) ) ; //Unused for now.
std : : string split2 = STORY_DIALOG [ dialogNumber ] . substr ( STORY_DIALOG [ dialogNumber ] . find ( ' \n ' ) + 1 , STORY_DIALOG [ dialogNumber ] . find ( ' \n ' , STORY_DIALOG [ dialogNumber ] . find ( ' \n ' ) + 1 ) - ( STORY_DIALOG [ dialogNumber ] . find ( ' \n ' ) + 1 ) ) ;
std : : string split3 = STORY_DIALOG [ dialogNumber ] . substr ( STORY_DIALOG [ dialogNumber ] . find ( ' \n ' , STORY_DIALOG [ dialogNumber ] . find ( ' \n ' ) + 1 ) + 1 , STORY_DIALOG [ dialogNumber ] . length ( ) - ( STORY_DIALOG [ dialogNumber ] . find ( ' \n ' , STORY_DIALOG [ dialogNumber ] . find ( ' \n ' ) + 1 ) + 1 ) ) ;
messageBoxSpeaker = split2 ;
messageBoxSpeaker = ( split2 . compare ( " $PLAYER " ) = = 0 ) ? split2 . replace ( 0 , split2 . length ( ) , PLAYER_NAME ) : split2 ;
messageBoxText = " " ;
messageBoxRefText = split3 ;
}
@ -1706,7 +1932,7 @@ public:
for ( int x = 0 ; x < 4 ; x + + ) {
for ( int y = 0 ; y < 4 ; y + + ) {
if ( rand ( ) % chanceToRegrow = = 0 ) {
setPlantStatus ( x , y , std : : clamp ( getPlantStatus ( x , y ) + 1 , 0 , 2 ) ) ;
setPlantStatusWithAbsoluteCoords ( x , y , std : : clamp ( getPlantStatusWithAbsoluteCoord s ( x , y ) + 1 , 0 , 2 ) ) ;
}
}
}
@ -1845,7 +2071,7 @@ public:
PLAYER_COORDS [ 1 ] = teleLoc . y + 0.5 ;
}
Object * CreateObject ( vf2d pos , Decal * spr , bool temporary = false ) {
Object * CreateObject ( vf2d pos , Decal * spr , int , bool temporary = false ) {
Object * newobj ;
OBJECTS . push_back ( newobj = new Object ( spr ) ) ;
newobj - > x = pos . x ;
@ -1877,6 +2103,7 @@ public:
}
}
}
//Returns true if the camera reached the target position.
bool MoveCameraTowardsPoint ( vf2d pos , float spd = BATTLE_CAMERA_SCROLL_SPD ) {
bool reachedPosition = true ;
if ( PLAYER_COORDS [ 0 ] ! = pos . x ) {