Пример #1
0
        public static void Main()
        {
            Shape myShape = new Shape();

            //Open the game window
            SwinGame.OpenGraphicsWindow("GameMain", 800, 600);
            SwinGame.ShowSwinGameSplashScreen();

            //Run the game loop
            while (SwinGame.WindowCloseRequested() == false)
            {
                //Fetch the next batch of UI interaction
                SwinGame.ProcessEvents();

                //Clear the screen and draw the framerate
                SwinGame.ClearScreen(Color.White);
                myShape.Draw();
                if (SwinGame.MouseClicked(MouseButton.LeftButton))
                {
                    myShape.X = SwinGame.MouseX();
                    myShape.Y = SwinGame.MouseY();
                }
                if (myShape.isAt(SwinGame.MousePosition()) && SwinGame.KeyTyped(KeyCode.vk_SPACE))
                {
                    myShape.Color = SwinGame.RandomRGBColor(255);
                }
                SwinGame.DrawFramerate(0, 0);


                //Draw onto the screen
                SwinGame.RefreshScreen(60);
            }
        }
Пример #2
0
        public static void Main()
        {
            //Declare new shape object
            Shape myShape = new Shape();

            //Open the game window
            SwinGame.OpenGraphicsWindow("GameMain", 800, 600);
            SwinGame.ShowSwinGameSplashScreen();

            //Run the game loop
            while (false == SwinGame.WindowCloseRequested())
            {
                //Fetch the next batch of UI interaction
                SwinGame.ProcessEvents();

                //Clear the screen and draw the framerate
                SwinGame.ClearScreen(Color.White);
                SwinGame.DrawFramerate(0, 0);

                if (Input.KeyTyped(KeyCode.SpaceKey))
                {
                    Random rand = new Random();
                    if (myShape.IsAt(Input.MousePosition()))
                    {
                        myShape.Colour = SwinGame.RandomRGBColor(255);
                    }
                }

                //draw myShape to the screen
                myShape.Draw();

                if (SwinGame.MouseClicked(MouseButton.LeftButton))
                {
                    myShape.X = Input.MousePosition().X;
                    myShape.Y = Input.MousePosition().Y;
                }

                //Draw onto the screen
                SwinGame.RefreshScreen(60);
            }
        }
Пример #3
0
        public static void Main()
        {
            //Open the game window
            SwinGame.OpenGraphicsWindow("GameMain", 800, 600);
            SwinGame.ShowSwinGameSplashScreen();

            Shape myShape = new Shape();

            //Run the game loop
            while (false == SwinGame.WindowCloseRequested())
            {
                //Fetch the next batch of UI interaction
                SwinGame.ProcessEvents();

                // If the user clicks the LeftButton on their mouse, set the shapes x, y to be at the mouse's position
                if (SwinGame.MouseClicked(MouseButton.LeftButton))
                {
                    myShape.X = SwinGame.MouseX();
                    myShape.Y = SwinGame.MouseY();
                }

                // If the mouse is over the shape and the user presses the spacebar, then change the color of the shape to a random color
                if (myShape.isAt(SwinGame.MousePosition()))
                {
                    if (SwinGame.KeyTyped(KeyCode.SpaceKey))
                    {
                        myShape.Color = SwinGame.RandomRGBColor(255);
                    }
                }

                //Clear the screen and draw the framerate
                SwinGame.ClearScreen(Color.White);
                myShape.Draw();
                SwinGame.DrawFramerate(0, 0);

                //Draw onto the screen
                SwinGame.RefreshScreen(60);
            }
        }