コード例 #1
0
ファイル: Game1.cs プロジェクト: jairam77/Gautam-Pong
 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);
 }
コード例 #2
0
ファイル: StartScreen.cs プロジェクト: timrisi/MonoPong
 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);
 }
コード例 #3
0
ファイル: Game1.cs プロジェクト: Limeabean/LocalHackDay2015
        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();
        }
コード例 #4
0
ファイル: Game1.cs プロジェクト: Innkeeper/PongClone
        /// <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();
        }
コード例 #5
0
ファイル: Game1.cs プロジェクト: alex45101/Pong
        /// <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();
        }
コード例 #6
0
ファイル: Game1.cs プロジェクト: jairam77/Gautam-Pong
        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);
        }
コード例 #7
0
ファイル: Game1.cs プロジェクト: jairam77/Gautam-Pong
 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;
 }