public void TestShapeAt()
        {
            Shape s = new Shape();

            s.X      = 25;
            s.Y      = 25;
            s.Width  = 50;
            s.Height = 50;

            Assert.IsTrue(s.IsAt(SwinGameSDK.SwinGame.PointAt(50, 50)));
            Assert.IsTrue(s.IsAt(SwinGameSDK.SwinGame.PointAt(25, 25)));
            Assert.IsFalse(s.IsAt(SwinGameSDK.SwinGame.PointAt(10, 50)));
            Assert.IsFalse(s.IsAt(SwinGameSDK.SwinGame.PointAt(50, 10)));
        }
        public void TestShapeWhenResized()
        {
            Shape s = new Shape();

            s.X      = 0;
            s.Y      = 0;
            s.Width  = 50;
            s.Height = 50;

            Assert.IsTrue(s.IsAt(SwinGameSDK.SwinGame.PointAt(25, 25)));

            s.Width  = 5;
            s.Height = 5;

            Assert.IsFalse(s.IsAt(SwinGameSDK.SwinGame.PointAt(25, 25)));
        }
Exemple #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 (SwinGame.MouseClicked(MouseButton.LeftButton))
                {
                    myShape.X = SwinGame.MousePosition().X;
                    myShape.Y = SwinGame.MousePosition().Y;
                }

                if (SwinGame.KeyDown(KeyCode.SpaceKey))
                {
                    if (myShape.IsAt(SwinGame.MousePosition()))
                    {
                        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);
            }
        }
        public MainGame()
        {
            SwinGame.OpenAudio();
            SwinGame.OpenGraphicsWindow("GameMain", 800, 600);
            SwinGame.ShowSwinGameSplashScreen();

            Shape myShape = new Shape();


            while (false == SwinGame.WindowCloseRequested())
            {
                SwinGame.ProcessEvents();

                SwinGame.ClearScreen(Color.White);
                SwinGame.DrawFramerate(0, 0);

                myShape.Drawshape();

                Point2D mouseLocation = SwinGame.MousePosition();

                if (SwinGameSDK.Input.MouseClicked(MouseButton.LeftButton))
                {
                    myShape.X = SwinGame.MouseX();
                    myShape.Y = SwinGame.MouseY();
                }
                if (myShape.IsAt(mouseLocation))
                {
                    if (SwinGame.KeyTyped(KeyCode.vk_SPACE))
                    {
                        myShape.Color = SwinGame.RandomRGBColor(255);
                    }
                }
                SwinGame.RefreshScreen();
            }

            SwinGame.CloseAudio();
            SwinGame.ReleaseAllResources();
        }