static void Main(string[] args)
        {
            Raylib.InitWindow(800, 600, "Game engine");
            Raylib.SetTargetFPS(60);

            GameObject leftPaddle  = new Paddle(10, 275, KeyboardKey.KEY_W, KeyboardKey.KEY_S);
            GameObject rightPaddle = new Paddle(770, 275, KeyboardKey.KEY_UP, KeyboardKey.KEY_DOWN);

            Ball ball = new Ball();

            GameScreens screen = GameScreens.Start;

            while (!Raylib.WindowShouldClose())
            {
                // LOGIK
                if (screen == GameScreens.Start)
                {
                    if (Raylib.IsKeyPressed(KeyboardKey.KEY_ENTER))
                    {
                        screen = GameScreens.Game;
                    }
                }
                else if (screen == GameScreens.Game)
                {
                    GameObject.UpdateAll();
                }


                // ball.Update();

                // GRAFIK
                Raylib.BeginDrawing();

                if (screen == GameScreens.Start)
                {
                    Raylib.ClearBackground(Color.GRAY);
                    Raylib.DrawText("Press ENTER to start", 10, 10, 64, Color.BLACK);
                }
                else if (screen == GameScreens.Game)
                {
                    Raylib.ClearBackground(Color.GOLD);
                    GameObject.DrawAll();
                }



                // if (Raylib.CheckCollisionRecs(ballRect, ball2Rect))
                // {
                //   Raylib.DrawText("JA", 10, 500, 64, Color.BLACK);
                // }
                // else
                // {
                //   Raylib.DrawText("NEJ", 10, 500, 64, Color.BLACK);
                // }



                Raylib.EndDrawing();
            }
        }
        static void Main(string[] args)
        {
            Raylib.InitWindow(800, 600, "Spelmotor demo");
            Raylib.SetTargetFPS(60);

            Paddle leftPaddle  = new Paddle(10, 300, KeyboardKey.KEY_W, KeyboardKey.KEY_S);
            Paddle rightPaddle = new Paddle(770, 300, KeyboardKey.KEY_UP, KeyboardKey.KEY_DOWN);

            Ball ball = new Ball();

            while (!Raylib.WindowShouldClose())
            {
                GameObject.UpdateAll();

                Raylib.BeginDrawing();

                Raylib.ClearBackground(Color.GOLD);

                GameObject.DrawAll();

                Raylib.EndDrawing();
            }
        }
Exemplo n.º 3
0
        static void Main(string[] args)
        {
            Raylib.InitWindow(1000, 800, "Spelmotor demo"); //Sets the size and framerate of the game window
            Raylib.SetTargetFPS(60);

            Level testLevel = new Level("testLevel");          //Creates a level where the gameobjects can be drawn

            GameObject.currentLevel = testLevel;               //Sets GameObjects level variable to match the current level

            System.Console.WriteLine(GameObject.currentLevel); //Writes out the current level in the console

            Player p = new Player();                           //Creates a new level

            new Platform(0, 600, 1500, 200);                   //Creates two platforms of different sizes
            new Platform(300, 400, 500, 100);

            Level.camera.zoom   = 1f;                    //A zoom variable for the camera to work
            Level.camera.target = new Vector2(0, 0);     // Where the camera is pointed at
            Level.camera.offset = new Vector2(500, 400); //Makes sure tha camer is in the middle of the screen

            while (!Raylib.WindowShouldClose())          //The game loop that updates and draws all gamobjects in the current scene
            {
                GameObject.UpdateAll();


                GameObject.DrawAll();


                if (Level.changeLevel) //Functionality to change level manually inside of the program
                {
                    Level.LoadNextLevel();
                }
            }

            //testLevel.SaveLevel();
        }