Some code tweaks
This commit is contained in:
parent
7fb2459916
commit
1982eabe6e
4 changed files with 177 additions and 193 deletions
|
@ -189,7 +189,7 @@ void UnloadEndingScreen(void)
|
||||||
UnloadTexture(texVignette);
|
UnloadTexture(texVignette);
|
||||||
|
|
||||||
UnloadSound(fxNews);
|
UnloadSound(fxNews);
|
||||||
free(missions);
|
free(missions);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ending Screen should finish?
|
// Ending Screen should finish?
|
||||||
|
|
|
@ -212,9 +212,6 @@ void InitGameplayScreen(void)
|
||||||
int wordInitPosX = 0;
|
int wordInitPosX = 0;
|
||||||
int wordInitPosY = 0;
|
int wordInitPosY = 0;
|
||||||
|
|
||||||
// TODO: messageWords should be reseted every mission
|
|
||||||
//memcpy(messageWords, 0, sizeof(Word)*MAX_MISSION_WORDS);
|
|
||||||
|
|
||||||
for (int i = 0; i < msgLen; i++)
|
for (int i = 0; i < msgLen; i++)
|
||||||
{
|
{
|
||||||
char c = missions[currentMission].msg[i];
|
char c = missions[currentMission].msg[i];
|
||||||
|
@ -225,7 +222,6 @@ void InitGameplayScreen(void)
|
||||||
messageWords[currentWord - 1].rec.width = (int)MeasureTextEx(fontMessage, SubText(missions[currentMission].msg, wordInitPosX, (i - wordInitPosX)), 30, 0).x;
|
messageWords[currentWord - 1].rec.width = (int)MeasureTextEx(fontMessage, SubText(missions[currentMission].msg, wordInitPosX, (i - wordInitPosX)), 30, 0).x;
|
||||||
messageWords[currentWord - 1].rec.height = fontMessage.baseSize;
|
messageWords[currentWord - 1].rec.height = fontMessage.baseSize;
|
||||||
|
|
||||||
//TODO: Guardar en message
|
|
||||||
strncpy(messageWords[currentWord - 1].text, SubText(missions[currentMission].msg, wordInitPosX, (i - wordInitPosX)), i - wordInitPosX);
|
strncpy(messageWords[currentWord - 1].text, SubText(missions[currentMission].msg, wordInitPosX, (i - wordInitPosX)), i - wordInitPosX);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -343,25 +339,18 @@ void UpdateGameplayScreen(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Move word picked with mouse
|
// Move word picked with mouse
|
||||||
if (words[i].picked)
|
if (words[i].picked)
|
||||||
{
|
{
|
||||||
words[i].rec.x = GetMouseX() - words[i].rec.width/2;
|
words[i].rec.x = GetMouseX() - words[i].rec.width/2;
|
||||||
words[i].rec.y = GetMouseY() - words[i].rec.height/2;
|
words[i].rec.y = GetMouseY() - words[i].rec.height/2;
|
||||||
|
|
||||||
// TODO: Check if label is placed in some mission word position
|
|
||||||
//if (CheckCollisionRecs(words[i].rec))
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
//if (words[i].id != -1)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
canSend = true;
|
canSend = true;
|
||||||
for(int j = 0; j < missions[currentMission].wordsCount; j++)
|
for (int j = 0; j < missions[currentMission].wordsCount; j++)
|
||||||
{
|
{
|
||||||
if(messageWords[j].id == -1)
|
if (messageWords[j].id == -1)
|
||||||
{
|
{
|
||||||
canSend = false;
|
canSend = false;
|
||||||
break;
|
break;
|
||||||
|
@ -385,7 +374,7 @@ void DrawGameplayScreen(void)
|
||||||
{
|
{
|
||||||
Rectangle recLines = messageWords[i].rec;
|
Rectangle recLines = messageWords[i].rec;
|
||||||
DrawRectangleLines(recLines.x, recLines.y, recLines.width, recLines.height, Fade(RED, 0.35f));
|
DrawRectangleLines(recLines.x, recLines.y, recLines.width, recLines.height, Fade(RED, 0.35f));
|
||||||
if(messageWords[i].hover) DrawRectangleRec(messageWords[i].rec, Fade(RED, 0.30f));
|
if (messageWords[i].hover) DrawRectangleRec(messageWords[i].rec, Fade(RED, 0.30f));
|
||||||
DrawText(FormatText("%i", messageWords[i].id), i*25, 0, 30, RED);
|
DrawText(FormatText("%i", messageWords[i].id), i*25, 0, 30, RED);
|
||||||
}
|
}
|
||||||
for (int i = 0; i < MAX_CODING_WORDS; i++)
|
for (int i = 0; i < MAX_CODING_WORDS; i++)
|
||||||
|
|
|
@ -61,15 +61,15 @@ void InitLogoScreen(void)
|
||||||
// Logo Screen Update logic
|
// Logo Screen Update logic
|
||||||
void UpdateLogoScreen(void)
|
void UpdateLogoScreen(void)
|
||||||
{
|
{
|
||||||
if(!fadeOut)
|
if (!fadeOut)
|
||||||
{
|
{
|
||||||
fadeValue += 0.02f;
|
fadeValue += 0.02f;
|
||||||
if(fadeValue > 1.01f)
|
if (fadeValue > 1.01f)
|
||||||
{
|
{
|
||||||
fadeValue = 1.0f;
|
fadeValue = 1.0f;
|
||||||
framesCounter++;
|
framesCounter++;
|
||||||
|
|
||||||
if(framesCounter % showLogoFrames == 0)
|
if ((framesCounter%showLogoFrames) == 0)
|
||||||
{
|
{
|
||||||
fadeOut = true;
|
fadeOut = true;
|
||||||
finishScreen = true;
|
finishScreen = true;
|
||||||
|
@ -77,10 +77,7 @@ void UpdateLogoScreen(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(IsKeyPressed(KEY_ENTER))
|
if (IsKeyPressed(KEY_ENTER)) finishScreen = true;
|
||||||
{
|
|
||||||
finishScreen = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Logo Screen Draw logic
|
// Logo Screen Draw logic
|
||||||
|
|
|
@ -88,8 +88,7 @@ static Music musMission;
|
||||||
// Mission Screen Functions Definition
|
// Mission Screen Functions Definition
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
static void WriteMissionText();
|
static void WriteMissionText();
|
||||||
static void EndWritting();
|
|
||||||
static void BlinkKeyword();
|
|
||||||
|
|
||||||
// Mission Screen Initialization logic
|
// Mission Screen Initialization logic
|
||||||
void InitMissionScreen(void)
|
void InitMissionScreen(void)
|
||||||
|
@ -167,13 +166,28 @@ void UpdateMissionScreen(void)
|
||||||
UpdateMusicStream(musMission);
|
UpdateMusicStream(musMission);
|
||||||
|
|
||||||
if (!writeEnd) WriteMissionText();
|
if (!writeEnd) WriteMissionText();
|
||||||
else BlinkKeyword();
|
else
|
||||||
|
{
|
||||||
|
framesCounter++;
|
||||||
|
|
||||||
|
if ((framesCounter%blinkFrames) == 0)
|
||||||
|
{
|
||||||
|
framesCounter = 0;
|
||||||
|
blinkKeyWord = !blinkKeyWord;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (showButton)
|
if (showButton)
|
||||||
{
|
{
|
||||||
if (IsKeyPressed(KEY_ENTER) || IsButtonPressed())
|
if (IsKeyPressed(KEY_ENTER) || IsButtonPressed())
|
||||||
{
|
{
|
||||||
if (!writeEnd) EndWritting();
|
if (!writeEnd)
|
||||||
|
{
|
||||||
|
writeEnd = true;
|
||||||
|
writeKeyword = true;
|
||||||
|
writeNumber = true;
|
||||||
|
missionLenght = missionMaxLength;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
finishScreen = true;
|
finishScreen = true;
|
||||||
|
@ -186,7 +200,7 @@ void UpdateMissionScreen(void)
|
||||||
// Mission Screen Draw logic
|
// Mission Screen Draw logic
|
||||||
void DrawMissionScreen(void)
|
void DrawMissionScreen(void)
|
||||||
{
|
{
|
||||||
// TODO: Draw MISSION screen here!
|
// Draw MISSION screen here!
|
||||||
DrawTexture(texBackground, 0,0, WHITE);
|
DrawTexture(texBackground, 0,0, WHITE);
|
||||||
DrawTexturePro(texBackline, sourceRecBackLine, destRecBackLine, (Vector2){0,0},0, Fade(WHITE, fadeBackLine));
|
DrawTexturePro(texBackline, sourceRecBackLine, destRecBackLine, (Vector2){0,0},0, Fade(WHITE, fadeBackLine));
|
||||||
|
|
||||||
|
@ -204,7 +218,7 @@ void DrawMissionScreen(void)
|
||||||
// Mission Screen Unload logic
|
// Mission Screen Unload logic
|
||||||
void UnloadMissionScreen(void)
|
void UnloadMissionScreen(void)
|
||||||
{
|
{
|
||||||
// TODO: Unload MISSION screen variables here!
|
// Unload MISSION screen variables here!
|
||||||
UnloadTexture(texBackground);
|
UnloadTexture(texBackground);
|
||||||
UnloadTexture(texBackline);
|
UnloadTexture(texBackline);
|
||||||
UnloadSound(fxTransmit);
|
UnloadSound(fxTransmit);
|
||||||
|
@ -220,54 +234,54 @@ int FinishMissionScreen(void)
|
||||||
|
|
||||||
static void WriteMissionText()
|
static void WriteMissionText()
|
||||||
{
|
{
|
||||||
if(!startWritting)
|
if (!startWritting)
|
||||||
{
|
{
|
||||||
framesCounter++;
|
framesCounter++;
|
||||||
if(framesCounter % 60 == 0)
|
if (framesCounter % 60 == 0)
|
||||||
{
|
{
|
||||||
framesCounter = 0;
|
framesCounter = 0;
|
||||||
startWritting = true;
|
startWritting = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(!writeNumber)
|
else if (!writeNumber)
|
||||||
{
|
{
|
||||||
framesCounter++;
|
framesCounter++;
|
||||||
fadeBackLine += 0.020f;
|
fadeBackLine += 0.020f;
|
||||||
if(framesCounter % showNumberWaitFrames == 0)
|
if (framesCounter % showNumberWaitFrames == 0)
|
||||||
{
|
{
|
||||||
framesCounter = 0;
|
framesCounter = 0;
|
||||||
writeNumber = true;
|
writeNumber = true;
|
||||||
showButton = true;
|
showButton = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(!writeMission)
|
else if (!writeMission)
|
||||||
{
|
{
|
||||||
framesCounter ++;
|
framesCounter ++;
|
||||||
if(framesCounter % showMissionWaitFrames == 0)
|
if (framesCounter % showMissionWaitFrames == 0)
|
||||||
{
|
{
|
||||||
framesCounter = 0;
|
framesCounter = 0;
|
||||||
writeMission = true;
|
writeMission = true;
|
||||||
writtingMission = true;
|
writtingMission = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(writeMission && writtingMission)
|
else if (writeMission && writtingMission)
|
||||||
{
|
{
|
||||||
framesCounter++;
|
framesCounter++;
|
||||||
if(framesCounter % missionSpeed == 0)
|
if (framesCounter % missionSpeed == 0)
|
||||||
{
|
{
|
||||||
framesCounter = 0;
|
framesCounter = 0;
|
||||||
missionLenght++;
|
missionLenght++;
|
||||||
|
|
||||||
if(missionLenght == missionMaxLength)
|
if (missionLenght == missionMaxLength)
|
||||||
{
|
{
|
||||||
writtingMission = false;
|
writtingMission = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(!writeKeyword)
|
else if (!writeKeyword)
|
||||||
{
|
{
|
||||||
framesCounter++;
|
framesCounter++;
|
||||||
if(framesCounter % showKeywordWaitFrames == 0)
|
if (framesCounter % showKeywordWaitFrames == 0)
|
||||||
{
|
{
|
||||||
framesCounter = 0;
|
framesCounter = 0;
|
||||||
writeKeyword = true;
|
writeKeyword = true;
|
||||||
|
@ -275,19 +289,3 @@ static void WriteMissionText()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
static void EndWritting()
|
|
||||||
{
|
|
||||||
writeEnd = true;
|
|
||||||
writeKeyword = true;
|
|
||||||
writeNumber = true;
|
|
||||||
missionLenght = missionMaxLength;
|
|
||||||
}
|
|
||||||
static void BlinkKeyword()
|
|
||||||
{
|
|
||||||
framesCounter++;
|
|
||||||
if(framesCounter % blinkFrames == 0)
|
|
||||||
{
|
|
||||||
framesCounter = 0;
|
|
||||||
blinkKeyWord = !blinkKeyWord;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue