//Iclusão de Menu's e retrocesso para o MainMenu
using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
namespace Pong_The_Game_1._01
{
public class Game1 : Microsoft.Xna.Framework.Game
{
GraphicsDeviceManager graphics;
SpriteBatch spriteBatch;
SpriteFont Arial;
//Classe Bola
Bola_Easy bola_Easy;
Bola_Medium bola_Medium;
Bola_Hard bola_Hard;
//Classe Player
Player player1;
Player player2;
//Textura a ser utilizada na classe Bola
Texture2D imgBola;
//Textura a ser utilizada na classe Player
Texture2D imgPlayer;
//Texture2D Imagns Background;
Texture2D background;
Texture2D controls_background;
Texture2D credits_background;
//Textura da "rede"
Texture2D imgRede;
//Array que irá receber cada "fatia" da imagem com seu respectivo número
Rectangle[] pontos = null;
//Pontos dos jogadores_Easy
int pontosPlayer1_Easy;
int pontosPlayer2_Easy;
//Pontos dos jogadores_Medium
int pontosPlayer1_Medium;
int pontosPlayer2_Medium;
//Pontos dos jogadores_Hard
int pontosPlayer1_Hard;
int pontosPlayer2_Hard;
enum GameState
{
MainMenu,
Play_Menu,
Play,
Controls,
Credits,
Easy,
Medium,
Hard
}
GameState CurrentGameState = GameState.MainMenu;
int screenWidth = 800, screenHeight = 600;
cButton btnPlay_Play;
cButton btnPlay_Controls;
cButton btnPlay_Credits;
cButton btnPlay_Easy;
cButton btnPlay_Medium;
cButton btnPlay_Hard;
public Game1()
{
graphics = [URL="http://www.portugal-a-programar.pt/topic/57956-dificuldade-com-jogo-em-xna/<span>http://</span>www.google.com/search?q=new+msdn.microsoft.com"]new[/URL] GraphicsDeviceManager(this);
Content.RootDirectory = "Content";
}
protected override void Initialize()
{
bola_Easy = [URL="http://www.portugal-a-programar.pt/topic/57956-dificuldade-com-jogo-em-xna/<span>http://</span>www.google.com/search?q=new+msdn.microsoft.com"]new[/URL] Bola_Easy();
bola_Medium = [URL="http://www.portugal-a-programar.pt/topic/57956-dificuldade-com-jogo-em-xna/<span>http://</span>www.google.com/search?q=new+msdn.microsoft.com"]new[/URL] Bola_Medium();
bola_Hard = [URL="http://www.portugal-a-programar.pt/topic/57956-dificuldade-com-jogo-em-xna/<span>http://</span>www.google.com/search?q=new+msdn.microsoft.com"]new[/URL] Bola_Hard();
player1 = [URL="http://www.portugal-a-programar.pt/topic/57956-dificuldade-com-jogo-em-xna/<span>http://</span>www.google.com/search?q=new+msdn.microsoft.com"]new[/URL] Player();
player2 = [URL="http://www.portugal-a-programar.pt/topic/57956-dificuldade-com-jogo-em-xna/<span>http://</span>www.google.com/search?q=new+msdn.microsoft.com"]new[/URL] Player();
pontosPlayer1_Easy = 0;
pontosPlayer2_Easy = 0;
pontosPlayer1_Medium = 0;
pontosPlayer2_Medium = 0;
pontosPlayer1_Hard = 0;
pontosPlayer2_Hard = 0;
base.Initialize();
}
protected override void LoadContent()
{
spriteBatch = [URL="http://www.portugal-a-programar.pt/topic/57956-dificuldade-com-jogo-em-xna/<span>http://</span>www.google.com/search?q=new+msdn.microsoft.com"]new[/URL] SpriteBatch(GraphicsDevice);
graphics.PreferredBackBufferWidth = screenWidth;
graphics.PreferredBackBufferHeight = screenHeight;
graphics.ApplyChanges();
IsMouseVisible = true;
Arial = Content.Load<SpriteFont>("Arial");
//Carregando as imagens que serão utilizadas no jogo
imgBola = Content.Load<Texture2D>("bola");
imgPlayer = Content.Load<Texture2D>("player");
imgRede = Content.Load<Texture2D>("rede");
//Definições da Bola_Easy
//Aqui definimos as propriedades da bola como Tamanho, Posição inicial na tela
//velocidade e qual a textura a ser utilizada.
//Note tambem que utilizamos a classe Windows.ClientBound para posicionarmos
//nossa bola_Easy no centro da tela
bola_Easy.Tamanho = [URL="http://www.portugal-a-programar.pt/topic/57956-dificuldade-com-jogo-em-xna/<span>http://</span>www.google.com/search?q=new+msdn.microsoft.com"]new[/URL] Vector2(imgBola.Width, imgBola.Height);
bola_Easy.Posicao = [URL="http://www.portugal-a-programar.pt/topic/57956-dificuldade-com-jogo-em-xna/<span>http://</span>www.google.com/search?q=new+msdn.microsoft.com"]new[/URL] Vector2((window.ClientBounds.Width / 2) - (bola_Easy.Tamanho.X / 2), (window.ClientBounds.Height / 2) - (bola_Easy.Tamanho.Y / 2));
//nossa bola_Medium no centro da tela
bola_Medium.Tamanho = [URL="http://www.portugal-a-programar.pt/topic/57956-dificuldade-com-jogo-em-xna/<span>http://</span>www.google.com/search?q=new+msdn.microsoft.com"]new[/URL] Vector2(imgBola.Width, imgBola.Height);
bola_Medium.Posicao = [URL="http://www.portugal-a-programar.pt/topic/57956-dificuldade-com-jogo-em-xna/<span>http://</span>www.google.com/search?q=new+msdn.microsoft.com"]new[/URL] Vector2((window.ClientBounds.Width / 2) - (bola_Medium.Tamanho.X / 2), (window.ClientBounds.Height / 2) - (bola_Medium.Tamanho.Y / 2));
//nossa bola_Hard no centro da tela
bola_Hard.Tamanho = [URL="http://www.portugal-a-programar.pt/topic/57956-dificuldade-com-jogo-em-xna/<span>http://</span>www.google.com/search?q=new+msdn.microsoft.com"]new[/URL] Vector2(imgBola.Width, imgBola.Height);
bola_Hard.Posicao = [URL="http://www.portugal-a-programar.pt/topic/57956-dificuldade-com-jogo-em-xna/<span>http://</span>www.google.com/search?q=new+msdn.microsoft.com"]new[/URL] Vector2((window.ClientBounds.Width / 2) - (bola_Hard.Tamanho.X / 2), (window.ClientBounds.Height / 2) - (bola_Hard.Tamanho.Y / 2));
//velocidade Bola_Easy
bola_Easy.Velocidade = [URL="http://www.portugal-a-programar.pt/topic/57956-dificuldade-com-jogo-em-xna/<span>http://</span>www.google.com/search?q=new+msdn.microsoft.com"]new[/URL] Vector2(5.0f, 5.0f);
//velocidade Bola_Medium
bola_Medium.Velocidade = [URL="http://www.portugal-a-programar.pt/topic/57956-dificuldade-com-jogo-em-xna/<span>http://</span>www.google.com/search?q=new+msdn.microsoft.com"]new[/URL] Vector2(8.0f, 8.0f);
//velocidade Bola_Hard
bola_Hard.Velocidade = [URL="http://www.portugal-a-programar.pt/topic/57956-dificuldade-com-jogo-em-xna/<span>http://</span>www.google.com/search?q=new+msdn.microsoft.com"]new[/URL] Vector2(10.0f, 10.0f);
bola_Easy.Textura = imgBola;
bola_Medium.Textura = imgBola;
bola_Hard.Textura = imgBola;
//Player 1
//Assim como a bola, definimos também os dados de cada player
player1.Tamanho = [URL="http://www.portugal-a-programar.pt/topic/57956-dificuldade-com-jogo-em-xna/<span>http://</span>www.google.com/search?q=new+msdn.microsoft.com"]new[/URL] Vector2(imgPlayer.Width, imgPlayer.Height);
player1.Posicao = [URL="http://www.portugal-a-programar.pt/topic/57956-dificuldade-com-jogo-em-xna/<span>http://</span>www.google.com/search?q=new+msdn.microsoft.com"]new[/URL] Vector2(10f, (window.ClientBounds.Height / 2 - imgPlayer.Height / 2));
player1.Velocidade = [URL="http://www.portugal-a-programar.pt/topic/57956-dificuldade-com-jogo-em-xna/<span>http://</span>www.google.com/search?q=new+msdn.microsoft.com"]new[/URL] Vector2(0, 5);
player1.Textura = imgPlayer;
//Player 2
player2.Tamanho = [URL="http://www.portugal-a-programar.pt/topic/57956-dificuldade-com-jogo-em-xna/<span>http://</span>www.google.com/search?q=new+msdn.microsoft.com"]new[/URL] Vector2(imgPlayer.Width, imgPlayer.Height);
player2.Posicao = [URL="http://www.portugal-a-programar.pt/topic/57956-dificuldade-com-jogo-em-xna/<span>http://</span>www.google.com/search?q=new+msdn.microsoft.com"]new[/URL] Vector2((window.ClientBounds.Width - 10 - imgPlayer.Width), (window.ClientBounds.Height / 2 - imgPlayer.Height / 2));
player2.Velocidade = [URL="http://www.portugal-a-programar.pt/topic/57956-dificuldade-com-jogo-em-xna/<span>http://</span>www.google.com/search?q=new+msdn.microsoft.com"]new[/URL] Vector2(0, 5);
player2.Textura = imgPlayer;
pontos = [URL="http://www.portugal-a-programar.pt/topic/57956-dificuldade-com-jogo-em-xna/<span>http://</span>www.google.com/search?q=new+msdn.microsoft.com"]new[/URL] Rectangle[10];
//Carrega um array com a definição dos numeros
//Aqui realizamos o preenchimento de nosso array com seus
//respectivos valores para termos a posição certa de cada
//fatia dentro da imagem original
for (int i = 0; i < 10; i++)
{
pontos[i] = [URL="http://www.portugal-a-programar.pt/topic/57956-dificuldade-com-jogo-em-xna/<span>http://</span>www.google.com/search?q=new+msdn.microsoft.com"]new[/URL] Rectangle(i * 45, 0, 45, 75);
}
btnPlay_Play = [URL="http://www.portugal-a-programar.pt/topic/57956-dificuldade-com-jogo-em-xna/<span>http://</span>www.google.com/search?q=new+msdn.microsoft.com"]new[/URL] cButton(Content.Load<Texture2D>("play"), graphics.GraphicsDevice);
btnPlay_Play.setPosition([URL="http://www.portugal-a-programar.pt/topic/57956-dificuldade-com-jogo-em-xna/<span>http://</span>www.google.com/search?q=new+msdn.microsoft.com"]new[/URL] Vector2(320, 300));
btnPlay_Controls = [URL="http://www.portugal-a-programar.pt/topic/57956-dificuldade-com-jogo-em-xna/<span>http://</span>www.google.com/search?q=new+msdn.microsoft.com"]new[/URL] cButton(Content.Load<Texture2D>("controls"), graphics.GraphicsDevice);
btnPlay_Controls.setPosition([URL="http://www.portugal-a-programar.pt/topic/57956-dificuldade-com-jogo-em-xna/<span>http://</span>www.google.com/search?q=new+msdn.microsoft.com"]new[/URL] Vector2(320, 350));
btnPlay_Credits = [URL="http://www.portugal-a-programar.pt/topic/57956-dificuldade-com-jogo-em-xna/<span>http://</span>www.google.com/search?q=new+msdn.microsoft.com"]new[/URL] cButton(Content.Load<Texture2D>("credits"), graphics.GraphicsDevice);
btnPlay_Credits.setPosition([URL="http://www.portugal-a-programar.pt/topic/57956-dificuldade-com-jogo-em-xna/<span>http://</span>www.google.com/search?q=new+msdn.microsoft.com"]new[/URL] Vector2(320, 400));
btnPlay_Easy = [URL="http://www.portugal-a-programar.pt/topic/57956-dificuldade-com-jogo-em-xna/<span>http://</span>www.google.com/search?q=new+msdn.microsoft.com"]new[/URL] cButton(Content.Load<Texture2D>("easy"), graphics.GraphicsDevice);
btnPlay_Easy.setPosition([URL="http://www.portugal-a-programar.pt/topic/57956-dificuldade-com-jogo-em-xna/<span>http://</span>www.google.com/search?q=new+msdn.microsoft.com"]new[/URL] Vector2(320, 300));
btnPlay_Medium = [URL="http://www.portugal-a-programar.pt/topic/57956-dificuldade-com-jogo-em-xna/<span>http://</span>www.google.com/search?q=new+msdn.microsoft.com"]new[/URL] cButton(Content.Load<Texture2D>("medium"), graphics.GraphicsDevice);
btnPlay_Medium.setPosition([URL="http://www.portugal-a-programar.pt/topic/57956-dificuldade-com-jogo-em-xna/<span>http://</span>www.google.com/search?q=new+msdn.microsoft.com"]new[/URL] Vector2(320, 350));
btnPlay_Hard = [URL="http://www.portugal-a-programar.pt/topic/57956-dificuldade-com-jogo-em-xna/<span>http://</span>www.google.com/search?q=new+msdn.microsoft.com"]new[/URL] cButton(Content.Load<Texture2D>("hard"), graphics.GraphicsDevice);
btnPlay_Hard.setPosition([URL="http://www.portugal-a-programar.pt/topic/57956-dificuldade-com-jogo-em-xna/<span>http://</span>www.google.com/search?q=new+msdn.microsoft.com"]new[/URL] Vector2(320, 400));
background = Content.Load<Texture2D>("background_pong_the_game");
controls_background = Content.Load<Texture2D>("controls_background");
credits_background = Content.Load<Texture2D>("credits_background");
}
protected override void UnloadContent()
{
// TODO: Unload any non ContentManager content here
}
protected override void Update(GameTime gameTime)
{
MouseState mouse = Mouse.GetState();
KeyboardState keyboardstate = Keyboard.GetState();
switch (CurrentGameState)
{
case GameState.MainMenu:
{
if (btnPlay_Play.isClicked == true)
CurrentGameState = GameState.Play;
btnPlay_Play.update(mouse);
if (btnPlay_Controls.isClicked == true)
CurrentGameState = GameState.Controls;
btnPlay_Controls.update(mouse);
if (btnPlay_Credits.isClicked == true)
CurrentGameState = GameState.Credits;
btnPlay_Credits.update(mouse);
break;
}
case GameState.Play:
{
//Desenhar Nome do Jogo
//spriteBatch.DrawString(Arial, "Pong_The_Game", new Vector2(260, 10), Color.White);
//Menu dentro do Play
switch (CurrentGameState)
{
case GameState.Play:
{
if (btnPlay_Easy.isClicked == true)
CurrentGameState = GameState.Easy;
btnPlay_Easy.update(mouse);
if (btnPlay_Medium.isClicked == true)
CurrentGameState = GameState.Medium;
btnPlay_Medium.update(mouse);
if (btnPlay_Hard.isClicked == true)
CurrentGameState = GameState.Hard;
btnPlay_Hard.update(mouse);
break;
}
case GameState.Easy:
{
//Desenhar Nome do Jogo
//spriteBatch.DrawString(Arial, "Pong_The_Game", new Vector2(260, 10), Color.White);
break;
}
case GameState.Medium:
{
//Desenhar Nome do Jogo
//spriteBatch.DrawString(Arial, "Pong_The_Game", new Vector2(260, 10), Color.White);
break;
}
case GameState.Hard:
{
//Desenhar Nome do Jogo
//spriteBatch.DrawString(Arial, "Pong_The_Game", new Vector2(260, 10), Color.White);
break;
}
}
break;
}
case GameState.Controls:
{
//Desenhar Nome do Jogo
//spriteBatch.DrawString(Arial, "Pong_The_Game", new Vector2(260, 10), Color.White);
//Retroceder para o MainMenu
if (keyboardstate.IsKeyDown(Keys.Escape))
{
CurrentGameState = GameState.MainMenu;
break;
}
break;
}
case GameState.Credits:
{
//Desenhar Nome do Jogo
//spriteBatch.DrawString(Arial, "Pong_The_Game", new Vector2(260, 10), Color.White);
//Retroceder para o MainMenu
if (keyboardstate.IsKeyDown(Keys.Escape))
{
CurrentGameState = GameState.MainMenu;
break;
}
break;
}
}
//Bola_Easy
bola_Easy.checaColisao_Easy(player1.Retangulo, player2.Retangulo);
bola_Easy.mover_Easy(Window, ref pontosPlayer1_Easy, ref pontosPlayer2_Easy);
movePlayers();
if (pontosPlayer1_Easy > 9 || pontosPlayer2_Easy > 9)
{
pontosPlayer1_Easy = 0;
pontosPlayer2_Easy = 0;
}
//Bola_Medium
bola_Medium.checaColisao_Medium(player1.Retangulo, player2.Retangulo);
bola_Medium.mover_Medium(Window, ref pontosPlayer1_Medium, ref pontosPlayer2_Medium);
movePlayers();
if (pontosPlayer1_Medium > 9 || pontosPlayer2_Medium > 9)
{
pontosPlayer1_Medium = 0;
pontosPlayer2_Medium = 0;
}
//Bola_Hard
bola_Hard.checaColisao_Hard(player1.Retangulo, player2.Retangulo);
bola_Hard.mover_Hard(Window, ref pontosPlayer1_Hard, ref pontosPlayer2_Hard);
movePlayers();
if (pontosPlayer1_Hard > 9 || pontosPlayer2_Hard > 9)
{
pontosPlayer1_Hard = 0;
pontosPlayer2_Hard = 0;
}
base.Update(gameTime);
}
public void movePlayers()
{
KeyboardState keys = Keyboard.GetState();
//Player 1
if (keys.IsKeyDown(Keys.A))
{
if (player1.Posicao.Y < 0)
player1.Posicao = [URL="http://www.portugal-a-programar.pt/topic/57956-dificuldade-com-jogo-em-xna/<span>http://</span>www.google.com/search?q=new+msdn.microsoft.com"]new[/URL] Vector2(player1.Posicao.X, 0);
player1.Posicao -= player1.Velocidade;
}
if (keys.IsKeyDown(Keys.Z))
{
if (player1.Posicao.Y > window.ClientBounds.Height - player1.Textura.Height)
player1.Posicao = [URL="http://www.portugal-a-programar.pt/topic/57956-dificuldade-com-jogo-em-xna/<span>http://</span>www.google.com/search?q=new+msdn.microsoft.com"]new[/URL] Vector2(player1.Posicao.X, (window.ClientBounds.Height - imgPlayer.Height));
player1.Posicao += player1.Velocidade;
}
//Player 2
if (keys.IsKeyDown(Keys.Up))
{
if (player2.Posicao.Y < 0)
player2.Posicao = [URL="http://www.portugal-a-programar.pt/topic/57956-dificuldade-com-jogo-em-xna/<span>http://</span>www.google.com/search?q=new+msdn.microsoft.com"]new[/URL] Vector2(player2.Posicao.X, 0);
player2.Posicao -= player2.Velocidade;
}
if (keys.IsKeyDown(Keys.Down))
{
if (player2.Posicao.Y > window.ClientBounds.Height - player2.Textura.Height)
player2.Posicao = [URL="http://www.portugal-a-programar.pt/topic/57956-dificuldade-com-jogo-em-xna/<span>http://</span>www.google.com/search?q=new+msdn.microsoft.com"]new[/URL] Vector2(player2.Posicao.X, (window.ClientBounds.Height - imgPlayer.Height));
player2.Posicao += player2.Velocidade;
}
//Voltar ao Menu Inicial
if (keys.IsKeyDown(Keys.O))
{
}
}
protected override void Draw(GameTime gameTime)
{
// Desenha as texturas na tela
spriteBatch.Begin();
switch (CurrentGameState)
{
case GameState.MainMenu:
{
spriteBatch.Draw(background, [URL="http://www.portugal-a-programar.pt/topic/57956-dificuldade-com-jogo-em-xna/<span>http://</span>www.google.com/search?q=new+msdn.microsoft.com"]new[/URL] Rectangle(0, 0, 800, 600), Color.White);
btnPlay_Play.Draw(spriteBatch);
btnPlay_Controls.Draw(spriteBatch);
btnPlay_Credits.Draw(spriteBatch);
break;
}
case GameState.Play:
{
//graphics.GraphicsDevice.Clear(Color.White);
spriteBatch.Draw(background, [URL="http://www.portugal-a-programar.pt/topic/57956-dificuldade-com-jogo-em-xna/<span>http://</span>www.google.com/search?q=new+msdn.microsoft.com"]new[/URL] Rectangle(0, 0, 800, 600), Color.White);
btnPlay_Easy.Draw(spriteBatch);
btnPlay_Medium.Draw(spriteBatch);
btnPlay_Hard.Draw(spriteBatch);
switch (CurrentGameState)
{
case GameState.Easy:
{
graphics.GraphicsDevice.Clear(Color.Black);
//Posicionamos nossa "rede" no centro da tela
spriteBatch.Draw(imgRede, [URL="http://www.portugal-a-programar.pt/topic/57956-dificuldade-com-jogo-em-xna/<span>http://</span>www.google.com/search?q=new+msdn.microsoft.com"]new[/URL] Vector2((window.ClientBounds.Width * .5f), 0), Color.White);
//Desenhar Nome do Jogo
spriteBatch.DrawString(Arial, "Pong_The_Game_Easy", [URL="http://www.portugal-a-programar.pt/topic/57956-dificuldade-com-jogo-em-xna/<span>http://</span>www.google.com/search?q=new+msdn.microsoft.com"]new[/URL] Vector2(220, 10), Color.White);
//Desenhamos a pontuação do player 1 e do player 2
spriteBatch.DrawString(Arial, pontosPlayer1_Easy.ToString() + ":" + pontosPlayer2_Easy.ToString(), [URL="http://www.portugal-a-programar.pt/topic/57956-dificuldade-com-jogo-em-xna/<span>http://</span>www.google.com/search?q=new+msdn.microsoft.com"]new[/URL] Vector2(380, 50), Color.White);
//Desenhamos nossa "bola" apesar de ser quadrada..rsrs
spriteBatch.Draw(bola_Easy.Textura, bola_Easy.Retangulo, Color.White);
//Desenhamos os Player, um de cada lado
spriteBatch.Draw(player1.Textura, player1.Retangulo, Color.White);
spriteBatch.Draw(player2.Textura, player2.Retangulo, Color.White);
break;
}
case GameState.Medium:
{
//Posicionamos nossa "rede" no centro da tela
spriteBatch.Draw(imgRede, [URL="http://www.portugal-a-programar.pt/topic/57956-dificuldade-com-jogo-em-xna/<span>http://</span>www.google.com/search?q=new+msdn.microsoft.com"]new[/URL] Vector2((window.ClientBounds.Width * .5f), 0), Color.White);
//Desenhar Nome do Jogo
graphics.GraphicsDevice.Clear(Color.Black);
spriteBatch.DrawString(Arial, "Pong_The_Game_Medium", [URL="http://www.portugal-a-programar.pt/topic/57956-dificuldade-com-jogo-em-xna/<span>http://</span>www.google.com/search?q=new+msdn.microsoft.com"]new[/URL] Vector2(220, 10), Color.White);
//Desenhamos a pontuação do player 1 e do player 2
spriteBatch.DrawString(Arial, pontosPlayer1_Medium.ToString() + ":" + pontosPlayer2_Medium.ToString(), [URL="http://www.portugal-a-programar.pt/topic/57956-dificuldade-com-jogo-em-xna/<span>http://</span>www.google.com/search?q=new+msdn.microsoft.com"]new[/URL] Vector2(380, 50), Color.White);
//Desenhamos nossa "bola" apesar de ser quadrada..rsrs
spriteBatch.Draw(bola_Medium.Textura, bola_Medium.Retangulo, Color.White);
//Desenhamos os Player, um de cada lado
spriteBatch.Draw(player1.Textura, player1.Retangulo, Color.White);
spriteBatch.Draw(player2.Textura, player2.Retangulo, Color.White);
break;
}
case GameState.Hard:
{
//Posicionamos nossa "rede" no centro da tela
spriteBatch.Draw(imgRede, [URL="http://www.portugal-a-programar.pt/topic/57956-dificuldade-com-jogo-em-xna/<span>http://</span>www.google.com/search?q=new+msdn.microsoft.com"]new[/URL] Vector2((window.ClientBounds.Width * .5f), 0), Color.White);
//Desenhar Nome do Jogo
graphics.GraphicsDevice.Clear(Color.Black);
spriteBatch.DrawString(Arial, "Pong_The_Game_Hard", [URL="http://www.portugal-a-programar.pt/topic/57956-dificuldade-com-jogo-em-xna/<span>http://</span>www.google.com/search?q=new+msdn.microsoft.com"]new[/URL] Vector2(220, 10), Color.White);
//Desenhamos a pontuação do player 1 e do player 2
spriteBatch.DrawString(Arial, pontosPlayer1_Hard.ToString() + ":" + pontosPlayer2_Hard.ToString(), [URL="http://www.portugal-a-programar.pt/topic/57956-dificuldade-com-jogo-em-xna/<span>http://</span>www.google.com/search?q=new+msdn.microsoft.com"]new[/URL] Vector2(380, 50), Color.White);
//Desenhamos nossa "bola" apesar de ser quadrada..rsrs
spriteBatch.Draw(bola_Hard.Textura, bola_Hard.Retangulo, Color.White);
//Desenhamos os Player, um de cada lado
spriteBatch.Draw(player1.Textura, player1.Retangulo, Color.White);
spriteBatch.Draw(player2.Textura, player2.Retangulo, Color.White);
break;
}
}
break;
}
case GameState.Controls:
{
spriteBatch.Draw(controls_background, [URL="http://www.portugal-a-programar.pt/topic/57956-dificuldade-com-jogo-em-xna/<span>http://</span>www.google.com/search?q=new+msdn.microsoft.com"]new[/URL] Rectangle(0, 0, 800, 600), Color.White);
break;
}
case GameState.Credits:
{
spriteBatch.Draw(credits_background, [URL="http://www.portugal-a-programar.pt/topic/57956-dificuldade-com-jogo-em-xna/<span>http://</span>www.google.com/search?q=new+msdn.microsoft.com"]new[/URL] Rectangle(0, 0, 800, 600), Color.White);
break;
}
}
spriteBatch.End();
base.Draw(gameTime);
}
}
}//Iclusão de Menu's e retrocesso para o MainMenu
using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
namespace Pong_The_Game_1._01
{
public class Game1 : Microsoft.Xna.Framework.Game
{
GraphicsDeviceManager graphics;
SpriteBatch spriteBatch;
SpriteFont Arial;
//Classe Bola
Bola_Easy bola_Easy;
Bola_Medium bola_Medium;
Bola_Hard bola_Hard;
//Classe Player
Player player1;
Player player2;
//Textura a ser utilizada na classe Bola
Texture2D imgBola;
//Textura a ser utilizada na classe Player
Texture2D imgPlayer;
//Texture2D Imagns Background;
Texture2D background;
Texture2D controls_background;
Texture2D credits_background;
//Textura da "rede"
Texture2D imgRede;
//Array que irá receber cada "fatia" da imagem com seu respectivo número
Rectangle[] pontos = null;
//Pontos dos jogadores_Easy
int pontosPlayer1_Easy;
int pontosPlayer2_Easy;
//Pontos dos jogadores_Medium
int pontosPlayer1_Medium;
int pontosPlayer2_Medium;
//Pontos dos jogadores_Hard
int pontosPlayer1_Hard;
int pontosPlayer2_Hard;
enum GameState
{
MainMenu,
Play_Menu,
Play,
Controls,
Credits,
Easy,
Medium,
Hard
}
GameState CurrentGameState = GameState.MainMenu;
int screenWidth = 800, screenHeight = 600;
cButton btnPlay_Play;
cButton btnPlay_Controls;
cButton btnPlay_Credits;
cButton btnPlay_Easy;
cButton btnPlay_Medium;
cButton btnPlay_Hard;
public Game1()
{
graphics = [URL="http://www.portugal-a-programar.pt/topic/57956-dificuldade-com-jogo-em-xna/<span>http://</span>www.google.com/search?q=new+msdn.microsoft.com"]new[/URL] GraphicsDeviceManager(this);
Content.RootDirectory = "Content";
}
protected override void Initialize()
{
bola_Easy = [URL="http://www.portugal-a-programar.pt/topic/57956-dificuldade-com-jogo-em-xna/<span>http://</span>www.google.com/search?q=new+msdn.microsoft.com"]new[/URL] Bola_Easy();
bola_Medium = [URL="http://www.portugal-a-programar.pt/topic/57956-dificuldade-com-jogo-em-xna/<span>http://</span>www.google.com/search?q=new+msdn.microsoft.com"]new[/URL] Bola_Medium();
bola_Hard = [URL="http://www.portugal-a-programar.pt/topic/57956-dificuldade-com-jogo-em-xna/<span>http://</span>www.google.com/search?q=new+msdn.microsoft.com"]new[/URL] Bola_Hard();
player1 = [URL="http://www.portugal-a-programar.pt/topic/57956-dificuldade-com-jogo-em-xna/<span>http://</span>www.google.com/search?q=new+msdn.microsoft.com"]new[/URL] Player();
player2 = [URL="http://www.portugal-a-programar.pt/topic/57956-dificuldade-com-jogo-em-xna/<span>http://</span>www.google.com/search?q=new+msdn.microsoft.com"]new[/URL] Player();
pontosPlayer1_Easy = 0;
pontosPlayer2_Easy = 0;
pontosPlayer1_Medium = 0;
pontosPlayer2_Medium = 0;
pontosPlayer1_Hard = 0;
pontosPlayer2_Hard = 0;
base.Initialize();
}
protected override void LoadContent()
{
spriteBatch = [URL="http://www.portugal-a-programar.pt/topic/57956-dificuldade-com-jogo-em-xna/<span>http://</span>www.google.com/search?q=new+msdn.microsoft.com"]new[/URL] SpriteBatch(GraphicsDevice);
graphics.PreferredBackBufferWidth = screenWidth;
graphics.PreferredBackBufferHeight = screenHeight;
graphics.ApplyChanges();
IsMouseVisible = true;
Arial = Content.Load<SpriteFont>("Arial");
//Carregando as imagens que serão utilizadas no jogo
imgBola = Content.Load<Texture2D>("bola");
imgPlayer = Content.Load<Texture2D>("player");
imgRede = Content.Load<Texture2D>("rede");
//Definições da Bola_Easy
//Aqui definimos as propriedades da bola como Tamanho, Posição inicial na tela
//velocidade e qual a textura a ser utilizada.
//Note tambem que utilizamos a classe Windows.ClientBound para posicionarmos
//nossa bola_Easy no centro da tela
bola_Easy.Tamanho = [URL="http://www.portugal-a-programar.pt/topic/57956-dificuldade-com-jogo-em-xna/<span>http://</span>www.google.com/search?q=new+msdn.microsoft.com"]new[/URL] Vector2(imgBola.Width, imgBola.Height);
bola_Easy.Posicao = [URL="http://www.portugal-a-programar.pt/topic/57956-dificuldade-com-jogo-em-xna/<span>http://</span>www.google.com/search?q=new+msdn.microsoft.com"]new[/URL] Vector2((window.ClientBounds.Width / 2) - (bola_Easy.Tamanho.X / 2), (window.ClientBounds.Height / 2) - (bola_Easy.Tamanho.Y / 2));
//nossa bola_Medium no centro da tela
bola_Medium.Tamanho = [URL="http://www.portugal-a-programar.pt/topic/57956-dificuldade-com-jogo-em-xna/<span>http://</span>www.google.com/search?q=new+msdn.microsoft.com"]new[/URL] Vector2(imgBola.Width, imgBola.Height);
bola_Medium.Posicao = [URL="http://www.portugal-a-programar.pt/topic/57956-dificuldade-com-jogo-em-xna/<span>http://</span>www.google.com/search?q=new+msdn.microsoft.com"]new[/URL] Vector2((window.ClientBounds.Width / 2) - (bola_Medium.Tamanho.X / 2), (window.ClientBounds.Height / 2) - (bola_Medium.Tamanho.Y / 2));
//nossa bola_Hard no centro da tela
bola_Hard.Tamanho = [URL="http://www.portugal-a-programar.pt/topic/57956-dificuldade-com-jogo-em-xna/<span>http://</span>www.google.com/search?q=new+msdn.microsoft.com"]new[/URL] Vector2(imgBola.Width, imgBola.Height);
bola_Hard.Posicao = [URL="http://www.portugal-a-programar.pt/topic/57956-dificuldade-com-jogo-em-xna/<span>http://</span>www.google.com/search?q=new+msdn.microsoft.com"]new[/URL] Vector2((window.ClientBounds.Width / 2) - (bola_Hard.Tamanho.X / 2), (window.ClientBounds.Height / 2) - (bola_Hard.Tamanho.Y / 2));
//velocidade Bola_Easy
bola_Easy.Velocidade = [URL="http://www.portugal-a-programar.pt/topic/57956-dificuldade-com-jogo-em-xna/<span>http://</span>www.google.com/search?q=new+msdn.microsoft.com"]new[/URL] Vector2(5.0f, 5.0f);
//velocidade Bola_Medium
bola_Medium.Velocidade = [URL="http://www.portugal-a-programar.pt/topic/57956-dificuldade-com-jogo-em-xna/<span>http://</span>www.google.com/search?q=new+msdn.microsoft.com"]new[/URL] Vector2(8.0f, 8.0f);
//velocidade Bola_Hard
bola_Hard.Velocidade = [URL="http://www.portugal-a-programar.pt/topic/57956-dificuldade-com-jogo-em-xna/<span>http://</span>www.google.com/search?q=new+msdn.microsoft.com"]new[/URL] Vector2(10.0f, 10.0f);
bola_Easy.Textura = imgBola;
bola_Medium.Textura = imgBola;
bola_Hard.Textura = imgBola;
//Player 1
//Assim como a bola, definimos também os dados de cada player
player1.Tamanho = [URL="http://www.portugal-a-programar.pt/topic/57956-dificuldade-com-jogo-em-xna/<span>http://</span>www.google.com/search?q=new+msdn.microsoft.com"]new[/URL] Vector2(imgPlayer.Width, imgPlayer.Height);
player1.Posicao = [URL="http://www.portugal-a-programar.pt/topic/57956-dificuldade-com-jogo-em-xna/<span>http://</span>www.google.com/search?q=new+msdn.microsoft.com"]new[/URL] Vector2(10f, (window.ClientBounds.Height / 2 - imgPlayer.Height / 2));
player1.Velocidade = [URL="http://www.portugal-a-programar.pt/topic/57956-dificuldade-com-jogo-em-xna/<span>http://</span>www.google.com/search?q=new+msdn.microsoft.com"]new[/URL] Vector2(0, 5);
player1.Textura = imgPlayer;
//Player 2
player2.Tamanho = [URL="http://www.portugal-a-programar.pt/topic/57956-dificuldade-com-jogo-em-xna/<span>http://</span>www.google.com/search?q=new+msdn.microsoft.com"]new[/URL] Vector2(imgPlayer.Width, imgPlayer.Height);
player2.Posicao = [URL="http://www.portugal-a-programar.pt/topic/57956-dificuldade-com-jogo-em-xna/<span>http://</span>www.google.com/search?q=new+msdn.microsoft.com"]new[/URL] Vector2((window.ClientBounds.Width - 10 - imgPlayer.Width), (window.ClientBounds.Height / 2 - imgPlayer.Height / 2));
player2.Velocidade = [URL="http://www.portugal-a-programar.pt/topic/57956-dificuldade-com-jogo-em-xna/<span>http://</span>www.google.com/search?q=new+msdn.microsoft.com"]new[/URL] Vector2(0, 5);
player2.Textura = imgPlayer;
pontos = [URL="http://www.portugal-a-programar.pt/topic/57956-dificuldade-com-jogo-em-xna/<span>http://</span>www.google.com/search?q=new+msdn.microsoft.com"]new[/URL] Rectangle[10];
//Carrega um array com a definição dos numeros
//Aqui realizamos o preenchimento de nosso array com seus
//respectivos valores para termos a posição certa de cada
//fatia dentro da imagem original
for (int i = 0; i < 10; i++)
{
pontos[i] = [URL="http://www.portugal-a-programar.pt/topic/57956-dificuldade-com-jogo-em-xna/<span>http://</span>www.google.com/search?q=new+msdn.microsoft.com"]new[/URL] Rectangle(i * 45, 0, 45, 75);
}
btnPlay_Play = [URL="http://www.portugal-a-programar.pt/topic/57956-dificuldade-com-jogo-em-xna/<span>http://</span>www.google.com/search?q=new+msdn.microsoft.com"]new[/URL] cButton(Content.Load<Texture2D>("play"), graphics.GraphicsDevice);
btnPlay_Play.setPosition([URL="http://www.portugal-a-programar.pt/topic/57956-dificuldade-com-jogo-em-xna/<span>http://</span>www.google.com/search?q=new+msdn.microsoft.com"]new[/URL] Vector2(320, 300));
btnPlay_Controls = [URL="http://www.portugal-a-programar.pt/topic/57956-dificuldade-com-jogo-em-xna/<span>http://</span>www.google.com/search?q=new+msdn.microsoft.com"]new[/URL] cButton(Content.Load<Texture2D>("controls"), graphics.GraphicsDevice);
btnPlay_Controls.setPosition([URL="http://www.portugal-a-programar.pt/topic/57956-dificuldade-com-jogo-em-xna/<span>http://</span>www.google.com/search?q=new+msdn.microsoft.com"]new[/URL] Vector2(320, 350));
btnPlay_Credits = [URL="http://www.portugal-a-programar.pt/topic/57956-dificuldade-com-jogo-em-xna/<span>http://</span>www.google.com/search?q=new+msdn.microsoft.com"]new[/URL] cButton(Content.Load<Texture2D>("credits"), graphics.GraphicsDevice);
btnPlay_Credits.setPosition([URL="http://www.portugal-a-programar.pt/topic/57956-dificuldade-com-jogo-em-xna/<span>http://</span>www.google.com/search?q=new+msdn.microsoft.com"]new[/URL] Vector2(320, 400));
btnPlay_Easy = [URL="http://www.portugal-a-programar.pt/topic/57956-dificuldade-com-jogo-em-xna/<span>http://</span>www.google.com/search?q=new+msdn.microsoft.com"]new[/URL] cButton(Content.Load<Texture2D>("easy"), graphics.GraphicsDevice);
btnPlay_Easy.setPosition([URL="http://www.portugal-a-programar.pt/topic/57956-dificuldade-com-jogo-em-xna/<span>http://</span>www.google.com/search?q=new+msdn.microsoft.com"]new[/URL] Vector2(320, 300));
btnPlay_Medium = [URL="http://www.portugal-a-programar.pt/topic/57956-dificuldade-com-jogo-em-xna/<span>http://</span>www.google.com/search?q=new+msdn.microsoft.com"]new[/URL] cButton(Content.Load<Texture2D>("medium"), graphics.GraphicsDevice);
btnPlay_Medium.setPosition([URL="http://www.portugal-a-programar.pt/topic/57956-dificuldade-com-jogo-em-xna/<span>http://</span>www.google.com/search?q=new+msdn.microsoft.com"]new[/URL] Vector2(320, 350));
btnPlay_Hard = [URL="http://www.portugal-a-programar.pt/topic/57956-dificuldade-com-jogo-em-xna/<span>http://</span>www.google.com/search?q=new+msdn.microsoft.com"]new[/URL] cButton(Content.Load<Texture2D>("hard"), graphics.GraphicsDevice);
btnPlay_Hard.setPosition([URL="http://www.portugal-a-programar.pt/topic/57956-dificuldade-com-jogo-em-xna/<span>http://</span>www.google.com/search?q=new+msdn.microsoft.com"]new[/URL] Vector2(320, 400));
background = Content.Load<Texture2D>("background_pong_the_game");
controls_background = Content.Load<Texture2D>("controls_background");
credits_background = Content.Load<Texture2D>("credits_background");
}
protected override void UnloadContent()
{
// TODO: Unload any non ContentManager content here
}
protected override void Update(GameTime gameTime)
{
MouseState mouse = Mouse.GetState();
KeyboardState keyboardstate = Keyboard.GetState();
switch (CurrentGameState)
{
case GameState.MainMenu:
{
if (btnPlay_Play.isClicked == true)
CurrentGameState = GameState.Play;
btnPlay_Play.update(mouse);
if (btnPlay_Controls.isClicked == true)
CurrentGameState = GameState.Controls;
btnPlay_Controls.update(mouse);
if (btnPlay_Credits.isClicked == true)
CurrentGameState = GameState.Credits;
btnPlay_Credits.update(mouse);
break;
}
case GameState.Play:
{
//Desenhar Nome do Jogo
//spriteBatch.DrawString(Arial, "Pong_The_Game", new Vector2(260, 10), Color.White);
//Menu dentro do Play
switch (CurrentGameState)
{
case GameState.Play:
{
if (btnPlay_Easy.isClicked == true)
CurrentGameState = GameState.Easy;
btnPlay_Easy.update(mouse);
if (btnPlay_Medium.isClicked == true)
CurrentGameState = GameState.Medium;
btnPlay_Medium.update(mouse);
if (btnPlay_Hard.isClicked == true)
CurrentGameState = GameState.Hard;
btnPlay_Hard.update(mouse);
break;
}
case GameState.Easy:
{
//Desenhar Nome do Jogo
//spriteBatch.DrawString(Arial, "Pong_The_Game", new Vector2(260, 10), Color.White);
break;
}
case GameState.Medium:
{
//Desenhar Nome do Jogo
//spriteBatch.DrawString(Arial, "Pong_The_Game", new Vector2(260, 10), Color.White);
break;
}
case GameState.Hard:
{
//Desenhar Nome do Jogo
//spriteBatch.DrawString(Arial, "Pong_The_Game", new Vector2(260, 10), Color.White);
break;
}
}
break;
}
case GameState.Controls:
{
//Desenhar Nome do Jogo
//spriteBatch.DrawString(Arial, "Pong_The_Game", new Vector2(260, 10), Color.White);
//Retroceder para o MainMenu
if (keyboardstate.IsKeyDown(Keys.Escape))
{
CurrentGameState = GameState.MainMenu;
break;
}
break;
}
case GameState.Credits:
{
//Desenhar Nome do Jogo
//spriteBatch.DrawString(Arial, "Pong_The_Game", new Vector2(260, 10), Color.White);
//Retroceder para o MainMenu
if (keyboardstate.IsKeyDown(Keys.Escape))
{
CurrentGameState = GameState.MainMenu;
break;
}
break;
}
}
//Bola_Easy
bola_Easy.checaColisao_Easy(player1.Retangulo, player2.Retangulo);
bola_Easy.mover_Easy(Window, ref pontosPlayer1_Easy, ref pontosPlayer2_Easy);
movePlayers();
if (pontosPlayer1_Easy > 9 || pontosPlayer2_Easy > 9)
{
pontosPlayer1_Easy = 0;
pontosPlayer2_Easy = 0;
}
//Bola_Medium
bola_Medium.checaColisao_Medium(player1.Retangulo, player2.Retangulo);
bola_Medium.mover_Medium(Window, ref pontosPlayer1_Medium, ref pontosPlayer2_Medium);
movePlayers();
if (pontosPlayer1_Medium > 9 || pontosPlayer2_Medium > 9)
{
pontosPlayer1_Medium = 0;
pontosPlayer2_Medium = 0;
}
//Bola_Hard
bola_Hard.checaColisao_Hard(player1.Retangulo, player2.Retangulo);
bola_Hard.mover_Hard(Window, ref pontosPlayer1_Hard, ref pontosPlayer2_Hard);
movePlayers();
if (pontosPlayer1_Hard > 9 || pontosPlayer2_Hard > 9)
{
pontosPlayer1_Hard = 0;
pontosPlayer2_Hard = 0;
}
base.Update(gameTime);
}
public void movePlayers()
{
KeyboardState keys = Keyboard.GetState();
//Player 1
if (keys.IsKeyDown(Keys.A))
{
if (player1.Posicao.Y < 0)
player1.Posicao = [URL="http://www.portugal-a-programar.pt/topic/57956-dificuldade-com-jogo-em-xna/<span>http://</span>www.google.com/search?q=new+msdn.microsoft.com"]new[/URL] Vector2(player1.Posicao.X, 0);
player1.Posicao -= player1.Velocidade;
}
if (keys.IsKeyDown(Keys.Z))
{
if (player1.Posicao.Y > window.ClientBounds.Height - player1.Textura.Height)
player1.Posicao = [URL="http://www.portugal-a-programar.pt/topic/57956-dificuldade-com-jogo-em-xna/<span>http://</span>www.google.com/search?q=new+msdn.microsoft.com"]new[/URL] Vector2(player1.Posicao.X, (window.ClientBounds.Height - imgPlayer.Height));
player1.Posicao += player1.Velocidade;
}
//Player 2
if (keys.IsKeyDown(Keys.Up))
{
if (player2.Posicao.Y < 0)
player2.Posicao = [URL="http://www.portugal-a-programar.pt/topic/57956-dificuldade-com-jogo-em-xna/<span>http://</span>www.google.com/search?q=new+msdn.microsoft.com"]new[/URL] Vector2(player2.Posicao.X, 0);
player2.Posicao -= player2.Velocidade;
}
if (keys.IsKeyDown(Keys.Down))
{
if (player2.Posicao.Y > window.ClientBounds.Height - player2.Textura.Height)
player2.Posicao = [URL="http://www.portugal-a-programar.pt/topic/57956-dificuldade-com-jogo-em-xna/<span>http://</span>www.google.com/search?q=new+msdn.microsoft.com"]new[/URL] Vector2(player2.Posicao.X, (window.ClientBounds.Height - imgPlayer.Height));
player2.Posicao += player2.Velocidade;
}
//Voltar ao Menu Inicial
if (keys.IsKeyDown(Keys.O))
{
}
}
protected override void Draw(GameTime gameTime)
{
// Desenha as texturas na tela
spriteBatch.Begin();
switch (CurrentGameState)
{
case GameState.MainMenu:
{
spriteBatch.Draw(background, [URL="http://www.portugal-a-programar.pt/topic/57956-dificuldade-com-jogo-em-xna/<span>http://</span>www.google.com/search?q=new+msdn.microsoft.com"]new[/URL] Rectangle(0, 0, 800, 600), Color.White);
btnPlay_Play.Draw(spriteBatch);
btnPlay_Controls.Draw(spriteBatch);
btnPlay_Credits.Draw(spriteBatch);
break;
}
case GameState.Play:
{
//graphics.GraphicsDevice.Clear(Color.White);
spriteBatch.Draw(background, [URL="http://www.portugal-a-programar.pt/topic/57956-dificuldade-com-jogo-em-xna/<span>http://</span>www.google.com/search?q=new+msdn.microsoft.com"]new[/URL] Rectangle(0, 0, 800, 600), Color.White);
btnPlay_Easy.Draw(spriteBatch);
btnPlay_Medium.Draw(spriteBatch);
btnPlay_Hard.Draw(spriteBatch);
switch (CurrentGameState)
{
case GameState.Easy:
{
graphics.GraphicsDevice.Clear(Color.Black);
//Posicionamos nossa "rede" no centro da tela
spriteBatch.Draw(imgRede, [URL="http://www.portugal-a-programar.pt/topic/57956-dificuldade-com-jogo-em-xna/<span>http://</span>www.google.com/search?q=new+msdn.microsoft.com"]new[/URL] Vector2((window.ClientBounds.Width * .5f), 0), Color.White);
//Desenhar Nome do Jogo
spriteBatch.DrawString(Arial, "Pong_The_Game_Easy", [URL="http://www.portugal-a-programar.pt/topic/57956-dificuldade-com-jogo-em-xna/<span>http://</span>www.google.com/search?q=new+msdn.microsoft.com"]new[/URL] Vector2(220, 10), Color.White);
//Desenhamos a pontuação do player 1 e do player 2
spriteBatch.DrawString(Arial, pontosPlayer1_Easy.ToString() + ":" + pontosPlayer2_Easy.ToString(), [URL="http://www.portugal-a-programar.pt/topic/57956-dificuldade-com-jogo-em-xna/<span>http://</span>www.google.com/search?q=new+msdn.microsoft.com"]new[/URL] Vector2(380, 50), Color.White);
//Desenhamos nossa "bola" apesar de ser quadrada..rsrs
spriteBatch.Draw(bola_Easy.Textura, bola_Easy.Retangulo, Color.White);
//Desenhamos os Player, um de cada lado
spriteBatch.Draw(player1.Textura, player1.Retangulo, Color.White);
spriteBatch.Draw(player2.Textura, player2.Retangulo, Color.White);
break;
}
case GameState.Medium:
{
//Posicionamos nossa "rede" no centro da tela
spriteBatch.Draw(imgRede, [URL="http://www.portugal-a-programar.pt/topic/57956-dificuldade-com-jogo-em-xna/<span>http://</span>www.google.com/search?q=new+msdn.microsoft.com"]new[/URL] Vector2((window.ClientBounds.Width * .5f), 0), Color.White);
//Desenhar Nome do Jogo
graphics.GraphicsDevice.Clear(Color.Black);
spriteBatch.DrawString(Arial, "Pong_The_Game_Medium", [URL="http://www.portugal-a-programar.pt/topic/57956-dificuldade-com-jogo-em-xna/<span>http://</span>www.google.com/search?q=new+msdn.microsoft.com"]new[/URL] Vector2(220, 10), Color.White);
//Desenhamos a pontuação do player 1 e do player 2
spriteBatch.DrawString(Arial, pontosPlayer1_Medium.ToString() + ":" + pontosPlayer2_Medium.ToString(), [URL="http://www.portugal-a-programar.pt/topic/57956-dificuldade-com-jogo-em-xna/<span>http://</span>www.google.com/search?q=new+msdn.microsoft.com"]new[/URL] Vector2(380, 50), Color.White);
//Desenhamos nossa "bola" apesar de ser quadrada..rsrs
spriteBatch.Draw(bola_Medium.Textura, bola_Medium.Retangulo, Color.White);
//Desenhamos os Player, um de cada lado
spriteBatch.Draw(player1.Textura, player1.Retangulo, Color.White);
spriteBatch.Draw(player2.Textura, player2.Retangulo, Color.White);
break;
}
case GameState.Hard:
{
//Posicionamos nossa "rede" no centro da tela
spriteBatch.Draw(imgRede, [URL="http://www.portugal-a-programar.pt/topic/57956-dificuldade-com-jogo-em-xna/<span>http://</span>www.google.com/search?q=new+msdn.microsoft.com"]new[/URL] Vector2((window.ClientBounds.Width * .5f), 0), Color.White);
//Desenhar Nome do Jogo
graphics.GraphicsDevice.Clear(Color.Black);
spriteBatch.DrawString(Arial, "Pong_The_Game_Hard", [URL="http://www.portugal-a-programar.pt/topic/57956-dificuldade-com-jogo-em-xna/<span>http://</span>www.google.com/search?q=new+msdn.microsoft.com"]new[/URL] Vector2(220, 10), Color.White);
//Desenhamos a pontuação do player 1 e do player 2
spriteBatch.DrawString(Arial, pontosPlayer1_Hard.ToString() + ":" + pontosPlayer2_Hard.ToString(), [URL="http://www.portugal-a-programar.pt/topic/57956-dificuldade-com-jogo-em-xna/<span>http://</span>www.google.com/search?q=new+msdn.microsoft.com"]new[/URL] Vector2(380, 50), Color.White);
//Desenhamos nossa "bola" apesar de ser quadrada..rsrs
spriteBatch.Draw(bola_Hard.Textura, bola_Hard.Retangulo, Color.White);
//Desenhamos os Player, um de cada lado
spriteBatch.Draw(player1.Textura, player1.Retangulo, Color.White);
spriteBatch.Draw(player2.Textura, player2.Retangulo, Color.White);
break;
}
}
break;
}
case GameState.Controls:
{
spriteBatch.Draw(controls_background, [URL="http://www.portugal-a-programar.pt/topic/57956-dificuldade-com-jogo-em-xna/<span>http://</span>www.google.com/search?q=new+msdn.microsoft.com"]new[/URL] Rectangle(0, 0, 800, 600), Color.White);
break;
}
case GameState.Credits:
{
spriteBatch.Draw(credits_background, [URL="http://www.portugal-a-programar.pt/topic/57956-dificuldade-com-jogo-em-xna/<span>http://</span>www.google.com/search?q=new+msdn.microsoft.com"]new[/URL] Rectangle(0, 0, 800, 600), Color.White);
break;
}
}
spriteBatch.End();
base.Draw(gameTime);
}
}
}