Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

visual changes and starting on connecting. #46

Merged
merged 2 commits into from
Apr 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/Client/Menu/ChooseNameView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,14 @@ public override void render(GameTime gameTime)
m_spriteBatch.Begin();

// Calculate the center position for "Enter Your Name" text
string enterNameText = $"Enter Your Name: {playerName}";
string enterNameText = $"Enter Your Name: [ Using Keyboard ] \n {playerName}";
Vector2 textSize = font.MeasureString(enterNameText);
Vector2 textPosition = new Vector2(
(m_graphics.PreferredBackBufferWidth - textSize.X) / 2,
(m_graphics.PreferredBackBufferHeight - textSize.Y) / 2);

// Draw "Enter Your Name" text
m_spriteBatch.DrawString(font, enterNameText, textPosition, Color.White);
m_spriteBatch.DrawString(font, enterNameText, textPosition, Color.PaleGoldenrod);

// Draw "Press Enter to proceed" below the name text if a name has been entered
if (playerName.Length > 0)
Expand All @@ -93,7 +93,7 @@ public override void render(GameTime gameTime)
(m_graphics.PreferredBackBufferWidth - proceedTextSize.X) / 2,
textPosition.Y + textSize.Y + 20); // 20 pixels below the name text

m_spriteBatch.DrawString(font, proceedText, proceedTextPosition, Color.White);
m_spriteBatch.DrawString(font, proceedText, proceedTextPosition, Color.PaleGoldenrod);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's use the Colors.DisplayColor here instead of saying Color.PaleGoldenRod. I believe it is in the Styles.cs file.

}

m_spriteBatch.End();
Expand Down
12 changes: 12 additions & 0 deletions src/Client/Menu/ConnectingView.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Client.Menu
{
internal class ConnectingView
{
}
}
24 changes: 18 additions & 6 deletions src/Client/Menu/HowToPlay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ namespace Client.Menu
public class HowToPlayView : GameStateView
{
private SpriteFont font;
private string howToPlayMessage = "The snake will change direction based on keypress";
private string howToPlayMessage =
"Control a snake to eat food and grow. Use arrow keys for movement. \n" +
"(Custom controls in Main Menu) \n" +
"Avoid wall and other players!. How long can you grow? Try to beat the high score!";
private string titleMessage = "HOW TO PLAY";
private string continueMessage = "Press Enter to continue";
private KeyboardState oldState;
Expand Down Expand Up @@ -56,24 +59,33 @@ public override void render(GameTime gameTime)
{
m_spriteBatch.Begin();

// Define text scale
Vector2 textScale = new Vector2(0.5f, 0.5f);

// Title
Vector2 titlePosition = new Vector2(m_graphics.PreferredBackBufferWidth / 2, m_graphics.PreferredBackBufferHeight / 4);
Vector2 titleOrigin = font.MeasureString(titleMessage) / 2;
m_spriteBatch.DrawString(font, titleMessage, titlePosition - titleOrigin, Color.White);
m_spriteBatch.DrawString(font, titleMessage, titlePosition - (titleOrigin * textScale), Color.PaleGoldenrod, 0f, Vector2.Zero, textScale, SpriteEffects.None, 0f);

// How to Play Instructions
Vector2 instructionsPosition = new Vector2(m_graphics.PreferredBackBufferWidth / 2, m_graphics.PreferredBackBufferHeight / 2);
Vector2 instructionsOrigin = font.MeasureString(howToPlayMessage) / 2;
m_spriteBatch.DrawString(font, howToPlayMessage, instructionsPosition - instructionsOrigin, Color.White);
Vector2 instructionsPosition = new Vector2(m_graphics.PreferredBackBufferWidth / 2, m_graphics.PreferredBackBufferHeight / 2.5f);
string[] lines = howToPlayMessage.Split('\n');
foreach (string line in lines)
{
Vector2 lineSize = font.MeasureString(line) * textScale;
m_spriteBatch.DrawString(font, line, instructionsPosition - new Vector2(lineSize.X / 2, 0), Color.PaleGoldenrod, 0f, Vector2.Zero, textScale, SpriteEffects.None, 0f);
instructionsPosition.Y += lineSize.Y + 5; // Adjust spacing between lines if necessary, taking scale into account
}

// Continue Prompt
Vector2 continuePosition = new Vector2(m_graphics.PreferredBackBufferWidth / 2, (m_graphics.PreferredBackBufferHeight / 4) * 3);
Vector2 continueOrigin = font.MeasureString(continueMessage) / 2;
m_spriteBatch.DrawString(font, continueMessage, continuePosition - continueOrigin, Color.White);
m_spriteBatch.DrawString(font, continueMessage, continuePosition - (continueOrigin * textScale), Color.PaleGoldenrod, 0f, Vector2.Zero, textScale, SpriteEffects.None, 0f);

m_spriteBatch.End();
}


public override void RegisterCommands()
{
// If you have commands to register, such as an Exit command, register them here
Expand Down
1 change: 1 addition & 0 deletions src/Client/Menu/MenuStateEnum.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ public enum MenuStateEnum
GamePlay,
ChooseName,
HowToPlay,
Connecting,
HighScores,
Controls,
Help,
Expand Down
Loading