Browse Source

Some code tweaks

raysan5 6 years ago
parent
commit
1982eabe6e

+ 32 - 32
games/transmission/screens/screen_ending.c

@@ -35,13 +35,13 @@
 //----------------------------------------------------------------------------------
 // Global Variables Definition (local to this module)
 //----------------------------------------------------------------------------------
-static char *codingWords[MAX_CODING_WORDS] = { 
-    "pollo\0", 
-    "conejo\0", 
+static char *codingWords[MAX_CODING_WORDS] = {
+    "pollo\0",
+    "conejo\0",
     "huevo\0",
-    "nido\0", 
-    "aire\0", 
-    "armario\0", 
+    "nido\0",
+    "aire\0",
+    "armario\0",
     "agujero\0",
     "platano\0",
     "pastel\0",
@@ -82,21 +82,21 @@ void InitEndingScreen(void)
 {
     framesCounter = 0;
     finishScreen = 0;
-    
+
     rotation = 0.1f;
     scale = 0.05f;
     state = 0;
-    
+
     texBackground = LoadTexture("resources/textures/ending_background.png");
     texVignette = LoadTexture("resources/textures/message_vignette.png");
     fxNews = LoadSound("resources/audio/fx_batman.ogg");
-    
+
     missions = LoadMissions("resources/missions.txt");
     int wordsCount = missions[currentMission].wordsCount;
 
     strcpy(headline, missions[currentMission].msg);     // Base headline
     int len = strlen(headline);
-    
+
     // Remove @ from headline
     // TODO: Also remove additional spaces
     for (int i = 0; i < len; i++)
@@ -110,7 +110,7 @@ void InitEndingScreen(void)
         {
             // WARNING: It fails if the last sentence word has a '.' after space
             char *title = StringReplace(headline, messageWords[i].text, codingWords[messageWords[i].id]);
-           
+
             if (title != NULL)
             {
                 strcpy(headline, title);     // Base headline updated
@@ -118,14 +118,14 @@ void InitEndingScreen(void)
             }
         }
     }
-    
+
     TraceLog(LOG_WARNING, "Titular: %s", headline);
-    
+
     // Generate newspaper with title and subtitle
     Image imNewspaper = LoadImage("resources/textures/ending_newspaper.png");
     fontNews = LoadFontEx("resources/fonts/Lora-Bold.ttf", 32, 250, 0);
     ImageDrawTextEx(&imNewspaper, (Vector2){ 50, 220 }, fontNews, headline, fontNews.baseSize, 0, DARKGRAY);
-    
+
     texNewspaper = LoadTextureFromImage(imNewspaper);
     //UnloadFont(fontNews);
     UnloadImage(imNewspaper);
@@ -135,25 +135,25 @@ void InitEndingScreen(void)
 void UpdateEndingScreen(void)
 {
     framesCounter++;
-    
+
     if (framesCounter == 10) PlaySound(fxNews);
-    
+
     if (state == 0)
     {
         rotation += 18.0f;
         scale += 0.0096f;
-        
-        if (scale >= 1.0f) 
+
+        if (scale >= 1.0f)
         {
             scale = 1.0f;
             state = 1;
         }
     }
-    
-    if ((state == 1) && (IsKeyPressed(KEY_ENTER) || IsButtonPressed())) 
+
+    if ((state == 1) && (IsKeyPressed(KEY_ENTER) || IsButtonPressed()))
     {
         currentMission++;
-        
+
         if (currentMission >= totalMissions) finishScreen = 2;
         else finishScreen = 1;
     }
@@ -163,16 +163,16 @@ void UpdateEndingScreen(void)
 void DrawEndingScreen(void)
 {
     DrawTexture(texBackground, 0, 0, WHITE);
-    
+
     DrawTexturePro(texNewspaper, (Rectangle){ 0, 0, texNewspaper.width, texNewspaper.height },
-                   (Rectangle){ GetScreenWidth()/2, GetScreenHeight()/2, texNewspaper.width*scale, texNewspaper.height*scale }, 
+                   (Rectangle){ GetScreenWidth()/2, GetScreenHeight()/2, texNewspaper.width*scale, texNewspaper.height*scale },
                    (Vector2){ (float)texNewspaper.width*scale/2, (float)texNewspaper.height*scale/2 }, rotation, WHITE);
 
     DrawTextureEx(texVignette, (Vector2){ 0, 0 }, 0.0f, 2.0f, WHITE);
 
     // Draw debug information
     DrawTextEx(fontNews, headline, (Vector2){ 10, 10 }, fontNews.baseSize, 0, RAYWHITE);
-    
+
     for (int i = 0; i < missions[currentMission].wordsCount; i++)
     {
         DrawText(codingWords[messageWords[i].id], 10, 60 + 30*i, 20, (messageWords[i].id == missions[currentMission].sols[i]) ? GREEN : RED);
@@ -187,9 +187,9 @@ void UnloadEndingScreen(void)
     UnloadTexture(texBackground);
     UnloadTexture(texNewspaper);
     UnloadTexture(texVignette);
-    
+
     UnloadSound(fxNews);
-	free(missions);
+    free(missions);
 }
 
 // Ending Screen should finish?
@@ -213,16 +213,16 @@ static char *StringReplace(char *orig, char *rep, char *with)
 
     // Sanity checks and initialization
     if (!orig || !rep) return NULL;
-    
+
     len_rep = strlen(rep);
     if (len_rep == 0) return NULL;  // Empty rep causes infinite loop during count
-    
+
     if (!with) with = "";           // Replace with nothing if not provided
     len_with = strlen(with);
 
     // Count the number of replacements needed
     ins = orig;
-    for (count = 0; tmp = strstr(ins, rep); ++count) 
+    for (count = 0; tmp = strstr(ins, rep); ++count)
     {
         ins = tmp + len_rep;
     }
@@ -235,7 +235,7 @@ static char *StringReplace(char *orig, char *rep, char *with)
     //    tmp points to the end of the result string
     //    ins points to the next occurrence of rep in orig
     //    orig points to the remainder of orig after "end of rep"
-    while (count--) 
+    while (count--)
     {
         ins = strstr(orig, rep);
         len_front = ins - orig;
@@ -243,8 +243,8 @@ static char *StringReplace(char *orig, char *rep, char *with)
         tmp = strcpy(tmp, with) + len_with;
         orig += len_front + len_rep; // move to next "end of rep"
     }
-    
+
     strcpy(tmp, orig);
-    
+
     return result;
 }

+ 73 - 84
games/transmission/screens/screen_gameplay.c

@@ -35,9 +35,9 @@
 #define MAX_LINE_CHAR  30
 
 /*
-// NOTE: Coding words are generic and the same words 
-// are used for all missions, 
-typedef enum CodingWords { 
+// NOTE: Coding words are generic and the same words
+// are used for all missions,
+typedef enum CodingWords {
     POLLO = 0,
     CONEJO,
     HUEVO,
@@ -50,13 +50,13 @@ typedef enum CodingWords {
 } CodingWords;
 */
 
-static char *codingWords[MAX_CODING_WORDS] = { 
-    "pollo\0", 
-    "conejo\0", 
+static char *codingWords[MAX_CODING_WORDS] = {
+    "pollo\0",
+    "conejo\0",
     "huevo\0",
-    "nido\0", 
-    "aire\0", 
-    "armario\0", 
+    "nido\0",
+    "aire\0",
+    "armario\0",
     "agujero\0",
     "platano\0",
     "pastel\0",
@@ -125,19 +125,19 @@ void InitGameplayScreen(void)
 {
     framesCounter = 0;
     finishScreen = 0;
-    
+
     fontMessage = LoadFontEx("resources/fonts/traveling_typewriter.ttf", 30, 250, 0);
-    
+
     texBackground = LoadTexture("resources/textures/message_background.png");
     texVignette = LoadTexture("resources/textures/message_vignette.png");
-    
+
     fxGrab = LoadSound("resources/audio/fx_grab.ogg");
     fxPlace = LoadSound("resources/audio/fx_place.ogg");
     fxLeave = LoadSound("resources/audio/fx_leave.ogg");
-    
+
     musSpy = LoadMusicStream("resources/audio/s_p_y.xm");
     PlayMusicStream(musSpy);
-    
+
 #if defined(PLATFORM_WEB)
     #define WORD_ATLAS_FROM_FILE
 #endif
@@ -147,20 +147,20 @@ void InitGameplayScreen(void)
     // Generate coding words atlas directly from text
     Image imWordsBase = LoadImage("resources/textures/words_base.png");
     Image imWords = GenImageColor(imWordsBase.width, imWordsBase.height*MAX_CODING_WORDS, WHITE);
-    
+
     for (int i = 0; i < MAX_CODING_WORDS; i++)
     {
-        ImageDraw(&imWords, imWordsBase, 
+        ImageDraw(&imWords, imWordsBase,
                   (Rectangle){ 0, 0, imWordsBase.width, imWordsBase.height },
                   (Rectangle){ 0, imWordsBase.height*i, imWordsBase.width, imWordsBase.height });
-                  
-        ImageDrawTextEx(&imWords,(Vector2){ imWordsBase.width/2 - MeasureTextEx(fontMessage, codingWords[i], 
-                        fontMessage.baseSize, 0).x/2, imWordsBase.height*i }, fontMessage, codingWords[i], 
-                        fontMessage.baseSize, 0, BLACK); 
+
+        ImageDrawTextEx(&imWords,(Vector2){ imWordsBase.width/2 - MeasureTextEx(fontMessage, codingWords[i],
+                        fontMessage.baseSize, 0).x/2, imWordsBase.height*i }, fontMessage, codingWords[i],
+                        fontMessage.baseSize, 0, BLACK);
     }
-    
+
     texWordsAtlas = LoadTextureFromImage(imWords);
-    
+
     UnloadImage(imWordsBase);
     UnloadImage(imWords);
 #endif
@@ -183,13 +183,13 @@ void InitGameplayScreen(void)
         words[i].iniRec = words[i].rec;
         words[i].hover = false;    // Mouse hover detected
         words[i].picked = false;   // Mouse picked
-        
+
         //words[i].text = ''; //codingWords[i];     // Fill text if required...
     }
-    
+
     // Analize missions[currentMission].msg string for words!
     int msgLen = strlen(missions[currentMission].msg);
-    
+
     // Add '/' each MAX_LINE_CHAR chars
     int currentLine = 1;
     int i = currentLine * MAX_LINE_CHAR;
@@ -203,39 +203,35 @@ void InitGameplayScreen(void)
             i = currentLine*MAX_LINE_CHAR;
         }
         else i++;
-    }      
-    
+    }
+
     int currentWord = 0;
     int offsetX = 0;
     int offsetY = 0;
     bool foundWord = false;
     int wordInitPosX = 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++)
-    {        
+    {
         char c = missions[currentMission].msg[i];
         if (foundWord && (c == ' ' || c == '.'))
         {
             foundWord = false;
-            
+
             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;
-            
-            //TODO: Guardar en message
+
             strncpy(messageWords[currentWord - 1].text, SubText(missions[currentMission].msg, wordInitPosX, (i - wordInitPosX)), i - wordInitPosX);
         }
-        
+
         if (c == '@') // One word to change
         {
             foundWord = true;
             missions[currentMission].msg[i] = ' ';
 
             offsetX = (int)MeasureTextEx(fontMessage, SubText(missions[currentMission].msg, wordInitPosY, (i + 1) - wordInitPosY), 30, 0).x;
-            
+
             messageWords[currentWord].rec.x = offsetX;
             messageWords[currentWord].rec.y = offsetY;
 
@@ -254,16 +250,16 @@ void InitGameplayScreen(void)
     for (int i = 0; i < missions[currentMission].wordsCount; i++)
     {
         messageWords[i].id = -1;          // Not required for message words, id is the array position
-        
+
         // Recalculate words rectangles considering text offset on screen
         messageWords[i].rec.x += msgOffset.x;
         messageWords[i].rec.y += msgOffset.y;
-        
+
         // Recalculate words rectangle considering new width height
         messageWords[i].rec.x -= (texWordsAtlas.width - messageWords[i].rec.width)/2;
         messageWords[i].rec.y -= ((texWordsAtlas.height / MAX_CODING_WORDS) - messageWords[i].rec.height)/2;
-        
-        //Recalculate width height 
+
+        //Recalculate width height
         messageWords[i].rec.width =  texWordsAtlas.width;
         messageWords[i].rec.height = texWordsAtlas.height / MAX_CODING_WORDS;
 
@@ -276,13 +272,13 @@ void InitGameplayScreen(void)
 void UpdateGameplayScreen(void)
 {
     UpdateMusicStream(musSpy);
-    
+
     for (int i = 0; i < MAX_CODING_WORDS; i++)
     {
         if (CheckCollisionPointRec(GetMousePosition(), words[i].rec))
         {
             words[i].hover = true;
-            
+
             if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON))
             {
                 words[i].picked = true;
@@ -290,41 +286,41 @@ void UpdateGameplayScreen(void)
             }
         }
         else words[i].hover = false;
-        
-        
+
+
         if (words[i].picked)
-        {  
+        {
             for (int j = 0; j < missions[currentMission].wordsCount; j++)
-            {               
+            {
                 if (CheckCollisionPointRec(GetMousePosition(), messageWords[j].rec)) messageWords[j].hover = true;
                 else messageWords[j].hover = false;
             }
-            
+
             if (IsMouseButtonReleased(MOUSE_LEFT_BUTTON))
-            {              
+            {
                 words[i].picked = false;
-                
+
                 for (int j = 0; j < missions[currentMission].wordsCount; j++)
-                {     
+                {
                     messageWords[j].hover = false;
-                    
+
                     if (CheckCollisionPointRec(GetMousePosition(), messageWords[j].rec))
                     {
                         PlaySound(fxPlace);
-                        
+
                         words[i].rec.x = messageWords[j].rec.x;
                         words[i].rec.y = messageWords[j].rec.y;
-                        
+
                         if (messageWords[j].id != -1)
                         {
                             int id = messageWords[j].id;
                             words[id].rec = words[id].iniRec;
                         }
-                        
+
                         messageWords[j].id = i;
                         for (int k = 0; k < missions[currentMission].wordsCount; k++)
                         {
-                            if (j != k && messageWords[j].id == messageWords[k].id) 
+                            if (j != k && messageWords[j].id == messageWords[k].id)
                             {
                                 messageWords[k].id = -1;
                                 break;
@@ -332,60 +328,53 @@ void UpdateGameplayScreen(void)
                         }
                         break;
                     }
-                    else 
+                    else
                     {
                         PlaySound(fxLeave);
-                        
+
                         words[i].rec = words[i].iniRec;
                         if (i == messageWords[j].id) messageWords[j].id = -1;
                     }
-                } 
-            }            
+                }
+            }
         }
-        
-        // TODO: Move word picked with mouse
+
+        // Move word picked with mouse
         if (words[i].picked)
         {
             words[i].rec.x = GetMouseX() - words[i].rec.width/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;
-    for(int j = 0; j < missions[currentMission].wordsCount; j++)
-    {               
-        if(messageWords[j].id == -1)
+    for (int j = 0; j < missions[currentMission].wordsCount; j++)
+    {
+        if (messageWords[j].id == -1)
         {
             canSend = false;
             break;
         }
     }
-    
-    if (canSend && (IsKeyPressed(KEY_ENTER) || IsButtonPressed())) 
-    {       
+
+    if (canSend && (IsKeyPressed(KEY_ENTER) || IsButtonPressed()))
+    {
         finishScreen = true;
-    } 
+    }
 }
 
 // Gameplay Screen Draw logic
 void DrawGameplayScreen(void)
 {
     DrawTexture(texBackground, 0, 0, WHITE);
-    
+
     DrawTextEx(fontMessage, missions[currentMission].msg, msgOffset, fontMessage.baseSize, 0, BLACK);
-    
+
     for (int i = 0; i < missions[currentMission].wordsCount; i++)
     {
         Rectangle recLines = messageWords[i].rec;
         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);
     }
     for (int i = 0; i < MAX_CODING_WORDS; i++)
@@ -394,9 +383,9 @@ void DrawGameplayScreen(void)
         else if (words[i].hover) DrawTextureRec(texWordsAtlas, (Rectangle){ 0, i*35, 140, 35 }, (Vector2){ words[i].rec.x, words[i].rec.y }, RED);
         else DrawTextureRec(texWordsAtlas, (Rectangle){ 0, i*35, 140, 35 }, (Vector2){ words[i].rec.x, words[i].rec.y }, WHITE);
     }
-    
+
     DrawTexturePro(texVignette, (Rectangle){0,0,texVignette.width, texVignette.height}, (Rectangle){0,0,GetScreenWidth(), GetScreenHeight()}, (Vector2){0,0}, 0, WHITE);
-    
+
     if (canSend) DrawButton("enviar");
 }
 
@@ -406,13 +395,13 @@ void UnloadGameplayScreen(void)
     UnloadTexture(texBackground);
     UnloadTexture(texVignette);
     UnloadTexture(texWordsAtlas);
-    
+
     UnloadSound(fxGrab);
     UnloadSound(fxLeave);
     UnloadSound(fxPlace);
-    
+
     UnloadMusicStream(musSpy);
-    
+
     free(missions);
 }
 

+ 4 - 7
games/transmission/screens/screen_logo.c

@@ -61,15 +61,15 @@ void InitLogoScreen(void)
 // Logo Screen Update logic
 void UpdateLogoScreen(void)
 {
-    if(!fadeOut)
+    if (!fadeOut)
     {       
         fadeValue += 0.02f;
-        if(fadeValue > 1.01f)
+        if (fadeValue > 1.01f)
         {
             fadeValue = 1.0f;
             framesCounter++;
             
-            if(framesCounter % showLogoFrames == 0)
+            if ((framesCounter%showLogoFrames) == 0)
             {
                 fadeOut = true;
                 finishScreen = true;
@@ -77,10 +77,7 @@ void UpdateLogoScreen(void)
         }        
     }   
     
-    if(IsKeyPressed(KEY_ENTER))
-    {
-        finishScreen = true;
-    }
+    if (IsKeyPressed(KEY_ENTER)) finishScreen = true;
 }
 
 // Logo Screen Draw logic

+ 68 - 70
games/transmission/screens/screen_mission.c

@@ -88,34 +88,33 @@ static Music musMission;
 // Mission Screen Functions Definition
 //----------------------------------------------------------------------------------
 static void WriteMissionText();
-static void EndWritting();
-static void BlinkKeyword();
+
 
 // Mission Screen Initialization logic
 void InitMissionScreen(void)
 {
     framesCounter = 0;
     finishScreen = 0;
-    
-    fadeButton = 0.80f;  
-    
+
+    fadeButton = 0.80f;
+
     texBackground = LoadTexture("resources/textures/mission_background.png");
-    
-    texBackline = LoadTexture("resources/textures/mission_backline.png");    
+
+    texBackline = LoadTexture("resources/textures/mission_backline.png");
     sourceRecBackLine = (Rectangle){0,0,GetScreenWidth(), texBackline.height};
     destRecBackLine = (Rectangle){0,0,sourceRecBackLine.width, sourceRecBackLine.height};
     fadeBackLine = 0;
-    
+
     fxTransmit = LoadSound("resources/audio/fx_message.ogg");
     musMission = LoadMusicStream("resources/audio/music_mission.ogg");
-    
+
     PlayMusicStream(musMission);
-    
+
     // Initialize missions
     missions = LoadMissions("resources/missions.txt");
-    
+
     missionMaxLength = strlen(missions[currentMission].brief);
-    
+
     // Insert line breaks every MAX_LINE_CHAR
     int currentLine = 1;
     int i = currentLine * MAX_LINE_CHAR;
@@ -129,35 +128,35 @@ void InitMissionScreen(void)
             i = currentLine*MAX_LINE_CHAR;
         }
         else i++;
-    }        
-    
-    missionSize = 30;    
+    }
+
+    missionSize = 30;
     missionLenght = 0;
     missionSpeed = 1;
-    
+
     numberColor = RAYWHITE;
     missionColor = LIGHTGRAY;
     keywordColor = (Color){198, 49, 60, 255}; //RED
-    
+
     numberPosition = (Vector2){150, 185};
     missionPosition = (Vector2){numberPosition.x, numberPosition.y + 60};
     keywordPosition = (Vector2){missionPosition.x, missionPosition.y + MeasureTextEx(fontMission, missions[currentMission].brief, missionSize, 0).y + 60};
-    
+
     startWritting = false;
     writeNumber = false;
     writeMission = false;
     writeKeyword = false;
     writeEnd = false;
-    
+
     writtingMission = false;
-    
+
     showNumberWaitFrames = 30;
-    showMissionWaitFrames = 60; 
-    showKeywordWaitFrames = 60;    
-    
+    showMissionWaitFrames = 60;
+    showKeywordWaitFrames = 60;
+
     blinkKeyWord = true;
     blinkFrames = 15;
-    
+
     PlaySound(fxTransmit);
 }
 
@@ -165,37 +164,52 @@ void InitMissionScreen(void)
 void UpdateMissionScreen(void)
 {
     UpdateMusicStream(musMission);
-    
-    if (!writeEnd) WriteMissionText(); 
-    else BlinkKeyword();
-    
+
+    if (!writeEnd) WriteMissionText();
+    else
+    {
+        framesCounter++;
+
+        if ((framesCounter%blinkFrames) == 0)
+        {
+            framesCounter = 0;
+            blinkKeyWord = !blinkKeyWord;
+        }
+    }
+
     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
             {
                 finishScreen = true;
                 showButton = false;
             }
-        } 
+        }
     }
 }
 
 // Mission Screen Draw logic
 void DrawMissionScreen(void)
 {
-    // TODO: Draw MISSION screen here!
+    // Draw MISSION screen here!
     DrawTexture(texBackground, 0,0, WHITE);
     DrawTexturePro(texBackline, sourceRecBackLine, destRecBackLine, (Vector2){0,0},0, Fade(WHITE, fadeBackLine));
-    
-    if (writeNumber) DrawTextEx(fontMission, FormatText("Filtración #%02i ", currentMission + 1), numberPosition, missionSize + 10, 0, numberColor);    
+
+    if (writeNumber) DrawTextEx(fontMission, FormatText("Filtración #%02i ", currentMission + 1), numberPosition, missionSize + 10, 0, numberColor);
     DrawTextEx(fontMission, SubText(missions[currentMission].brief, 0, missionLenght), missionPosition, missionSize, 0, missionColor);
-    if (writeKeyword && blinkKeyWord) DrawTextEx(fontMission, FormatText("Keyword: %s", missions[currentMission].key), keywordPosition, missionSize + 10, 0, keywordColor);    
-    
-    if (showButton) 
-    {        
+    if (writeKeyword && blinkKeyWord) DrawTextEx(fontMission, FormatText("Keyword: %s", missions[currentMission].key), keywordPosition, missionSize + 10, 0, keywordColor);
+
+    if (showButton)
+    {
         if (!writeEnd) DrawButton("saltar");
         else DrawButton("codificar");
     }
@@ -204,8 +218,8 @@ void DrawMissionScreen(void)
 // Mission Screen Unload logic
 void UnloadMissionScreen(void)
 {
-    // TODO: Unload MISSION screen variables here!
-    UnloadTexture(texBackground); 
+    // Unload MISSION screen variables here!
+    UnloadTexture(texBackground);
     UnloadTexture(texBackline);
     UnloadSound(fxTransmit);
     UnloadMusicStream(musMission);
@@ -220,74 +234,58 @@ int FinishMissionScreen(void)
 
 static void WriteMissionText()
 {
-    if(!startWritting)
+    if (!startWritting)
     {
         framesCounter++;
-        if(framesCounter % 60 == 0) 
+        if (framesCounter % 60 == 0)
         {
             framesCounter = 0;
             startWritting = true;
         }
-    }    
-    else if(!writeNumber)
+    }
+    else if (!writeNumber)
     {
         framesCounter++;
         fadeBackLine += 0.020f;
-        if(framesCounter % showNumberWaitFrames == 0)
+        if (framesCounter % showNumberWaitFrames == 0)
         {
             framesCounter = 0;
             writeNumber = true;
             showButton = true;
         }
     }
-    else if(!writeMission)
+    else if (!writeMission)
     {
         framesCounter ++;
-        if(framesCounter % showMissionWaitFrames == 0)
+        if (framesCounter % showMissionWaitFrames == 0)
         {
             framesCounter = 0;
             writeMission = true;
             writtingMission = true;
         }
     }
-    else if(writeMission && writtingMission)
+    else if (writeMission && writtingMission)
     {
         framesCounter++;
-        if(framesCounter % missionSpeed == 0)
+        if (framesCounter % missionSpeed == 0)
         {
             framesCounter = 0;
-            missionLenght++;            
-            
-            if(missionLenght == missionMaxLength)
+            missionLenght++;
+
+            if (missionLenght == missionMaxLength)
             {
                 writtingMission = false;
             }
         }
     }
-    else if(!writeKeyword)
+    else if (!writeKeyword)
     {
         framesCounter++;
-        if(framesCounter % showKeywordWaitFrames == 0)
+        if (framesCounter % showKeywordWaitFrames == 0)
         {
             framesCounter = 0;
             writeKeyword = true;
             writeEnd = true;
         }
-    }    
-}
-static void EndWritting()
-{
-    writeEnd = true;
-    writeKeyword = true;
-    writeNumber = true;
-    missionLenght = missionMaxLength;
-}
-static void BlinkKeyword()
-{
-    framesCounter++;
-    if(framesCounter % blinkFrames == 0)
-    {
-        framesCounter = 0;
-        blinkKeyWord = !blinkKeyWord;
     }
 }