protected void difficulty() { gamescreen = GameScreens.GameState.DifficultySelect; List<Text> Menutextdiff = new List<Text>(); Menutextdiff.Add(new Text(new Vector2(360,150),"Easy",font,easy)); Menutextdiff.Add(new Text(new Vector2(360, 200), "Medium", font, easy)); Menutextdiff.Add(new Text(new Vector2(360, 250), "Hard", font, easy)); difmenu = new Menu(Menutextdiff, difficultymenu); }
public StartScreen(Game game, SpriteBatch spriteBatch, SpriteFont spriteFont) : base(game, spriteBatch) { string [] menuItems = { "One Player", "Two Players", "Up: W", "Up: Up", "Down: S", "Down: Down" }; menu = new Menu (game, spriteBatch, spriteFont, menuItems); Components.Add (menu); }
public Game1() { graphics = new GraphicsDeviceManager(this); Content.RootDirectory = "Content"; menuSprite = new Sprite(); pointerSprite = new Sprite(); creditSprite = new Sprite(); gameOverSprite = new Sprite(); gameball = new Ball(285, 285, 30, 30, 5, 5); paddle1 = new Paddle(1); paddle2 = new Paddle(2); paddle3 = new Paddle(3); paddle4 = new Paddle(4); ballsprite = new Sprite(gameball.getx(), gameball.gety()); paddlesprite1 = new Sprite(paddle1.getX(), paddle1.getY()); paddlesprite2 = new Sprite(paddle2.getX(), paddle2.getY()); paddlesprite3 = new Sprite(paddle3.getX(), paddle3.getY()); paddlesprite4 = new Sprite(paddle4.getX(), paddle4.getY()); menu = new Menu(); }
/// <summary> /// Allows the game to perform any initialization it needs to before starting to run. /// This is where it can query for any required services and load any non-graphic /// related content. Calling base.Initialize will enumerate through any components /// and initialize them as well. /// </summary> protected override void Initialize() { screenHeight = 600; screenWidth = 800; menu = new Menu(); gamestate = GameStates.Menu; resetTimer = 0; resetTimerInUse = true; lastScored = false; graphics.PreferredBackBufferWidth = screenWidth; graphics.PreferredBackBufferHeight = screenHeight; graphics.IsFullScreen = false; graphics.ApplyChanges(); // TODO: Add your initialization logic here ball = new Ball(Content, new Vector2(screenWidth, screenHeight)); SetUpMulti(); input = new Input(); base.Initialize(); }
/// <summary> /// Allows the game to perform any initialization it needs to before starting to run. /// This is where it can query for any required services and load any non-graphic /// related content. Calling base.Initialize will enumerate through any components /// and initialize them as well. /// </summary> protected override void Initialize() { // TODO: Add your initialization logic here IsMouseVisible = true; gameengine = new GameEngine(); menu = new Menu(gameengine); base.Initialize(); }
protected override void Update(GameTime gameTime) { oldkeyboardstate = keyboardstate; keyboardstate = Keyboard.GetState(); if (gameend) { if (keyboardstate.IsKeyDown(Keys.Escape)) { gamescreen = GameScreens.GameState.Menu; ListMenu = new List<Text>(); ListMenu.Add(new Text(new Vector2(50, 50), "Human vs Human", font, gamestart)); ListMenu.Add(new Text(new Vector2(50, 100), "Human vs Computer", font, difficulty)); ListMenu.Add(new Text(new Vector2(50, 150), "Exit", font, End)); mainmenu = new Menu(ListMenu,mainmenuimg); gameend = false; } } if (gamescreen == GameScreens.GameState.Play) { if (timerstarted) { if (timestart.ElapsedMilliseconds > 3000) { timestart.Stop(); timestart.Reset(); timerstarted = false; gameball.start_ball(); } } Left.TakeInput(keyboardstate); Right.TakeInput(keyboardstate); gameball.updatepaddleboundary(Left.boundary, Right.boundary); gameball.update(); if (gameball.Location.X < -25) { playerright.scored(); gameball.stop(); gameball.keepinposition(); timestart.Start(); timerstarted = true; } else if (gameball.Location.X > 750) { playerleft.scored(); gameball.stop(); gameball.keepinposition(); timestart.Start(); timerstarted = true; } if (playerleft.Score == 10) { gameover(playerleft); timestart.Stop(); } if (playerright.Score == 10) { gameover(playerright); timestart.Stop(); } } else if (gamescreen == GameScreens.GameState.Menu) { mainmenu.input(keyboardstate,oldkeyboardstate); } else if (gamescreen == GameScreens.GameState.PlayComp) { if (timerstarted) { if (timestart.ElapsedMilliseconds > 3000) { timestart.Stop(); timestart.Reset(); timerstarted = false; gameball.start_ball(); } } computer.updatepaddle(gameball,Left); gameball.updatepaddleboundary(Left.boundary, Right.boundary); Right.TakeInput(keyboardstate); gameball.update(); if (gameball.Location.X < -25) { playerright.scored(); gameball.stop(); gameball.keepinposition(); timestart.Start(); timerstarted = true; } else if (gameball.Location.X > 750) { playerleft.scored(); gameball.stop(); gameball.keepinposition(); timestart.Start(); timerstarted = true; } if (playerleft.Score == 10) { gameover(playerleft); timestart.Stop(); } if (playerright.Score == 10) { gameover(playerright); timestart.Stop(); } } else if (gamescreen == GameScreens.GameState.DifficultySelect) { difmenu.input(keyboardstate, oldkeyboardstate); } base.Update(gameTime); }
protected override void LoadContent() { gamescreen = GameScreens.GameState.Menu; font = Content.Load<SpriteFont>("GameFont"); ListMenu = new List<Text>(); mainmenuimg = Content.Load<Texture2D>("MainMenu"); ListMenu.Add(new Text(new Vector2(50, 50), "Human vs Human", font, gamestart)); ListMenu.Add(new Text(new Vector2(50, 100), "Human vs Computer", font, difficulty)); ListMenu.Add(new Text(new Vector2(50, 150), "Exit", font,End)); mainmenu = new Menu(ListMenu,mainmenuimg); spriteBatch = new SpriteBatch(GraphicsDevice); ball = Content.Load<Texture2D>("Ball"); paddle = Content.Load<Texture2D>("Paddle"); board = Content.Load<Texture2D>("Board"); gametimer = new Stopwatch(); keyboardstate = new KeyboardState(); oldkeyboardstate = new KeyboardState(); difficultymenu = Content.Load<Texture2D>("Difficulty Screen"); timerstarted = false; timestart = new Stopwatch(); gameend = false; }