Esempio n. 1
0
    public static void Main()
    {
        TextureLoader.LoadTextures();

        var map    = MapLoader.LoadMap("Default");
        var pacman = new Pacman(map, new Position(1, 1));

        RenderWindowEventHandler.RegisterHandlers(Window, pacman);

        while (Window.IsOpen)
        {
            Window.Clear();

            Window.DispatchEvents();
            foreach (var tile in map)
            {
                tile.Draw(Window, default);
            }

            pacman.Move();
            pacman.Draw(Window, default);

            Window.Display();
        }
    }
Esempio n. 2
0
    public void Draw()
    {
        _GameWindow.Clear(Color.Black); // clear window with black
        _Gameboard.DrawMaze();          // draws maze jpeg to screen
        _Gameboard.DrawBoard();         // creates maze and pivot visual representations for testing

        _Pacman.Draw();                 // draw pacman
        foreach (Ghost g in _Ghosts)
        {
            g.Draw();
        }
        UpdateHUD();
        _GameWindow.Refresh(60); // refresh screen
    }
Esempio n. 3
0
        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.CornflowerBlue);
            GraphicsDevice.DepthStencilState = new DepthStencilState();
            GraphicsDevice.Clear(background);

            if (currentScene == scenes["Play"])
            {
                foreach (Camera camera in cameras)
                {
                    effect.Parameters["NormalMap"].SetValue(terrain.NormalMap);
                    effect.Parameters["World"].SetValue(terrain.Transform.World);
                    effect.Parameters["View"].SetValue(camera.View);
                    effect.Parameters["Projection"].SetValue(camera.Projection);
                    effect.Parameters["CameraPosition"].SetValue(camera.Transform.Position);
                    effect.Parameters["LightPosition"].SetValue(light.Transform.Position);
                    foreach (EffectPass pass in effect.CurrentTechnique.Passes)
                    {
                        pass.Apply();
                        terrain.Draw();
                    }

                    pacman.Draw();
                    Inky.Draw();
                    Blinky.Draw();
                    Pinky.Draw();
                    Clyde.Draw();
                    powerUp.Draw();
                }
                spriteBatch.Begin();
                spriteBatch.DrawString(font, "# of Hits: " + hits, new Vector2(100, 50), Color.White);
                spriteBatch.DrawString(font, "Time left: " + Time.TotalGameTime, new Vector2(100, 70), Color.White);
                spriteBatch.DrawString(font, "WASD to move", new Vector2(100, 90), Color.White);
                spriteBatch.End();
            }
            currentScene.Draw();

            base.Draw(gameTime);
        }