Hardcode! Gamepad support.

This commit is contained in:
Mootfrost777 2022-07-03 11:52:35 +03:00
parent 391e5e25ff
commit d1db6d431e
54 changed files with 388 additions and 83 deletions

Binary file not shown.

View file

@ -8,6 +8,7 @@ using Microsoft.Xna.Framework.Input;
using System.IO;
using System.Linq;
using System.Diagnostics;
using System.Threading;
namespace Pacman.Classes
{
@ -227,11 +228,29 @@ namespace Pacman.Classes
// Pacman died
if (Game1.pacman.ExtraLives > 0)
{
Thread vibrateThread = new Thread(time =>
{
int vibrationTime = (int)time;
GamePad.SetVibration(0, 1, 1);
Thread.Sleep(vibrationTime);
GamePad.SetVibration(0, 0, 0);
});
vibrateThread.Start(400);
Game1.deathSong.Play();
Game1.RestartGame(false);
}
else
{
Thread vibrateThread = new Thread(time =>
{
int vibrationTime = (int)time;
GamePad.SetVibration(0, 1, 1);
Thread.Sleep(vibrationTime);
GamePad.SetVibration(0, 0, 0);
});
vibrateThread.Start(1000);
Game1.UpdateHighScore(Game1.pacman.highScore);
Game1.gameState = GameState.GameOver;
Game1.deathSong.Play();
@ -239,6 +258,15 @@ namespace Pacman.Classes
}
else if (GhostRectangle.Intersects(Game1.pacman.PacmanRectangle) && IsAfraidEffectOn && IsAlive)
{
Thread vibrateThread = new Thread(time =>
{
int vibrationTime = (int)time;
GamePad.SetVibration(0, 1, 1);
Thread.Sleep(vibrationTime);
GamePad.SetVibration(0, 0, 0);
});
vibrateThread.Start(200);
Speed *= 4;
Debug.WriteLine(200 * Game1.pacman.ghostsEaten);
Game1.pacman.highScore += 200 * Game1.pacman.ghostsEaten;

View file

@ -55,14 +55,38 @@ namespace Pacman
public void Update()
{
GamePadState gamePadState = GamePad.GetState(0);
KeyboardState state = Keyboard.GetState();
if ((PressedKey == Keys.None || Direction == null) && state.GetPressedKeyCount() != 0)
bool stickUp = false;
bool stickDown = false;
bool stickLeft = false;
bool stickRight = false;
if (Math.Abs(gamePadState.ThumbSticks.Left.Y) > Math.Abs(gamePadState.ThumbSticks.Left.X) &&
Math.Abs(gamePadState.ThumbSticks.Left.Y) > 0.25f)
{
if (gamePadState.ThumbSticks.Left.Y > 0) stickUp = true;
else stickDown = true;
}
else if (Math.Abs(gamePadState.ThumbSticks.Left.X) > Math.Abs(gamePadState.ThumbSticks.Left.Y) &&
Math.Abs(gamePadState.ThumbSticks.Left.X) > 0.25f)
{
if (gamePadState.ThumbSticks.Left.X > 0) stickRight = true;
else stickLeft = true;
}
if ((PressedKey == Keys.None || Direction == null) && state.GetPressedKeyCount() != 0)
{
PressedKey = state.GetPressedKeys()[0];
}
if ((Position.Y - 12) % 24 == 0 && (Position.X - 12) % 24 == 0)
{
if (PressedKey == Keys.W && !Obstackles.Contains(file[(int)(Position.Y / 24 - 1)][(int)Position.X / 24]))
if ((PressedKey == Keys.W ||
stickUp ||
gamePadState.DPad.Up == ButtonState.Pressed) &&
!Obstackles.Contains(file[(int)(Position.Y / 24 - 1)][(int)Position.X / 24]))
{
Rotation = 0;
PressedKey = Keys.None;
@ -71,7 +95,10 @@ namespace Pacman
Direction = "Up";
}
}
else if (PressedKey == Keys.D && !Obstackles.Contains(file[(int)Position.Y / 24][(int)(Position.X / 24 + 1)]))
else if ((PressedKey == Keys.D ||
stickRight ||
gamePadState.DPad.Right == ButtonState.Pressed) &&
!Obstackles.Contains(file[(int)Position.Y / 24][(int)(Position.X / 24 + 1)]))
{
Rotation = (float)(0.5 * Math.PI);
PressedKey = Keys.None;
@ -80,7 +107,10 @@ namespace Pacman
Direction = "Right";
}
}
else if (PressedKey == Keys.S && !Obstackles.Contains(file[(int)(Position.Y / 24 + 1)][(int)Position.X / 24]))
else if ((PressedKey == Keys.S ||
stickDown ||
gamePadState.DPad.Down == ButtonState.Pressed) &&
!Obstackles.Contains(file[(int)(Position.Y / 24 + 1)][(int)Position.X / 24]))
{
Rotation = (float)(Math.PI);
PressedKey = Keys.None;
@ -89,7 +119,10 @@ namespace Pacman
Direction = "Down";
}
}
else if (PressedKey == Keys.A && !Obstackles.Contains(file[(int)Position.Y / 24][(int)(Position.X / 24 - 1)]))
else if ((PressedKey == Keys.A ||
stickLeft ||
gamePadState.DPad.Left == ButtonState.Pressed) &&
!Obstackles.Contains(file[(int)Position.Y / 24][(int)(Position.X / 24 - 1)]))
{
Rotation = (float)(1.5 * Math.PI);
PressedKey = Keys.None;

View file

@ -14,26 +14,53 @@ namespace Pacman.Classes.UI
private KeyboardState keyboardState;
private KeyboardState prevKeyboardState;
private int selectedItem = 0;
private Label label = new Label();
private Label menuLabel = new Label();
private GamePadState gamePadState;
private GamePadState prevGamePadState;
private string[] menuElements
= { "play again", "main menu", "quit" };
public void LoadContent(ContentManager Content, string fontName)
{
label.LoadContent(Content, fontName);
menuLabel.LoadContent(Content, "gameFont");
}
public void Update()
{
keyboardState = Keyboard.GetState();
gamePadState = GamePad.GetState(0);
// Move in the menu
if (keyboardState.IsKeyDown(Keys.W) && selectedItem > 0 && keyboardState != prevKeyboardState)
bool stickUp = false;
bool stickDown = false;
if (Math.Abs(gamePadState.ThumbSticks.Left.Y) > Math.Abs(gamePadState.ThumbSticks.Left.X) &&
Math.Abs(gamePadState.ThumbSticks.Left.Y) > 0.5f)
{
if (gamePadState.ThumbSticks.Left.Y > 0) stickUp = true;
else stickDown = true;
}
if (((keyboardState.IsKeyDown(Keys.W) && keyboardState != prevKeyboardState) ||
(stickUp && prevGamePadState.ThumbSticks.Left.Y <= 0.5f) ||
((gamePadState.DPad.Up == ButtonState.Pressed) && (prevGamePadState.DPad.Up == ButtonState.Released)))
&& selectedItem > 0)
{
selectedItem--;
}
if (keyboardState.IsKeyDown(Keys.S) && selectedItem < menuElements.Length - 1 && keyboardState != prevKeyboardState)
if (((keyboardState.IsKeyDown(Keys.S) && keyboardState != prevKeyboardState) ||
(stickDown && prevGamePadState.ThumbSticks.Left.Y >= -0.5f) ||
((gamePadState.DPad.Down == ButtonState.Pressed) && (prevGamePadState.DPad.Down == ButtonState.Released)))
&& selectedItem < menuElements.Length - 1)
{
selectedItem++;
}
// Select menu item
if (keyboardState.IsKeyDown(Keys.Enter) && keyboardState != prevKeyboardState)
if ((keyboardState.IsKeyDown(Keys.Enter) || gamePadState.Buttons.A == ButtonState.Pressed))
{
if (selectedItem == 0)
{
@ -52,16 +79,17 @@ namespace Pacman.Classes.UI
}
}
prevKeyboardState = keyboardState;
prevGamePadState = gamePadState;
}
public void Draw(SpriteBatch spriteBatch)
{
if (counter <= 30)
{
Label label = new Label("GAME OVER", new Vector2(0, 150), Color.Red);
label.HorizontalCenterGameOver((int)Game1.screenSize.X);
label.SetData("GAME OVER", new Vector2(0, 150), Color.Red);
label.HorizontalCenter((int)Game1.screenSize.X);
label.DrawGameOver(spriteBatch);
label.Draw(spriteBatch);
}
else if (counter >= 60)
{
@ -76,12 +104,12 @@ namespace Pacman.Classes.UI
{
element = "> " + element + " <";
}
Label label = new Label(element,
new Vector2(0, 500 + i * 35),
menuLabel.SetData(element,
new Vector2(0, 600 + i * 35),
Color.White);
label.HorizontalCenter((int)Game1.screenSize.X);
menuLabel.HorizontalCenter((int)Game1.screenSize.X);
label.Draw(spriteBatch);
menuLabel.Draw(spriteBatch);
}
}
}

View file

@ -1,27 +1,35 @@
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
namespace Pacman.Classes.UI
{
public class HUD
{
private Vector2 position;
private Label label = new Label();
public HUD(Vector2 position)
{
this.position = position;
}
public void LoadContent(ContentManager Content, string fontName)
{
label.LoadContent(Content, fontName);
}
public void Draw(SpriteBatch spriteBatch, int score, int lives)
{
Label label = new Label($"Score:{score}", position, Color.DarkRed);
label.SetData($"Score:{score}", position, Color.DarkRed);
label.Draw(spriteBatch);
label = new Label($"Hi-score:{Game1.pacman.highScore}", position, Color.DarkRed);
label.SetData($"Hi-score:{Game1.pacman.highScore}", position, Color.DarkRed);
label.HorizontalRight((int)Game1.screenSize.X);
label.Draw(spriteBatch);
label = new Label($"Level:{Game1.pacman.Level + 1}", position + new Vector2(0, 40), Color.White);
label.SetData($"Level:{Game1.pacman.Level + 1}", position + new Vector2(0, 40), Color.White);
label.HorizontalRight((int)Game1.screenSize.X);
label.Draw(spriteBatch);

View file

@ -0,0 +1,52 @@
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using System;
using System.Collections.Generic;
using System.Linq;
namespace Pacman.Classes.UI
{
public class HowToPlay
{
private Label label = new Label();
private static string rules =
@"
Your task is to eat all -
food(dots) and not to be eaten by ghosts.
Use this keys to navigate through the map:
W - Up
A - Left
S - Down
D - Right
If you ate big dot(energizer), ghosts will run -
away rom you and you can eat them.
Press Escape to retutn to main menu.
";
public void LoadContent(ContentManager Content, string fontName)
{
label.LoadContent(Content, fontName);
}
public void Draw(SpriteBatch spriteBatch)
{
label.SetData(rules,
new Vector2(0, 50),
Color.White);
label.Draw(spriteBatch);
}
public void Update()
{
KeyboardState keyboardState = Keyboard.GetState();
if (keyboardState.IsKeyDown(Keys.Escape))
{
Game1.gameState = GameState.Menu;
}
}
}
}

View file

@ -7,15 +7,11 @@ namespace Pacman.Classes.UI
{
class Label
{
public static SpriteFont spriteFont;
public static SpriteFont gameOverFont;
public SpriteFont spriteFont;
private Color color_default;
public Vector2 Position { get; set; }
public string Text { get; set; }
public Color Color { get; set; }
public static string fontName = "gameFont";
public string FontName { set { fontName = value; } }
public Label()
{
@ -39,11 +35,6 @@ namespace Pacman.Classes.UI
Position = new Vector2(screenWidth / 2 - spriteFont.MeasureString(Text).X / 2, Position.Y);
}
public void HorizontalCenterGameOver(int screenWidth)
{
Position = new Vector2(screenWidth / 2 - gameOverFont.MeasureString(Text).X / 2, Position.Y);
}
public void HorizontalRight(int screenWidth)
{
Position = new Vector2(screenWidth - spriteFont.MeasureString(Text).X, Position.Y);
@ -54,10 +45,9 @@ namespace Pacman.Classes.UI
Color = color_default;
}
public static void LoadContent(ContentManager Content)
public void LoadContent(ContentManager Content, string fontName)
{
spriteFont = Content.Load<SpriteFont>(fontName);
gameOverFont = Content.Load<SpriteFont>("gameOverFont");
}
public void Draw(SpriteBatch spriteBatch)
@ -65,9 +55,11 @@ namespace Pacman.Classes.UI
spriteBatch.DrawString(spriteFont, Text, Position, Color);
}
public void DrawGameOver(SpriteBatch spriteBatch)
public void SetData(string text, Vector2 position, Color color)
{
spriteBatch.DrawString(gameOverFont, Text, Position, Color);
Text = text;
Position = position;
Color = color;
}
}
}

View file

@ -16,6 +16,11 @@ namespace Pacman.Classes.UI
private KeyboardState keyboardState;
private KeyboardState prevKeyboardState;
private GamePadState gamePadState;
private GamePadState prevGamePadState;
private Label label = new Label();
private static List<Character> characters = new List<Character>()
{
new Character("- shadow \"blinky\"", new Point(0, 144), new Point(22, 22), Color.Red),
@ -29,27 +34,44 @@ namespace Pacman.Classes.UI
private int selectedItem = 0;
public void LoadContent(ContentManager content)
public void LoadContent(ContentManager content, string fontName)
{
logo = content.Load<Texture2D>("logo");
label.LoadContent(content, fontName);
}
public void Update()
{
keyboardState = Keyboard.GetState();
gamePadState = GamePad.GetState(0);
// Move in the menu
if (keyboardState.IsKeyDown(Keys.W) && selectedItem > 0 && keyboardState != prevKeyboardState)
bool stickUp = false;
bool stickDown = false;
if (Math.Abs(gamePadState.ThumbSticks.Left.Y) > Math.Abs(gamePadState.ThumbSticks.Left.X) &&
Math.Abs(gamePadState.ThumbSticks.Left.Y) > 0.5f)
{
if (gamePadState.ThumbSticks.Left.Y > 0) stickUp = true;
else stickDown = true;
}
if (((keyboardState.IsKeyDown(Keys.W) && keyboardState != prevKeyboardState) ||
(stickUp && prevGamePadState.ThumbSticks.Left.Y <= 0.5f) ||
((gamePadState.DPad.Up == ButtonState.Pressed) && (prevGamePadState.DPad.Up == ButtonState.Released)))
&& selectedItem > 0 )
{
selectedItem--;
}
if (keyboardState.IsKeyDown(Keys.S) && selectedItem < menuElements.Length - 1 && keyboardState != prevKeyboardState)
if (((keyboardState.IsKeyDown(Keys.S) && keyboardState != prevKeyboardState) ||
(stickDown && prevGamePadState.ThumbSticks.Left.Y >= -0.5f) ||
((gamePadState.DPad.Down == ButtonState.Pressed) && (prevGamePadState.DPad.Down == ButtonState.Released)))
&& selectedItem < menuElements.Length - 1)
{
selectedItem++;
}
// Select menu item
if (keyboardState.IsKeyDown(Keys.Enter) && keyboardState != prevKeyboardState)
if ((keyboardState.IsKeyDown(Keys.Enter) || gamePadState.Buttons.A == ButtonState.Pressed))
{
if (selectedItem == 0)
{
@ -61,7 +83,7 @@ namespace Pacman.Classes.UI
}
else if (selectedItem == 1)
{
// How to play
Game1.gameState = GameState.HowToPlay;
}
else if (selectedItem == 2)
{
@ -69,11 +91,12 @@ namespace Pacman.Classes.UI
}
}
prevKeyboardState = keyboardState;
prevGamePadState = gamePadState;
}
public void Draw(SpriteBatch spriteBatch)
{
Label label = new Label($"Hi-score:{Game1.pacman.highScore}",
label.SetData($"Hi-score:{Game1.pacman.highScore}",
new Vector2(50, 20),
Color.DarkRed);
@ -95,7 +118,7 @@ namespace Pacman.Classes.UI
sorceRect,
Color.White);
label = new Label(character.description,
label.SetData(character.description,
new Vector2(75 + character.size.X, 270 + i * character.size.Y * 1.3f),
character.color);
label.Draw(spriteBatch);
@ -108,8 +131,8 @@ namespace Pacman.Classes.UI
{
element = "> " + element + " <";
}
label = new Label(element,
new Vector2(0, 500 + i * 35),
label.SetData(element,
new Vector2(0, 600 + i * 35),
Color.White);
label.HorizontalCenter((int)Game1.screenSize.X);

View file

@ -13,11 +13,11 @@
#---------------------------------- Content ---------------------------------#
#begin chompSound.wav
/importer:WavImporter
#begin chompSound.mp3
/importer:Mp3Importer
/processor:SoundEffectProcessor
/processorParam:Quality=Best
/build:chompSound.wav
/build:chompSound.mp3
#begin deathSound.wav
/importer:WavImporter
@ -75,6 +75,13 @@
/processorParam:Quality=Best
/build:mainSong.wav
#begin rulesFont.spritefont
/importer:FontDescriptionImporter
/processor:FontDescriptionProcessor
/processorParam:PremultiplyAlpha=True
/processorParam:TextureFormat=Compressed
/build:rulesFont.spritefont
#begin sprites.png
/importer:TextureImporter
/processor:TextureProcessor

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -4,7 +4,7 @@
<Platform>Windows</Platform>
<Config />
<SourceFiles>
<File>C:/Users/Semejkin_AV/Documents/Github_repos/Pacman/Pacman/Content/chompSound.wav</File>
<File>C:/Users/Semejkin_AV/Documents/Github_repos/Pacman/Pacman/Content/chompSound.mp3</File>
<File>C:/Users/Semejkin_AV/Documents/Github_repos/Pacman/Pacman/Content/deathSound.wav</File>
<File>C:/Users/Semejkin_AV/Documents/Github_repos/Pacman/Pacman/Content/fruitEaten.mp3</File>
<File>C:/Users/Semejkin_AV/Documents/Github_repos/Pacman/Pacman/Content/gameFont.spritefont</File>
@ -13,6 +13,7 @@
<File>C:/Users/Semejkin_AV/Documents/Github_repos/Pacman/Pacman/Content/intermissionSound.wav</File>
<File>C:/Users/Semejkin_AV/Documents/Github_repos/Pacman/Pacman/Content/logo.png</File>
<File>C:/Users/Semejkin_AV/Documents/Github_repos/Pacman/Pacman/Content/mainSong.wav</File>
<File>C:/Users/Semejkin_AV/Documents/Github_repos/Pacman/Pacman/Content/rulesFont.spritefont</File>
<File>C:/Users/Semejkin_AV/Documents/Github_repos/Pacman/Pacman/Content/sprites.png</File>
</SourceFiles>
<DestFiles>
@ -26,5 +27,6 @@
<File xsi:nil="true" />
<File xsi:nil="true" />
<File xsi:nil="true" />
<File xsi:nil="true" />
</DestFiles>
</SourceFileCollection>

View file

@ -1,11 +1,12 @@
Source File,Dest File,Processor Type,Content Type,Source File Size,Dest File Size,Build Seconds
"C:/Users/Semejkin_AV/Documents/Github_repos/Pacman/Pacman/Content/chompSound.wav","C:/Users/Semejkin_AV/Documents/Github_repos/Pacman/Pacman/Content/bin/Windows/chompSound.xnb","SoundEffectProcessor","SoundEffectContent",21528,21457,0.9651652
"C:/Users/Semejkin_AV/Documents/Github_repos/Pacman/Pacman/Content/deathSound.wav","C:/Users/Semejkin_AV/Documents/Github_repos/Pacman/Pacman/Content/bin/Windows/deathSound.xnb","SoundEffectProcessor","SoundEffectContent",17008,17021,0.6668953
"C:/Users/Semejkin_AV/Documents/Github_repos/Pacman/Pacman/Content/fruitEaten.mp3","C:/Users/Semejkin_AV/Documents/Github_repos/Pacman/Pacman/Content/bin/Windows/fruitEaten.xnb","SoundEffectProcessor","SoundEffectContent",10057,13929,0.9344639
"C:/Users/Semejkin_AV/Documents/Github_repos/Pacman/Pacman/Content/gameFont.spritefont","C:/Users/Semejkin_AV/Documents/Github_repos/Pacman/Pacman/Content/bin/Windows/gameFont.xnb","FontDescriptionProcessor","SpriteFontContent",2011,70690,0.3369461
"C:/Users/Semejkin_AV/Documents/Github_repos/Pacman/Pacman/Content/gameOverFont.spritefont","C:/Users/Semejkin_AV/Documents/Github_repos/Pacman/Pacman/Content/bin/Windows/gameOverFont.xnb","FontDescriptionProcessor","SpriteFontContent",2008,267298,0.085875
"C:/Users/Semejkin_AV/Documents/Github_repos/Pacman/Pacman/Content/ghostDeathSound.mp3","C:/Users/Semejkin_AV/Documents/Github_repos/Pacman/Pacman/Content/bin/Windows/ghostDeathSound.xnb","SoundEffectProcessor","SoundEffectContent",11728,16233,0.8279983
"C:/Users/Semejkin_AV/Documents/Github_repos/Pacman/Pacman/Content/intermissionSound.wav","C:/Users/Semejkin_AV/Documents/Github_repos/Pacman/Pacman/Content/bin/Windows/intermissionSound.xnb","SongProcessor","SongContent",57600,135,0.7278905
"C:/Users/Semejkin_AV/Documents/Github_repos/Pacman/Pacman/Content/logo.png","C:/Users/Semejkin_AV/Documents/Github_repos/Pacman/Pacman/Content/bin/Windows/logo.xnb","TextureProcessor","Texture2DContent",161105,1776085,0.1889831
"C:/Users/Semejkin_AV/Documents/Github_repos/Pacman/Pacman/Content/mainSong.wav","C:/Users/Semejkin_AV/Documents/Github_repos/Pacman/Pacman/Content/bin/Windows/mainSong.xnb","SongProcessor","SongContent",46592,126,0.6260953
"C:/Users/Semejkin_AV/Documents/Github_repos/Pacman/Pacman/Content/sprites.png","C:/Users/Semejkin_AV/Documents/Github_repos/Pacman/Pacman/Content/bin/Windows/sprites.xnb","TextureProcessor","Texture2DContent",5012,368725,0.0677785
"C:/Users/Semejkin_AV/Documents/Github_repos/Pacman/Pacman/Content/chompSound.mp3","C:/Users/Semejkin_AV/Documents/Github_repos/Pacman/Pacman/Content/bin/Windows/chompSound.xnb","SoundEffectProcessor","SoundEffectContent",4892,24391,0.5305191
"C:/Users/Semejkin_AV/Documents/Github_repos/Pacman/Pacman/Content/deathSound.wav","C:/Users/Semejkin_AV/Documents/Github_repos/Pacman/Pacman/Content/bin/Windows/deathSound.xnb","SoundEffectProcessor","SoundEffectContent",17008,17021,0.305673
"C:/Users/Semejkin_AV/Documents/Github_repos/Pacman/Pacman/Content/fruitEaten.mp3","C:/Users/Semejkin_AV/Documents/Github_repos/Pacman/Pacman/Content/bin/Windows/fruitEaten.xnb","SoundEffectProcessor","SoundEffectContent",10057,13929,0.4888306
"C:/Users/Semejkin_AV/Documents/Github_repos/Pacman/Pacman/Content/gameFont.spritefont","C:/Users/Semejkin_AV/Documents/Github_repos/Pacman/Pacman/Content/bin/Windows/gameFont.xnb","FontDescriptionProcessor","SpriteFontContent",2011,70690,0.238199
"C:/Users/Semejkin_AV/Documents/Github_repos/Pacman/Pacman/Content/gameOverFont.spritefont","C:/Users/Semejkin_AV/Documents/Github_repos/Pacman/Pacman/Content/bin/Windows/gameOverFont.xnb","FontDescriptionProcessor","SpriteFontContent",2008,267298,0.3368205
"C:/Users/Semejkin_AV/Documents/Github_repos/Pacman/Pacman/Content/ghostDeathSound.mp3","C:/Users/Semejkin_AV/Documents/Github_repos/Pacman/Pacman/Content/bin/Windows/ghostDeathSound.xnb","SoundEffectProcessor","SoundEffectContent",11728,16233,0.6772644
"C:/Users/Semejkin_AV/Documents/Github_repos/Pacman/Pacman/Content/intermissionSound.wav","C:/Users/Semejkin_AV/Documents/Github_repos/Pacman/Pacman/Content/bin/Windows/intermissionSound.xnb","SongProcessor","SongContent",57600,135,0.3451544
"C:/Users/Semejkin_AV/Documents/Github_repos/Pacman/Pacman/Content/logo.png","C:/Users/Semejkin_AV/Documents/Github_repos/Pacman/Pacman/Content/bin/Windows/logo.xnb","TextureProcessor","Texture2DContent",161105,1776085,0.1126467
"C:/Users/Semejkin_AV/Documents/Github_repos/Pacman/Pacman/Content/mainSong.wav","C:/Users/Semejkin_AV/Documents/Github_repos/Pacman/Pacman/Content/bin/Windows/mainSong.xnb","SongProcessor","SongContent",46592,126,0.4629836
"C:/Users/Semejkin_AV/Documents/Github_repos/Pacman/Pacman/Content/rulesFont.spritefont","C:/Users/Semejkin_AV/Documents/Github_repos/Pacman/Pacman/Content/bin/Windows/rulesFont.xnb","FontDescriptionProcessor","SpriteFontContent",2011,21538,0.0359558
"C:/Users/Semejkin_AV/Documents/Github_repos/Pacman/Pacman/Content/sprites.png","C:/Users/Semejkin_AV/Documents/Github_repos/Pacman/Pacman/Content/bin/Windows/sprites.xnb","TextureProcessor","Texture2DContent",5012,368725,0.0271384

View file

@ -4,7 +4,7 @@
<Platform>Windows</Platform>
<Config />
<SourceFiles>
<File>C:/Users/Semejkin_AV/Documents/Github_repos/Pacman/Pacman/Content/chompSound.wav</File>
<File>C:/Users/Semejkin_AV/Documents/Github_repos/Pacman/Pacman/Content/chompSound.mp3</File>
<File>C:/Users/Semejkin_AV/Documents/Github_repos/Pacman/Pacman/Content/deathSound.wav</File>
<File>C:/Users/Semejkin_AV/Documents/Github_repos/Pacman/Pacman/Content/fruitEaten.mp3</File>
<File>C:/Users/Semejkin_AV/Documents/Github_repos/Pacman/Pacman/Content/gameFont.spritefont</File>
@ -13,6 +13,7 @@
<File>C:/Users/Semejkin_AV/Documents/Github_repos/Pacman/Pacman/Content/intermissionSound.wav</File>
<File>C:/Users/Semejkin_AV/Documents/Github_repos/Pacman/Pacman/Content/logo.png</File>
<File>C:/Users/Semejkin_AV/Documents/Github_repos/Pacman/Pacman/Content/mainSong.wav</File>
<File>C:/Users/Semejkin_AV/Documents/Github_repos/Pacman/Pacman/Content/rulesFont.spritefont</File>
<File>C:/Users/Semejkin_AV/Documents/Github_repos/Pacman/Pacman/Content/sprites.png</File>
</SourceFiles>
<DestFiles>
@ -26,5 +27,6 @@
<File xsi:nil="true" />
<File xsi:nil="true" />
<File xsi:nil="true" />
<File xsi:nil="true" />
</DestFiles>
</SourceFileCollection>

View file

@ -1,5 +1,5 @@
Source File,Dest File,Processor Type,Content Type,Source File Size,Dest File Size,Build Seconds
"C:/Users/Semejkin_AV/Documents/Github_repos/Pacman/Pacman/Content/chompSound.wav","C:/Users/Semejkin_AV/Documents/Github_repos/Pacman/Pacman/Content/bin/Windows/Content/chompSound.xnb","SoundEffectProcessor","SoundEffectContent",21528,21457,0.7019035
"C:/Users/Semejkin_AV/Documents/Github_repos/Pacman/Pacman/Content/chompSound.mp3","C:/Users/Semejkin_AV/Documents/Github_repos/Pacman/Pacman/Content/bin/Windows/Content/chompSound.xnb","SoundEffectProcessor","SoundEffectContent",4892,24391,0.4690988
"C:/Users/Semejkin_AV/Documents/Github_repos/Pacman/Pacman/Content/deathSound.wav","C:/Users/Semejkin_AV/Documents/Github_repos/Pacman/Pacman/Content/bin/Windows/Content/deathSound.xnb","SoundEffectProcessor","SoundEffectContent",17008,17021,0.6754085
"C:/Users/Semejkin_AV/Documents/Github_repos/Pacman/Pacman/Content/fruitEaten.mp3","C:/Users/Semejkin_AV/Documents/Github_repos/Pacman/Pacman/Content/bin/Windows/Content/fruitEaten.xnb","SoundEffectProcessor","SoundEffectContent",10057,13929,0.7637201
"C:/Users/Semejkin_AV/Documents/Github_repos/Pacman/Pacman/Content/gameFont.spritefont","C:/Users/Semejkin_AV/Documents/Github_repos/Pacman/Pacman/Content/bin/Windows/Content/gameFont.xnb","FontDescriptionProcessor","SpriteFontContent",2011,70690,0.3852959
@ -8,4 +8,5 @@ Source File,Dest File,Processor Type,Content Type,Source File Size,Dest File Siz
"C:/Users/Semejkin_AV/Documents/Github_repos/Pacman/Pacman/Content/intermissionSound.wav","C:/Users/Semejkin_AV/Documents/Github_repos/Pacman/Pacman/Content/bin/Windows/Content/intermissionSound.xnb","SongProcessor","SongContent",57600,135,0.7034911
"C:/Users/Semejkin_AV/Documents/Github_repos/Pacman/Pacman/Content/logo.png","C:/Users/Semejkin_AV/Documents/Github_repos/Pacman/Pacman/Content/bin/Windows/Content/logo.xnb","TextureProcessor","Texture2DContent",161105,1776085,0.6158541
"C:/Users/Semejkin_AV/Documents/Github_repos/Pacman/Pacman/Content/mainSong.wav","C:/Users/Semejkin_AV/Documents/Github_repos/Pacman/Pacman/Content/bin/Windows/Content/mainSong.xnb","SongProcessor","SongContent",46592,126,0.4894537
"C:/Users/Semejkin_AV/Documents/Github_repos/Pacman/Pacman/Content/rulesFont.spritefont","C:/Users/Semejkin_AV/Documents/Github_repos/Pacman/Pacman/Content/bin/Windows/Content/rulesFont.xnb","FontDescriptionProcessor","SpriteFontContent",2011,21538,0.413126
"C:/Users/Semejkin_AV/Documents/Github_repos/Pacman/Pacman/Content/sprites.png","C:/Users/Semejkin_AV/Documents/Github_repos/Pacman/Pacman/Content/bin/Windows/Content/sprites.xnb","TextureProcessor","Texture2DContent",5012,368725,0.2415895

View file

@ -1,10 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<PipelineBuildEvent xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<SourceFile>C:/Users/Semejkin_AV/Documents/Github_repos/Pacman/Pacman/Content/chompSound.wav</SourceFile>
<SourceTime>2022-07-02T23:38:17.5676669+03:00</SourceTime>
<SourceFile>C:/Users/Semejkin_AV/Documents/Github_repos/Pacman/Pacman/Content/chompSound.mp3</SourceFile>
<SourceTime>2022-07-03T11:26:43.2803394+03:00</SourceTime>
<DestFile>C:/Users/Semejkin_AV/Documents/Github_repos/Pacman/Pacman/Content/bin/Windows/Content/chompSound.xnb</DestFile>
<DestTime>2022-07-02T23:38:35.6800123+03:00</DestTime>
<Importer>WavImporter</Importer>
<DestTime>2022-07-03T11:26:54.4822089+03:00</DestTime>
<Importer>Mp3Importer</Importer>
<ImporterTime>2020-08-10T16:17:54+03:00</ImporterTime>
<Processor>SoundEffectProcessor</Processor>
<ProcessorTime>2020-08-10T16:17:54+03:00</ProcessorTime>

View file

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<PipelineBuildEvent xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<SourceFile>C:/Users/Semejkin_AV/Documents/Github_repos/Pacman/Pacman/Content/rulesFont.spritefont</SourceFile>
<SourceTime>2022-07-03T00:43:06.5809617+03:00</SourceTime>
<DestFile>C:/Users/Semejkin_AV/Documents/Github_repos/Pacman/Pacman/Content/bin/Windows/Content/rulesFont.xnb</DestFile>
<DestTime>2022-07-03T00:43:51.2755208+03:00</DestTime>
<Importer>FontDescriptionImporter</Importer>
<ImporterTime>2020-08-10T16:17:54+03:00</ImporterTime>
<Processor>FontDescriptionProcessor</Processor>
<ProcessorTime>2020-08-10T16:17:54+03:00</ProcessorTime>
<Parameters>
<Key>PremultiplyAlpha</Key>
<Value>True</Value>
</Parameters>
<Parameters>
<Key>TextureFormat</Key>
<Value>Compressed</Value>
</Parameters>
<Dependencies />
<BuildAsset />
<BuildOutput />
</PipelineBuildEvent>

View file

@ -1,10 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<PipelineBuildEvent xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<SourceFile>C:/Users/Semejkin_AV/Documents/Github_repos/Pacman/Pacman/Content/chompSound.wav</SourceFile>
<SourceTime>2022-07-02T23:38:17.5676669+03:00</SourceTime>
<SourceFile>C:/Users/Semejkin_AV/Documents/Github_repos/Pacman/Pacman/Content/chompSound.mp3</SourceFile>
<SourceTime>2022-07-03T11:26:43.2803394+03:00</SourceTime>
<DestFile>C:/Users/Semejkin_AV/Documents/Github_repos/Pacman/Pacman/Content/bin/Windows/chompSound.xnb</DestFile>
<DestTime>2022-07-02T23:38:41.2925098+03:00</DestTime>
<Importer>WavImporter</Importer>
<DestTime>2022-07-03T11:26:56.9111082+03:00</DestTime>
<Importer>Mp3Importer</Importer>
<ImporterTime>2020-08-10T16:17:54+03:00</ImporterTime>
<Processor>SoundEffectProcessor</Processor>
<ProcessorTime>2020-08-10T16:17:54+03:00</ProcessorTime>

View file

@ -3,7 +3,7 @@
<SourceFile>C:/Users/Semejkin_AV/Documents/Github_repos/Pacman/Pacman/Content/deathSound.wav</SourceFile>
<SourceTime>2004-04-03T11:29:18+04:00</SourceTime>
<DestFile>C:/Users/Semejkin_AV/Documents/Github_repos/Pacman/Pacman/Content/bin/Windows/deathSound.xnb</DestFile>
<DestTime>2022-07-02T23:38:41.9761102+03:00</DestTime>
<DestTime>2022-07-03T11:26:57.222108+03:00</DestTime>
<Importer>WavImporter</Importer>
<ImporterTime>2020-08-10T16:17:54+03:00</ImporterTime>
<Processor>SoundEffectProcessor</Processor>

View file

@ -3,7 +3,7 @@
<SourceFile>C:/Users/Semejkin_AV/Documents/Github_repos/Pacman/Pacman/Content/fruitEaten.mp3</SourceFile>
<SourceTime>2022-07-02T16:22:50.1623369+03:00</SourceTime>
<DestFile>C:/Users/Semejkin_AV/Documents/Github_repos/Pacman/Pacman/Content/bin/Windows/fruitEaten.xnb</DestFile>
<DestTime>2022-07-02T23:38:42.903116+03:00</DestTime>
<DestTime>2022-07-03T11:26:57.7131038+03:00</DestTime>
<Importer>Mp3Importer</Importer>
<ImporterTime>2020-08-10T16:17:54+03:00</ImporterTime>
<Processor>SoundEffectProcessor</Processor>

View file

@ -3,7 +3,7 @@
<SourceFile>C:/Users/Semejkin_AV/Documents/Github_repos/Pacman/Pacman/Content/gameFont.spritefont</SourceFile>
<SourceTime>2022-07-01T14:42:48.0529101+03:00</SourceTime>
<DestFile>C:/Users/Semejkin_AV/Documents/Github_repos/Pacman/Pacman/Content/bin/Windows/gameFont.xnb</DestFile>
<DestTime>2022-07-02T23:38:43.2601128+03:00</DestTime>
<DestTime>2022-07-03T11:26:57.9531071+03:00</DestTime>
<Importer>FontDescriptionImporter</Importer>
<ImporterTime>2020-08-10T16:17:54+03:00</ImporterTime>
<Processor>FontDescriptionProcessor</Processor>

View file

@ -3,7 +3,7 @@
<SourceFile>C:/Users/Semejkin_AV/Documents/Github_repos/Pacman/Pacman/Content/gameOverFont.spritefont</SourceFile>
<SourceTime>2022-07-02T14:55:47.6326791+03:00</SourceTime>
<DestFile>C:/Users/Semejkin_AV/Documents/Github_repos/Pacman/Pacman/Content/bin/Windows/gameOverFont.xnb</DestFile>
<DestTime>2022-07-02T23:38:43.3461128+03:00</DestTime>
<DestTime>2022-07-03T11:26:58.2921097+03:00</DestTime>
<Importer>FontDescriptionImporter</Importer>
<ImporterTime>2020-08-10T16:17:54+03:00</ImporterTime>
<Processor>FontDescriptionProcessor</Processor>

View file

@ -3,7 +3,7 @@
<SourceFile>C:/Users/Semejkin_AV/Documents/Github_repos/Pacman/Pacman/Content/ghostDeathSound.mp3</SourceFile>
<SourceTime>2022-07-02T16:15:02.5759174+03:00</SourceTime>
<DestFile>C:/Users/Semejkin_AV/Documents/Github_repos/Pacman/Pacman/Content/bin/Windows/ghostDeathSound.xnb</DestFile>
<DestTime>2022-07-02T23:38:44.1746886+03:00</DestTime>
<DestTime>2022-07-03T11:26:58.9701324+03:00</DestTime>
<Importer>Mp3Importer</Importer>
<ImporterTime>2020-08-10T16:17:54+03:00</ImporterTime>
<Processor>SoundEffectProcessor</Processor>

View file

@ -3,7 +3,7 @@
<SourceFile>C:/Users/Semejkin_AV/Documents/Github_repos/Pacman/Pacman/Content/intermissionSound.wav</SourceFile>
<SourceTime>2004-04-03T11:27:18+04:00</SourceTime>
<DestFile>C:/Users/Semejkin_AV/Documents/Github_repos/Pacman/Pacman/Content/bin/Windows/intermissionSound.xnb</DestFile>
<DestTime>2022-07-02T23:38:44.8981732+03:00</DestTime>
<DestTime>2022-07-03T11:26:59.3191079+03:00</DestTime>
<Importer>WavImporter</Importer>
<ImporterTime>2020-08-10T16:17:54+03:00</ImporterTime>
<Processor>SongProcessor</Processor>

View file

@ -3,7 +3,7 @@
<SourceFile>C:/Users/Semejkin_AV/Documents/Github_repos/Pacman/Pacman/Content/logo.png</SourceFile>
<SourceTime>2022-07-01T17:57:24.2958134+03:00</SourceTime>
<DestFile>C:/Users/Semejkin_AV/Documents/Github_repos/Pacman/Pacman/Content/bin/Windows/logo.xnb</DestFile>
<DestTime>2022-07-02T23:38:45.0901659+03:00</DestTime>
<DestTime>2022-07-03T11:26:59.4321046+03:00</DestTime>
<Importer>TextureImporter</Importer>
<ImporterTime>2020-08-10T16:17:54+03:00</ImporterTime>
<Processor>TextureProcessor</Processor>

View file

@ -3,7 +3,7 @@
<SourceFile>C:/Users/Semejkin_AV/Documents/Github_repos/Pacman/Pacman/Content/mainSong.wav</SourceFile>
<SourceTime>2004-04-03T11:26:48+04:00</SourceTime>
<DestFile>C:/Users/Semejkin_AV/Documents/Github_repos/Pacman/Pacman/Content/bin/Windows/mainSong.xnb</DestFile>
<DestTime>2022-07-02T23:38:45.7231693+03:00</DestTime>
<DestTime>2022-07-03T11:26:59.8981034+03:00</DestTime>
<Importer>WavImporter</Importer>
<ImporterTime>2020-08-10T16:17:54+03:00</ImporterTime>
<Processor>SongProcessor</Processor>

View file

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<PipelineBuildEvent xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<SourceFile>C:/Users/Semejkin_AV/Documents/Github_repos/Pacman/Pacman/Content/rulesFont.spritefont</SourceFile>
<SourceTime>2022-07-03T00:43:06.5809617+03:00</SourceTime>
<DestFile>C:/Users/Semejkin_AV/Documents/Github_repos/Pacman/Pacman/Content/bin/Windows/rulesFont.xnb</DestFile>
<DestTime>2022-07-03T11:26:59.935108+03:00</DestTime>
<Importer>FontDescriptionImporter</Importer>
<ImporterTime>2020-08-10T16:17:54+03:00</ImporterTime>
<Processor>FontDescriptionProcessor</Processor>
<ProcessorTime>2020-08-10T16:17:54+03:00</ProcessorTime>
<Parameters>
<Key>PremultiplyAlpha</Key>
<Value>True</Value>
</Parameters>
<Parameters>
<Key>TextureFormat</Key>
<Value>Compressed</Value>
</Parameters>
<Dependencies />
<BuildAsset />
<BuildOutput />
</PipelineBuildEvent>

View file

@ -3,7 +3,7 @@
<SourceFile>C:/Users/Semejkin_AV/Documents/Github_repos/Pacman/Pacman/Content/sprites.png</SourceFile>
<SourceTime>2022-06-29T15:43:37.3648634+03:00</SourceTime>
<DestFile>C:/Users/Semejkin_AV/Documents/Github_repos/Pacman/Pacman/Content/bin/Windows/sprites.xnb</DestFile>
<DestTime>2022-07-02T23:38:45.7951722+03:00</DestTime>
<DestTime>2022-07-03T11:26:59.9631041+03:00</DestTime>
<Importer>TextureImporter</Importer>
<ImporterTime>2020-08-10T16:17:54+03:00</ImporterTime>
<Processor>TextureProcessor</Processor>

View file

@ -0,0 +1,60 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
This file contains an xml description of a font, and will be read by the XNA
Framework Content Pipeline. Follow the comments to customize the appearance
of the font in your game, and to change the characters which are available to draw
with.
-->
<XnaContent xmlns:Graphics="Microsoft.Xna.Framework.Content.Pipeline.Graphics">
<Asset Type="Graphics:FontDescription">
<!--
Modify this string to change the font that will be imported.
-->
<FontName>Emulogic</FontName>
<!--
Size is a float value, measured in points. Modify this value to change
the size of the font.
-->
<Size>10</Size>
<!--
Spacing is a float value, measured in pixels. Modify this value to change
the amount of spacing in between characters.
-->
<Spacing>0</Spacing>
<!--
UseKerning controls the layout of the font. If this value is true, kerning information
will be used when placing characters.
-->
<UseKerning>true</UseKerning>
<!--
Style controls the style of the font. Valid entries are "Regular", "Bold", "Italic",
and "Bold, Italic", and are case sensitive.
-->
<Style>Regular</Style>
<!--
If you uncomment this line, the default character will be substituted if you draw
or measure text that contains characters which were not included in the font.
-->
<!-- <DefaultCharacter>*</DefaultCharacter> -->
<!--
CharacterRegions control what letters are available in the font. Every
character from Start to End will be built and made available for drawing. The
default range is from 32, (ASCII space), to 126, ('~'), covering the basic Latin
character set. The characters are ordered according to the Unicode standard.
See the documentation for more information.
-->
<CharacterRegions>
<CharacterRegion>
<Start>&#32;</Start>
<End>&#126;</End>
</CharacterRegion>
</CharacterRegions>
</Asset>
</XnaContent>

View file

@ -7,6 +7,7 @@ using Pacman.Classes;
using Pacman.Classes.UI;
using Microsoft.Xna.Framework.Media;
using Microsoft.Xna.Framework.Audio;
using System.Threading;
using System.IO;
@ -14,7 +15,7 @@ namespace Pacman
{
public enum GameState
{
Game, Menu, GameOver, NextLevel
Game, Menu, GameOver, NextLevel, HowToPlay
}
public class Game1 : Game
@ -37,6 +38,7 @@ namespace Pacman
private Menu menu;
private HUD hud;
private GameOver gameOver;
private HowToPlay howToPlay;
// Music fields
public static SoundEffect deathSong;
@ -47,7 +49,6 @@ namespace Pacman
public static Song mainSong;
public static Song intermissionSong;
public Game1()
{
@ -78,6 +79,7 @@ namespace Pacman
menu = new Menu();
hud = new HUD(new Vector2(0, 740));
gameOver = new GameOver();
howToPlay = new HowToPlay();
base.Initialize();
}
@ -88,8 +90,11 @@ namespace Pacman
// Load sprites
spriteSheet = Content.Load<Texture2D>("sprites");
menu.LoadContent(Content);
Label.LoadContent(Content);
menu.LoadContent(Content, "gameFont");
hud.LoadContent(Content, "gameFont");
howToPlay.LoadContent(Content, "rulesFont");
gameOver.LoadContent(Content, "gameOverFont");
for (int i = 0; i < Foods.Count; i++)
{
Foods[i].LoadContent();
@ -115,6 +120,18 @@ namespace Pacman
protected override void Update(GameTime gameTime)
{
GamePadState gamePadState = GamePad.GetState(0);
KeyboardState keyboardState = Keyboard.GetState();
if ((gamePadState.Buttons.Start == ButtonState.Pressed) ||
keyboardState.IsKeyDown(Keys.Escape))
{
gameState = GameState.Menu;
RestartGame(true);
pacman.Score = 0;
pacman.ExtraLives = 4;
}
switch (gameState)
{
case GameState.Menu:
@ -126,6 +143,9 @@ namespace Pacman
case GameState.GameOver:
gameOver.Update();
break;
case GameState.HowToPlay:
howToPlay.Update();
break;
}
base.Update(gameTime);
@ -166,6 +186,9 @@ namespace Pacman
case GameState.GameOver:
gameOver.Draw(_spriteBatch);
break;
case GameState.HowToPlay:
howToPlay.Draw(_spriteBatch);
break;
}
_spriteBatch.End();

Binary file not shown.

View file

@ -1 +1 @@
4220
7620

View file

@ -1 +1 @@
c9ee6a37358296c75d1682f0de32f3e0317744c8
34eef0df2019c6ba7409c77725adb7269cda07e4

View file

@ -53,3 +53,4 @@ C:\Users\Semejkin_AV\Documents\Github_repos\Pacman\Pacman\bin\Debug\netcoreapp3.
C:\Users\Semejkin_AV\Documents\Github_repos\Pacman\Pacman\bin\Debug\netcoreapp3.1\Content\ghostDeathSound.xnb
C:\Users\Semejkin_AV\Documents\Github_repos\Pacman\Pacman\bin\Debug\netcoreapp3.1\Content\fruitEaten.xnb
C:\Users\Semejkin_AV\Documents\Github_repos\Pacman\Pacman\bin\Debug\netcoreapp3.1\Content\chompSound.wma
C:\Users\Semejkin_AV\Documents\Github_repos\Pacman\Pacman\bin\Debug\netcoreapp3.1\Content\rulesFont.xnb