Konzolový Had 7 – Hlavné menu

V dnešnom diely budeme pracovať na ďalšej dôležitej časti našej hry, a to na hlavné menu.

Úvod

Po spustení väčšiny hier sa vám zobrazí hlavné menu, ktoré vám dovoľuje spustiť vašu hru, ukončiť a kam sa vrátite po jej dohraní. To nemôže chýbať ani v našej hre. Jej hlavné menu bude obsahovať viacej položiek a to spustenie novej hry (pre jedného aj dvoch hráčov) , načítanie hry a samozrejme vypnutie hry.

Trieda, ktorú budeme používať sa bude volať MainmenuScene, ktorá je v skutočnosti pomerne malá a jednoduchá. Najviac miesta v nej zaberá vykresľovanie pomocou metódy Draw.

Premenné a konštruktor

Najprv sa už klasicky pozrieme na premenné, ktorých tento krát bude len päť. Okrem bežného rodiča typu Game tu máme ešte tri boolovské hodnoty a jeden integer. Jedná sa o informácie o tom, či už bol obraz vykreslený, či už sme zahrali melódiu alebo či je momentálne zobrazený dialóg. Integer bude slúžiť na uloženie aktuálne vybratej položky.

private Game Parent;
private int selectedItem = 0;
private bool asked = false;
private bool played = false;
private bool drawed = false;

S týmto súvisí aj konštrukor, ktorý nastaví rodiča.

public MainMenuScene(Game parent)
{
    Parent = parent;
}

Metóda Update

Metóda Update sa skladá z troch samostatných častí. Prvá slúži na zahranie uvítacej melódie, druhá na reakciu pri stlačení tlačidla EXIT a tretia ovláda pohyb a akcie tlačidiel.

Zahranie melódie je podobné ako pri triede HighscoresScene, pričom si overíme, či už menu bolo aspoň raz vykreslené a či sme melódiu už raz nehrali. Potom pomocou Console.Beep zahráme melódiu a zapamätáme si, že sme ju zahrali.

if (!played && drawed)
{
    played = true;
    Console.Beep(200, 1000);
    Console.Beep(310, 500);
    Console.Beep(250, 250);
    Console.Beep(220, 250);
    Console.Beep(330, 500);
    Console.Beep(310, 1000);
}

V druhej časti je na rade premenná asked. Ak je nastavená ako true (čiže, ak sme sa pýtali otázku), tak ju vrátime na false a skontrolujeme, či hráč odpovedal kladne. Ak áno, vypneme hru.

if (asked)
{
    asked = false;
    if (Parent.Question.result) Program.Running = false;
}

Poznámka: Objekty Parent.Question a Program.Running eštee nemáte vytvorené. Na tie sa zameriame v ďalších dieloch.

Posledná časť metódy Update je samotné ovládanie menu. Celá prebieha v podmienke, ktorá kontroluje, či bolo stlačené tlačidlo if (Console.KeyAvailable) .

Tlačidlo je následne uložené do premennej ConsoleKey key = Console.ReadKey(true).Key; , ktorá je použitá v Switch podmienke. switch (key) .

V tejto podmienke skontrolujeme tlačidlá UpArrow (šípku hore) a W a zároveň DownArrow /šípku dole) a S. Tie budú slúžiť na pohyb, medzi možnosťami dole alebo hore. To prebehne pomocou zmeny hodnoty premennej selectedItem.

case ConsoleKey.UpArrow:
case ConsoleKey.W: if (selectedItem == 0) selectedItem = 3; else selectedItem--; break;
case ConsoleKey.DownArrow:
case ConsoleKey.S: if (selectedItem == 3) selectedItem = 0; else selectedItem++; break;

Podmienky if, ktoré môžete v kóde vidieť slúžia na obmedzenie hodnôt premennej selectedItem.

Tento switch má ešte jeden case a to pre tlačidlo Enter. Ten bude obsahovať ďalšiu podmienku Switch a to práve pre položku selectedItem. Prvé dve položky (case 0 a case 1) sú skoro totožné z jednou malou zmenou. Tieto slúžia na spustenie hry v režime jedného alebo dvoch hráčov. V prípade aktivácie case 0 sa nastavia premenné Level, ScoreLives v rodičovi na základné hodnoty a vyberie sa scéna na SaveGame. Tejto scéne sa nastaví predošlá scéna ako Hlavné menu, aby vedela, kam sa má vrátiť. Na záver je nastavená premenná MP tejto scény na false.

V prípade case 1 sa MP nastaví na trueselectedItem sa obnoví na 0.

case 0:
    Parent.Level = 1;
    Parent.Score = 0;
    Parent.Lives = 5;
    Parent.currentScene = Game.Scenes.SaveGame;
    Parent.SaveQuestion.last = Game.Scenes.MainMenu;
    Parent.SaveQuestion.MP = false;
    break;
case 1:
    selectedItem = 0;
    Parent.Level = 1;
    Parent.Score = 0;
    Parent.Lives = 5;
    Parent.currentScene = Game.Scenes.SaveGame;
    Parent.SaveQuestion.last = Game.Scenes.MainMenu;
    Parent.SaveQuestion.MP = true;
    break;

Poznámka: Premenné Parent.currentScene, Game.Scenes a Parent.SaveQuestion ešte nemáte vytvorené, budeme sa im venovať v ďalších dieloch.
Ďalej máme case 2, ktorý len nastaví selectedItem na 0 a scénu na LoadGame (ešte nevytvorená).

case 2:
    selectedItem = 0;
    Parent.currentScene = Game.Scenes.LoadGame;
    Parent.SaveQuestion.last = Game.Scenes.MainMenu;
    break;

A na záver metódy update je tu case 3, ktorý nastaví text otázky, premennú asked na true a vyberie scénu Question (opäť ešte nieje vytvorená).

case 3:
    asked = true;
    Parent.Question.Text = "REALLY WANT TO EXIT TO WINDOWS?";
    Parent.Question.last = Game.Scenes.MainMenu;
    Parent.currentScene = Game.Scenes.Question;
    break;

Zobraziť celú metódu

public void Update()
{
    if (!played && drawed)
    {
        played = true;
        Console.Beep(200, 1000);
        Console.Beep(310, 500);
        Console.Beep(250, 250);
        Console.Beep(220, 250);
        Console.Beep(330, 500);
        Console.Beep(310, 1000);
    }

    if (asked)
    {
        asked = false;
        if (Parent.Question.result) Program.Running = false;
    }

    if (Console.KeyAvailable)
    {
        ConsoleKey key = Console.ReadKey(true).Key;
        switch (key)
        {
            case ConsoleKey.UpArrow:
            case ConsoleKey.W: if (selectedItem == 0) selectedItem = 3; else selectedItem--; break;
            case ConsoleKey.DownArrow:
            case ConsoleKey.S: if (selectedItem == 3) selectedItem = 0; else selectedItem++; break;
            case ConsoleKey.Enter:
                switch (selectedItem)
                {
                case 0:
                    Parent.Level = 1;
                    Parent.Score = 0;
                    Parent.Lives = 5;
                    Parent.currentScene = Game.Scenes.SaveGame;
                    Parent.SaveQuestion.last = Game.Scenes.MainMenu;
                    Parent.SaveQuestion.MP = false;
                    break;
                case 1:
                    selectedItem = 0;
                    Parent.Level = 1;
                    Parent.Score = 0;
                    Parent.Lives = 5;
                    Parent.currentScene = Game.Scenes.SaveGame;
                    Parent.SaveQuestion.last = Game.Scenes.MainMenu;
                    Parent.SaveQuestion.MP = true;
                    break;
                    case 2:
                        selectedItem = 0;
                        Parent.currentScene = Game.Scenes.LoadGame;
                        Parent.SaveQuestion.last = Game.Scenes.MainMenu;
                        break;
                    case 3:
                        asked = true;
                        Parent.Question.Text = "REALLY WANT TO EXIT TO WINDOWS?";
                        Parent.Question.last = Game.Scenes.MainMenu;
                        Parent.currentScene = Game.Scenes.Question;
                        break;
                }
                break;
        }
    }
}

Metóda Draw

Metóda Draw je približne rovnako dlhá ako metóda Update, no je oveľa jednoduchšia na pochopenie. Najprv vykreslíme tvar loga SNAKE a následne v štyroch podmienkach tlačidlá. Podmienky určujú, či bude tlačidlo vykreslené zelenou (ak je vybraté) alebo modrou (ak nieje vybraté) farbou.

Na začiatku si ale musíme nastaviť premennú drawed na true, aby sme hru informovali, že už raz bol obraz vykreslený.

Tiež si vypočítame pozíciu loga hada podľa veľkosti okna ((veľkosť okna mínus veľkosť loga) deleno dva).

if (!drawed) drawed = true;

int LogoPosX = (Renderer.WindowSize.X - 48) / 2;

Po tomto vykreslíme logo hada pomocou metód Renderer.DrawRectangleRenerer.DrawPoint.

//S
Renderer.DrawRectangle(new Rectangle(LogoPosX, 2, 47, 1), ConsoleColor.Yellow);
Renderer.DrawRectangle(new Rectangle(LogoPosX + 47, 2, 1, 1), ConsoleColor.DarkYellow);
Renderer.DrawString(":", new Vector2(LogoPosX + 47, 2), ConsoleColor.DarkRed);
Renderer.DrawRectangle(new Rectangle(LogoPosX, 3, 1, 3), ConsoleColor.Yellow);
Renderer.DrawRectangle(new Rectangle(LogoPosX, 6, 8, 1), ConsoleColor.Yellow);
Renderer.DrawRectangle(new Rectangle(LogoPosX+7, 7, 1, 4), ConsoleColor.Yellow);
Renderer.DrawRectangle(new Rectangle(LogoPosX, 11, 8, 1), ConsoleColor.Yellow);
//N
Renderer.DrawRectangle(new Rectangle(LogoPosX + 10, 4, 1, 8), ConsoleColor.Green);
Renderer.DrawPoint(new Vector2(LogoPosX + 11, 5), ConsoleColor.Green);
Renderer.DrawPoint(new Vector2(LogoPosX + 12, 6), ConsoleColor.Green);
Renderer.DrawPoint(new Vector2(LogoPosX + 13, 7), ConsoleColor.Green);
Renderer.DrawPoint(new Vector2(LogoPosX + 14, 8), ConsoleColor.Green);
Renderer.DrawPoint(new Vector2(LogoPosX + 15, 9), ConsoleColor.Green);
Renderer.DrawPoint(new Vector2(LogoPosX + 16, 10), ConsoleColor.Green);
Renderer.DrawRectangle(new Rectangle(LogoPosX + 17, 4, 1, 8), ConsoleColor.Green);
//A
Renderer.DrawRectangle(new Rectangle(LogoPosX + 20, 6, 1, 6), ConsoleColor.Green);
Renderer.DrawRectangle(new Rectangle(LogoPosX + 21, 5, 2, 1), ConsoleColor.Green);
Renderer.DrawRectangle(new Rectangle(LogoPosX + 23, 4, 2, 1), ConsoleColor.Green);
Renderer.DrawRectangle(new Rectangle(LogoPosX + 21, 8, 6, 1), ConsoleColor.Green);
Renderer.DrawRectangle(new Rectangle(LogoPosX + 25, 5, 2, 1), ConsoleColor.Green);
Renderer.DrawRectangle(new Rectangle(LogoPosX + 27, 6, 1, 6), ConsoleColor.Green);
//K
Renderer.DrawRectangle(new Rectangle(LogoPosX + 30, 4, 1, 8), ConsoleColor.Green);
Renderer.DrawRectangle(new Rectangle(LogoPosX + 31, 7, 1, 2), ConsoleColor.Green);
Renderer.DrawRectangle(new Rectangle(LogoPosX + 32, 6, 2, 1), ConsoleColor.Green);
Renderer.DrawRectangle(new Rectangle(LogoPosX + 34, 5, 2, 1), ConsoleColor.Green);
Renderer.DrawRectangle(new Rectangle(LogoPosX + 36, 4, 2, 1), ConsoleColor.Green);
Renderer.DrawRectangle(new Rectangle(LogoPosX + 32, 9, 2, 1), ConsoleColor.Green);
Renderer.DrawRectangle(new Rectangle(LogoPosX + 34, 10, 2, 1), ConsoleColor.Green);
Renderer.DrawRectangle(new Rectangle(LogoPosX + 36, 11, 2, 1), ConsoleColor.Green);
//E
Renderer.DrawRectangle(new Rectangle(LogoPosX + 40, 4, 1, 8), ConsoleColor.Green);
Renderer.DrawRectangle(new Rectangle(LogoPosX + 41, 4, 7, 1), ConsoleColor.Green);
Renderer.DrawRectangle(new Rectangle(LogoPosX + 41, 7, 6, 1), ConsoleColor.Green);
Renderer.DrawRectangle(new Rectangle(LogoPosX + 41, 11, 7, 1), ConsoleColor.Green);

A na záver samotné tlačidlá pomocou metód DrawRectangleDrawString.

if (selectedItem == 0)
{
    Renderer.DrawRectangle(new Rectangle((Renderer.WindowSize.X - 35) / 2, 14, 35, 3), ConsoleColor.Green);
    Renderer.DrawString("New One Player Game", new Vector2((Renderer.WindowSize.X - "New One Player Game".Length) / 2, 15), ConsoleColor.Black);
}
else
{
    Renderer.DrawRectangle(new Rectangle((Renderer.WindowSize.X - 35) / 2, 14, 35, 3), ConsoleColor.Blue);
    Renderer.DrawString("New One Player Game", new Vector2((Renderer.WindowSize.X - "New One Player Game".Length) / 2, 15), ConsoleColor.White);
}
if (selectedItem == 1)
{
    Renderer.DrawRectangle(new Rectangle((Renderer.WindowSize.X - 35) / 2, 18, 35, 3), ConsoleColor.Green);
    Renderer.DrawString("New Two Player Game", new Vector2((Renderer.WindowSize.X - "New Two Player Game".Length) / 2, 19), ConsoleColor.Black);
}
else
{
    Renderer.DrawRectangle(new Rectangle((Renderer.WindowSize.X - 35) / 2, 18, 35, 3), ConsoleColor.Blue);
    Renderer.DrawString("New Two Player Game", new Vector2((Renderer.WindowSize.X - "New Two Player Game".Length) / 2, 19), ConsoleColor.White);
}
if (selectedItem == 2)
{
    Renderer.DrawRectangle(new Rectangle((Renderer.WindowSize.X - 35) / 2, 22, 35, 3), ConsoleColor.Green);
    Renderer.DrawString("Load Game", new Vector2((Renderer.WindowSize.X - "Load Game".Length) / 2, 23), ConsoleColor.Black);
}
else
{
    Renderer.DrawRectangle(new Rectangle((Renderer.WindowSize.X - 35) / 2, 22, 35, 3), ConsoleColor.Blue);
    Renderer.DrawString("Load Game", new Vector2((Renderer.WindowSize.X - "Load Game".Length) / 2, 23), ConsoleColor.White);
}
if (selectedItem == 3)
{
    Renderer.DrawRectangle(new Rectangle((Renderer.WindowSize.X - 35) / 2, 26, 35, 3), ConsoleColor.Green);
    Renderer.DrawString("Exit", new Vector2((Renderer.WindowSize.X - "Exit".Length) / 2, 27), ConsoleColor.Black);
}
else
{
    Renderer.DrawRectangle(new Rectangle((Renderer.WindowSize.X - 35) / 2, 26, 35, 3), ConsoleColor.Blue);
    Renderer.DrawString("Exit", new Vector2((Renderer.WindowSize.X - "Exit".Length) / 2, 27), ConsoleColor.White);
}

Zobraziť celú metódu

public void Draw()
{
if (!drawed) drawed = true;
int LogoPosX = (Renderer.WindowSize.X - 48) / 2;
//S
Renderer.DrawRectangle(new Rectangle(LogoPosX, 2, 47, 1), ConsoleColor.Yellow);
Renderer.DrawRectangle(new Rectangle(LogoPosX + 47, 2, 1, 1), ConsoleColor.DarkYellow);
Renderer.DrawString(":", new Vector2(LogoPosX + 47, 2), ConsoleColor.DarkRed);
Renderer.DrawRectangle(new Rectangle(LogoPosX, 3, 1, 3), ConsoleColor.Yellow);
Renderer.DrawRectangle(new Rectangle(LogoPosX, 6, 8, 1), ConsoleColor.Yellow);
Renderer.DrawRectangle(new Rectangle(LogoPosX+7, 7, 1, 4), ConsoleColor.Yellow);
Renderer.DrawRectangle(new Rectangle(LogoPosX, 11, 8, 1), ConsoleColor.Yellow);
//N
Renderer.DrawRectangle(new Rectangle(LogoPosX + 10, 4, 1, 8), ConsoleColor.Green);
Renderer.DrawPoint(new Vector2(LogoPosX + 11, 5), ConsoleColor.Green);
Renderer.DrawPoint(new Vector2(LogoPosX + 12, 6), ConsoleColor.Green);
Renderer.DrawPoint(new Vector2(LogoPosX + 13, 7), ConsoleColor.Green);
Renderer.DrawPoint(new Vector2(LogoPosX + 14, 8), ConsoleColor.Green);
Renderer.DrawPoint(new Vector2(LogoPosX + 15, 9), ConsoleColor.Green);
Renderer.DrawPoint(new Vector2(LogoPosX + 16, 10), ConsoleColor.Green);
Renderer.DrawRectangle(new Rectangle(LogoPosX + 17, 4, 1, 8), ConsoleColor.Green);
//A
Renderer.DrawRectangle(new Rectangle(LogoPosX + 20, 6, 1, 6), ConsoleColor.Green);
Renderer.DrawRectangle(new Rectangle(LogoPosX + 21, 5, 2, 1), ConsoleColor.Green);
Renderer.DrawRectangle(new Rectangle(LogoPosX + 23, 4, 2, 1), ConsoleColor.Green);
Renderer.DrawRectangle(new Rectangle(LogoPosX + 21, 8, 6, 1), ConsoleColor.Green);
Renderer.DrawRectangle(new Rectangle(LogoPosX + 25, 5, 2, 1), ConsoleColor.Green);
Renderer.DrawRectangle(new Rectangle(LogoPosX + 27, 6, 1, 6), ConsoleColor.Green);
//K
Renderer.DrawRectangle(new Rectangle(LogoPosX + 30, 4, 1, 8), ConsoleColor.Green);
Renderer.DrawRectangle(new Rectangle(LogoPosX + 31, 7, 1, 2), ConsoleColor.Green);
Renderer.DrawRectangle(new Rectangle(LogoPosX + 32, 6, 2, 1), ConsoleColor.Green);
Renderer.DrawRectangle(new Rectangle(LogoPosX + 34, 5, 2, 1), ConsoleColor.Green);
Renderer.DrawRectangle(new Rectangle(LogoPosX + 36, 4, 2, 1), ConsoleColor.Green);
Renderer.DrawRectangle(new Rectangle(LogoPosX + 32, 9, 2, 1), ConsoleColor.Green);
Renderer.DrawRectangle(new Rectangle(LogoPosX + 34, 10, 2, 1), ConsoleColor.Green);
Renderer.DrawRectangle(new Rectangle(LogoPosX + 36, 11, 2, 1), ConsoleColor.Green);
//E
Renderer.DrawRectangle(new Rectangle(LogoPosX + 40, 4, 1, 8), ConsoleColor.Green);
Renderer.DrawRectangle(new Rectangle(LogoPosX + 41, 4, 7, 1), ConsoleColor.Green);
Renderer.DrawRectangle(new Rectangle(LogoPosX + 41, 7, 6, 1), ConsoleColor.Green);
Renderer.DrawRectangle(new Rectangle(LogoPosX + 41, 11, 7, 1), ConsoleColor.Green);
#region Menu
if (selectedItem == 0)
{
Renderer.DrawRectangle(new Rectangle((Renderer.WindowSize.X - 35) / 2, 14, 35, 3), ConsoleColor.Green);
Renderer.DrawString("New One Player Game", new Vector2((Renderer.WindowSize.X - "New One Player Game".Length) / 2, 15), ConsoleColor.Black);
}
else
{
Renderer.DrawRectangle(new Rectangle((Renderer.WindowSize.X - 35) / 2, 14, 35, 3), ConsoleColor.Blue);
Renderer.DrawString("New One Player Game", new Vector2((Renderer.WindowSize.X - "New One Player Game".Length) / 2, 15), ConsoleColor.White);
}
if (selectedItem == 1)
{
Renderer.DrawRectangle(new Rectangle((Renderer.WindowSize.X - 35) / 2, 18, 35, 3), ConsoleColor.Green);
Renderer.DrawString("New Two Player Game", new Vector2((Renderer.WindowSize.X - "New Two Player Game".Length) / 2, 19), ConsoleColor.Black);
}
else
{
Renderer.DrawRectangle(new Rectangle((Renderer.WindowSize.X - 35) / 2, 18, 35, 3), ConsoleColor.Blue);
Renderer.DrawString("New Two Player Game", new Vector2((Renderer.WindowSize.X - "New Two Player Game".Length) / 2, 19), ConsoleColor.White);
}
if (selectedItem == 2)
{
Renderer.DrawRectangle(new Rectangle((Renderer.WindowSize.X - 35) / 2, 22, 35, 3), ConsoleColor.Green);
Renderer.DrawString("Load Game", new Vector2((Renderer.WindowSize.X - "Load Game".Length) / 2, 23), ConsoleColor.Black);
}
else
{
Renderer.DrawRectangle(new Rectangle((Renderer.WindowSize.X - 35) / 2, 22, 35, 3), ConsoleColor.Blue);
Renderer.DrawString("Load Game", new Vector2((Renderer.WindowSize.X - "Load Game".Length) / 2, 23), ConsoleColor.White);
}
if (selectedItem == 3)
{
Renderer.DrawRectangle(new Rectangle((Renderer.WindowSize.X - 35) / 2, 26, 35, 3), ConsoleColor.Green);
Renderer.DrawString("Exit", new Vector2((Renderer.WindowSize.X - "Exit".Length) / 2, 27), ConsoleColor.Black);
}
else
{
Renderer.DrawRectangle(new Rectangle((Renderer.WindowSize.X - 35) / 2, 26, 35, 3), ConsoleColor.Blue);
Renderer.DrawString("Exit", new Vector2((Renderer.WindowSize.X - "Exit".Length) / 2, 27), ConsoleColor.White);
}
#endregion
}

Týmto sme si preberali celú triedu MainmenuScene, a nabudúce sa pozrieme na už spomínanú triedu ExitQuestion. Na záver vám sem ešte vložím kompletný kód triedy.

Mainmenu

Zobraziť celú triedu

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Snake
{
public class MainMenuScene
{
private Game Parent;
private int selectedItem = 0;
private bool asked = false;
private bool played = false;
private bool drawed = false;
public MainMenuScene(Game parent)
{
Parent = parent;
}
public void Update()
{
if (!played && drawed)
{
played = true;
Console.Beep(200, 1000);
Console.Beep(310, 500);
Console.Beep(250, 250);
Console.Beep(220, 250);
Console.Beep(330, 500);
Console.Beep(310, 1000);
}
if (asked)
{
asked = false;
if (Parent.Question.result) Program.Running = false;
}
if (Console.KeyAvailable)
{
ConsoleKey key = Console.ReadKey(true).Key;
switch (key)
{
case ConsoleKey.UpArrow:
case ConsoleKey.W: if (selectedItem == 0) selectedItem = 3; else selectedItem--; break;
case ConsoleKey.DownArrow:
case ConsoleKey.S: if (selectedItem == 3) selectedItem = 0; else selectedItem++; break;
case ConsoleKey.Enter:
switch (selectedItem)
{
case 0:
Parent.Level = 1;
Parent.Score = 0;
Parent.Lives = 5;
Parent.currentScene = Game.Scenes.SaveGame;
Parent.SaveQuestion.last = Game.Scenes.MainMenu;
Parent.SaveQuestion.MP = false;
break;
case 1:
selectedItem = 0;
Parent.Level = 1;
Parent.Score = 0;
Parent.Lives = 5;
Parent.currentScene = Game.Scenes.SaveGame;
Parent.SaveQuestion.last = Game.Scenes.MainMenu;
Parent.SaveQuestion.MP = true;
break;
case 2:
selectedItem = 0;
Parent.currentScene = Game.Scenes.LoadGame;
Parent.SaveQuestion.last = Game.Scenes.MainMenu;
break;
case 3:
asked = true;
Parent.Question.Text = "REALLY WANT TO EXIT TO WINDOWS?";
Parent.Question.last = Game.Scenes.MainMenu;
Parent.currentScene = Game.Scenes.Question;
break;
}
break;
}
}
}
public void Draw()
{
if (!drawed) drawed = true;
int LogoPosX = (Renderer.WindowSize.X - 48) / 2;
//S
Renderer.DrawRectangle(new Rectangle(LogoPosX, 2, 47, 1), ConsoleColor.Yellow);
Renderer.DrawRectangle(new Rectangle(LogoPosX + 47, 2, 1, 1), ConsoleColor.DarkYellow);
Renderer.DrawString(":", new Vector2(LogoPosX + 47, 2), ConsoleColor.DarkRed);
Renderer.DrawRectangle(new Rectangle(LogoPosX, 3, 1, 3), ConsoleColor.Yellow);
Renderer.DrawRectangle(new Rectangle(LogoPosX, 6, 8, 1), ConsoleColor.Yellow);
Renderer.DrawRectangle(new Rectangle(LogoPosX+7, 7, 1, 4), ConsoleColor.Yellow);
Renderer.DrawRectangle(new Rectangle(LogoPosX, 11, 8, 1), ConsoleColor.Yellow);
//N
Renderer.DrawRectangle(new Rectangle(LogoPosX + 10, 4, 1, 8), ConsoleColor.Green);
Renderer.DrawPoint(new Vector2(LogoPosX + 11, 5), ConsoleColor.Green);
Renderer.DrawPoint(new Vector2(LogoPosX + 12, 6), ConsoleColor.Green);
Renderer.DrawPoint(new Vector2(LogoPosX + 13, 7), ConsoleColor.Green);
Renderer.DrawPoint(new Vector2(LogoPosX + 14, 8), ConsoleColor.Green);
Renderer.DrawPoint(new Vector2(LogoPosX + 15, 9), ConsoleColor.Green);
Renderer.DrawPoint(new Vector2(LogoPosX + 16, 10), ConsoleColor.Green);
Renderer.DrawRectangle(new Rectangle(LogoPosX + 17, 4, 1, 8), ConsoleColor.Green);
//A
Renderer.DrawRectangle(new Rectangle(LogoPosX + 20, 6, 1, 6), ConsoleColor.Green);
Renderer.DrawRectangle(new Rectangle(LogoPosX + 21, 5, 2, 1), ConsoleColor.Green);
Renderer.DrawRectangle(new Rectangle(LogoPosX + 23, 4, 2, 1), ConsoleColor.Green);
Renderer.DrawRectangle(new Rectangle(LogoPosX + 21, 8, 6, 1), ConsoleColor.Green);
Renderer.DrawRectangle(new Rectangle(LogoPosX + 25, 5, 2, 1), ConsoleColor.Green);
Renderer.DrawRectangle(new Rectangle(LogoPosX + 27, 6, 1, 6), ConsoleColor.Green);
//K
Renderer.DrawRectangle(new Rectangle(LogoPosX + 30, 4, 1, 8), ConsoleColor.Green);
Renderer.DrawRectangle(new Rectangle(LogoPosX + 31, 7, 1, 2), ConsoleColor.Green);
Renderer.DrawRectangle(new Rectangle(LogoPosX + 32, 6, 2, 1), ConsoleColor.Green);
Renderer.DrawRectangle(new Rectangle(LogoPosX + 34, 5, 2, 1), ConsoleColor.Green);
Renderer.DrawRectangle(new Rectangle(LogoPosX + 36, 4, 2, 1), ConsoleColor.Green);
Renderer.DrawRectangle(new Rectangle(LogoPosX + 32, 9, 2, 1), ConsoleColor.Green);
Renderer.DrawRectangle(new Rectangle(LogoPosX + 34, 10, 2, 1), ConsoleColor.Green);
Renderer.DrawRectangle(new Rectangle(LogoPosX + 36, 11, 2, 1), ConsoleColor.Green);
//E
Renderer.DrawRectangle(new Rectangle(LogoPosX + 40, 4, 1, 8), ConsoleColor.Green);
Renderer.DrawRectangle(new Rectangle(LogoPosX + 41, 4, 7, 1), ConsoleColor.Green);
Renderer.DrawRectangle(new Rectangle(LogoPosX + 41, 7, 6, 1), ConsoleColor.Green);
Renderer.DrawRectangle(new Rectangle(LogoPosX + 41, 11, 7, 1), ConsoleColor.Green);
#region Menu
if (selectedItem == 0)
{
Renderer.DrawRectangle(new Rectangle((Renderer.WindowSize.X - 35) / 2, 14, 35, 3), ConsoleColor.Green);
Renderer.DrawString("New One Player Game", new Vector2((Renderer.WindowSize.X - "New One Player Game".Length) / 2, 15), ConsoleColor.Black);
}
else
{
Renderer.DrawRectangle(new Rectangle((Renderer.WindowSize.X - 35) / 2, 14, 35, 3), ConsoleColor.Blue);
Renderer.DrawString("New One Player Game", new Vector2((Renderer.WindowSize.X - "New One Player Game".Length) / 2, 15), ConsoleColor.White);
}
if (selectedItem == 1)
{
Renderer.DrawRectangle(new Rectangle((Renderer.WindowSize.X - 35) / 2, 18, 35, 3), ConsoleColor.Green);
Renderer.DrawString("New Two Player Game", new Vector2((Renderer.WindowSize.X - "New Two Player Game".Length) / 2, 19), ConsoleColor.Black);
}
else
{
Renderer.DrawRectangle(new Rectangle((Renderer.WindowSize.X - 35) / 2, 18, 35, 3), ConsoleColor.Blue);
Renderer.DrawString("New Two Player Game", new Vector2((Renderer.WindowSize.X - "New Two Player Game".Length) / 2, 19), ConsoleColor.White);
}
if (selectedItem == 2)
{
Renderer.DrawRectangle(new Rectangle((Renderer.WindowSize.X - 35) / 2, 22, 35, 3), ConsoleColor.Green);
Renderer.DrawString("Load Game", new Vector2((Renderer.WindowSize.X - "Load Game".Length) / 2, 23), ConsoleColor.Black);
}
else
{
Renderer.DrawRectangle(new Rectangle((Renderer.WindowSize.X - 35) / 2, 22, 35, 3), ConsoleColor.Blue);
Renderer.DrawString("Load Game", new Vector2((Renderer.WindowSize.X - "Load Game".Length) / 2, 23), ConsoleColor.White);
}
if (selectedItem == 3)
{
Renderer.DrawRectangle(new Rectangle((Renderer.WindowSize.X - 35) / 2, 26, 35, 3), ConsoleColor.Green);
Renderer.DrawString("Exit", new Vector2((Renderer.WindowSize.X - "Exit".Length) / 2, 27), ConsoleColor.Black);
}
else
{
Renderer.DrawRectangle(new Rectangle((Renderer.WindowSize.X - 35) / 2, 26, 35, 3), ConsoleColor.Blue);
Renderer.DrawString("Exit", new Vector2((Renderer.WindowSize.X - "Exit".Length) / 2, 27), ConsoleColor.White);
}
#endregion
}
}
}

Pridajte Komentár

Vaša e-mailová adresa nebude zverejnená.

Scroll to Top