Code
Code
cs
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
public Game1()
{
_graphics = new GraphicsDeviceManager(this);
Content.RootDirectory = "Content";
IsMouseVisible = true;
_isNameEntered = false;
_input = string.Empty;
base.Initialize();
_font = Content.Load<SpriteFont>("Arial");
_logoTexture = Content.Load<Texture2D>("logo");
_playerTexture = Content.Load<Texture2D>("player");
_skyBG = Content.Load<Texture2D>("sky");
_treeTexture1 = Content.Load<Texture2D>("tree1");
_treeTexture2 = Content.Load<Texture2D>("tree2");
_signTexture = Content.Load<Texture2D>("sign");
_barrierTexture1 = Content.Load<Texture2D>("barrier");
_barrierTexture2 = Content.Load<Texture2D>("barrier2");
_tableTexture = Content.Load<Texture2D>("table");
_coffeeTexture = Content.Load<Texture2D>("coffee");
_drillTexture = Content.Load<Texture2D>("drill");
_foregroundTexture = Content.Load<Texture2D>("foreground");
_floorTexture = Content.Load<Texture2D>("floor");
_snowLayerTexture = Content.Load<Texture2D>("snowLayer");
if (Keyboard.GetState().IsKeyDown(Keys.Escape))
Exit();
if (!_isNameEntered)
{
foreach (var key in currentKeyboardState.GetPressedKeys())
_playerName = _input;
_isNameEntered = true;
MediaPlayer.Stop();
MediaPlayer.Play(_backgroundMusic);
MediaPlayer.IsRepeating = true;
else if (key >= Keys.A && key <= Keys.Z) // Filtrar solo teclas de letras
if (currentKeyboardState.IsKeyDown(Keys.LeftShift) ||
currentKeyboardState.IsKeyDown(Keys.RightShift))
else
else if (key >= Keys.D0 && key <= Keys.D9) // Filtrar solo teclas de
números
else
_previousMouseState = mouseState;
direction.Normalize();
}
else
_playerPosition = _targetPosition;
base.Update(gameTime);
GraphicsDevice.Clear(Color.CornflowerBlue);
_spriteBatch.Begin();
if (!_isNameEntered)
// Dibujar el logo
string instructionText = "Por favor, ingresa un nombre para tu oso: " + _input;
else
// Dibuja el piso
// Dibuja el foreground
// Dibuja la mesa
// Dibuja cafetera
// Dibuja taladro
_spriteBatch.End();
base.Draw(gameTime);
}
MainMenu.cs
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
public MainMenu()
Content.RootDirectory = "Content";
IsMouseVisible = true;
_isStartGameSelected = false;
base.Initialize();
}
protected override void LoadContent()
_font = Content.Load<SpriteFont>("Arial");
if (Keyboard.GetState().IsKeyDown(Keys.Enter))
_isStartGameSelected = true;
if (_isStartGameSelected)
game.Run();
Exit();
base.Update(gameTime);
GraphicsDevice.Clear(Color.CornflowerBlue);
_spriteBatch.Begin();
_spriteBatch.End();
base.Draw(gameTime);