Пример #1
0
        public void Update()
        {
            var delta = Raylib.GetFrameTime();

            if (Raylib.IsMouseButtonPressed(MouseButton.MOUSE_LEFT_BUTTON))
            {
                dir = Vector2.Normalize(Raylib.GetMousePosition() - position);
            }
            if (Raylib.IsMouseButtonDown(MouseButton.MOUSE_LEFT_BUTTON))
            {
                velocityY = 0;

                var lineEnd = position + dir * 10000;
                Raylib.DrawLine((int)position.X, (int)position.Y, (int)lineEnd.X, (int)lineEnd.Y, Color.RED);
            }
            else
            {
                velocityY  += gravity * delta;
                position.Y += velocityY * delta;
            }

            position += dir * speed * delta;

            Raylib.DrawCircle((int)position.X, (int)position.Y, 30, Color.WHITE);
        }
Пример #2
0
 public void Draw()
 {
     Raylib.DrawCircle(110, 260, 30f, lightGreen);
     Raylib.DrawCircle(900, 260, 30f, lightGreen);
     Raylib.DrawCircle(110, 700, 30f, lightGreen);
     Raylib.DrawCircle(900, 700, 30f, lightGreen);
 }
Пример #3
0
        void DrawSelectedPiece(ChessPiece selected)
        {
            if (selected == null)
            {
                return;
            }

            float xPos = board.pos.X + selected.GetCol() * board.tileSize;
            float yPos = board.pos.Y + selected.GetRow() * board.tileSize;

            Raylib.DrawRectangleLinesEx(new Rectangle(xPos, yPos, board.tileSize, board.tileSize), 3, Color.BLACK);

            // for the selected tile.
            // Draw a circle in the valid squares that it can move to.
            for (int y = 0; y < 8; y++)
            {
                for (int x = 0; x < 8; x++)
                {
                    if (selected.IsValidMove(y, x))
                    {
                        xPos = board.pos.X + x * board.tileSize + (board.tileSize / 2.0f);
                        yPos = board.pos.Y + y * board.tileSize + (board.tileSize / 2.0f);
                        Raylib.DrawCircle((int)xPos, (int)yPos, 4, Color.BLACK);
                    }
                }
            }
        }
Пример #4
0
        //Draw aiming indicator and character
        static void AimIndicator(Vector2 direc, Texture2D character)
        {
            int aimX = (int)(500 + direc.X);
            int aimY = (int)(750 - direc.Y);

            Raylib.DrawCircle(aimX, aimY, 20, Color.BLACK);
            Raylib.DrawTexture(character, 455, 690, Color.WHITE);
        }
Пример #5
0
        public void Draw()
        {
            var vecdir = Util.AngleToVec(direction, 1);

            Raylib.DrawCircle((int)position.X, (int)position.Y, radius, color);
            //Raylib.DrawLineEx(position, position + vecdir * radius, 1, Color.BLACK);
            //Raylib.DrawCircleLines((int)position.X, (int)position.Y, effectRadius, color);
        }
Пример #6
0
 public void Draw()
 {
     Raylib.DrawCircle((int)Position.X, (int)Position.Y, Size, this.GetColor());
     Raylib.DrawText(this.Health.ToString(), (int)Position.X - (2 * this.Health.ToString().Length), (int)Position.Y - 4, 6, this.GetHighlightColor());
     if (Selected)
     {
         Raylib.DrawCircleLines((int)Position.X, (int)Position.Y, Size + 2, this.GetHighlightColor());
     }
 }
Пример #7
0
        public void Draw()
        {
            Raylib.DrawCircle((int)position.X, (int)position.Y, playerRadius, Color.YELLOW);

            if (Raylib.IsKeyDown(KeyboardKey.KEY_RIGHT_CONTROL))
            {
                DebugDraw();
            }
        }
Пример #8
0
 static void player(int playerX, int playerY)
 {
     Raylib.DrawRectangle(playerX - 8, playerY - 60, 15, 50, Color.GRAY);
     Raylib.DrawCircle(playerX, playerY, 33, Color.BLUE);
     Raylib.DrawCircle(playerX + 12, playerY - 13, 10, Color.WHITE);
     Raylib.DrawCircle(playerX - 12, playerY - 13, 10, Color.WHITE);
     Raylib.DrawCircle(playerX + 12, playerY - 16, 5, Color.BLACK);
     Raylib.DrawCircle(playerX - 12, playerY - 16, 5, Color.BLACK);
 }
Пример #9
0
 static void enemy(Vector2 enemy)
 {
     Raylib.DrawRectangle((int)enemy.X + 10, (int)enemy.Y - 50, 10, 35, Color.GREEN);
     Raylib.DrawRectangle((int)enemy.X - 20, (int)enemy.Y - 50, 10, 35, Color.GREEN);
     Raylib.DrawCircle((int)enemy.X, (int)enemy.Y, 30, Color.GREEN);
     Raylib.DrawCircle((int)enemy.X + 12, (int)enemy.Y - 13, 10, Color.WHITE);
     Raylib.DrawCircle((int)enemy.X - 12, (int)enemy.Y - 13, 10, Color.WHITE);
     Raylib.DrawCircle((int)enemy.X + 12, (int)enemy.Y - 16, 5, Color.RED);
     Raylib.DrawCircle((int)enemy.X - 12, (int)enemy.Y - 16, 5, Color.RED);
 }
Пример #10
0
        public override void Draw()
        {
            //Color c = new Color(255, 255, 255, 100);

            //Raylib.DrawCircle((int)pos.X, (int)pos.Y, radius, Color.WHITE);

            Color color = asteroidCollisionPlayer ? asteroidHitColour : asteroidCurrentColour;

            Raylib.DrawCircle((int)pos.X, (int)pos.Y, radius, color);
        }
Пример #11
0
 public void Render()
 {
     _engine.DoPhysics();
     foreach (var b in _balls)
     {
         b.Update();
         Raylib.DrawCircle(b.Ellipse.X, b.Ellipse.Y, (int)b.Ellipse.Width, b.Ellipse.Fill);
         Raylib.DrawCircleLines(b.Ellipse.X, b.Ellipse.Y, (int)b.Ellipse.Width, Color.WHITE);
     }
 }
Пример #12
0
 public static void DrawCircle(Vector2 Pos, float Radius, Color Clr, bool Outline = true)
 {
     if (Outline)
     {
         Raylib.DrawCircleLines((int)Pos.X, (int)Pos.Y, Radius, Clr);
     }
     else
     {
         Raylib.DrawCircle((int)Pos.X, (int)Pos.Y, Radius, Clr);
     }
 }
Пример #13
0
        public override void draw()
        {
            if (Raylib.GetTime() >= time + frameTime)
            {
                ChangeFrame();
                time = Raylib.GetTime();
            }

            Raylib.DrawCircle((int)position.X, (int)position.Y, radius, new Color(255, 0, 0, 128));
            //Raylib.DrawTextureEx(frames[currentFrame], new Vector2(position.X - 128, position.Y - 128), 0, 1f, Color.WHITE);
        }
Пример #14
0
        public void DebugDraw()
        {
            //translate player position into row / col value
            var rect = level.GetTileRect(position);

            Raylib.DrawRectangleLinesEx(rect, 3, Color.YELLOW);

            Raylib.DrawCircle((int)startTilePos.X, (int)startTilePos.Y, 3, Color.RED);
            Raylib.DrawCircle((int)endTilePos.X, (int)endTilePos.Y, 3, Color.RED);
            Raylib.DrawLineEx(startTilePos, endTilePos, 3, Color.RED);
            Raylib.DrawCircle((int)position.X, (int)position.Y, 2, Color.BLACK);
        }
Пример #15
0
        //Draw/move objects and handle collisions
        static void HandleObjects(List <Bullet> bulletList, List <Obstacle> obstacleList, Game game)
        {
            //Draw/move bullets
            foreach (Bullet shot in bulletList)
            {
                Raylib.DrawCircle((int)shot.pos.X, (int)shot.pos.Y, 15, Color.GREEN);
                shot.pos.X += shot.xSpeed / 6;
                shot.pos.Y -= shot.ySpeed / 6;
            }

            //Draw/move obstacles and check all possible collisions
            //To remove objects from these lists using loops, it is required to go through for-loops in reverse
            for (int i = obstacleList.Count - 1; i >= 0; i--)
            {
                Obstacle enemy = obstacleList[i];
                int      sizeX = 80;
                int      sizeY = 120;
                enemy.color = new Color(255, enemy.red, enemy.red, 255);
                enemy.box   = new Rectangle(enemy.pos.X + 20, enemy.pos.Y, sizeX, sizeY);
                Raylib.DrawTexture(enemy.image, (int)enemy.pos.X, (int)enemy.pos.Y, enemy.color);
                enemy.pos.X += enemy.xSpeed;
                enemy.pos.Y += enemy.ySpeed;

                //If collision is detected, remove bullet and damage obstacle.
                for (int x = bulletList.Count - 1; x >= 0; x--)
                {
                    if (Raylib.CheckCollisionCircleRec(bulletList[x].pos, 15, enemy.box))
                    {
                        bulletList.RemoveAt(x);
                        enemy.hp -= 1;
                        enemy.red = 155;
                    }
                }

                //Make obstacle less red by increasing green and blue. If more green/blue than 255, make it 255.
                enemy.red += 15;
                if (enemy.red > 255)
                {
                    enemy.red = 255;
                }
                //Make obstacle bounce at borders
                if (enemy.pos.X > 900 || enemy.pos.X < 0)
                {
                    enemy.xSpeed = -enemy.xSpeed;
                }
                //Remove obstacle if its HP is 0
                if (enemy.hp < 1)
                {
                    obstacleList.Remove(enemy);
                    game.money += 100;
                }
            }
        }
Пример #16
0
        void Draw()
        {
            //DRAWING Logic
            Raylib.BeginDrawing();
            Raylib.ClearBackground(Color.DARKGRAY);

            Raylib.DrawCircle((int)ball.pos.X, (int)ball.pos.Y, ball.radius, Color.RAYWHITE);


            Raylib.DrawFPS(10, 10);

            Raylib.EndDrawing();
        }
Пример #17
0
        static void trainmove(Train trainMove, Track trackNow)
        {
            for (int i = 0; i < trackNow.stopOrder.Count; i++)
            {
                Raylib.DrawCircle((int)trackNow.stopOrder[i].xy.X, (int)trackNow.stopOrder[i].xy.Y, trackNow.size, trackNow.stopOrder[i].stopColor);
                Raylib.DrawRectangle((int)trainMove.xy.X, (int)trainMove.xy.Y, 50, 20, Color.BLACK);
                Vector2 k = trainMove.xy - trackNow.stopOrder[i].xy;

                Vector2 n = Vector2.Normalize(k);

                n = n * trainMove.speed;
            }
        }
Пример #18
0
 public void RenderDebug()
 {
     //
     // draw full rectangle
     //
     //Rectangle rt = new Rectangle(CollisionBox.min.X, CollisionBox.min.Y, boxContainer.width, boxContainer.height);
     //Raylib.DrawRectangleLines((int)rt.x, (int)rt.y,
     //					 (int)rt.width, (int)rt.height,
     //					 Color.RED);
     Raylib.DrawCircle((int)boxContainer.x, (int)boxContainer.y, Radius * RadiusMultiplier, Color.RED);
     //Raylib.DrawCircle((int)CollisionBox.min.X, (int)CollisionBox.min.X, 5, Color.GRAY);
     //Raylib.DrawCircle(Convert.ToInt32(CollisionBox.max.X), Convert.ToInt32(CollisionBox.max.Y), 5, Color.BLACK);
 }
Пример #19
0
        public void Draw()
        {
            Raylib.DrawCircle(
                (int)Pos.X,
                (int)Pos.Y,
                size,
                Color.DARKPURPLE
                );

            Raylib.DrawCircleLines(
                (int)Pos.X,
                (int)Pos.Y,
                size + 2,
                Color.PURPLE
                );
        }
Пример #20
0
        static void Main(string[] args)
        {
            Raylib.InitWindow(1800, 1000, "Hello TE!");

            Image     xWing        = Raylib.LoadImage(@"XWing.png");
            Texture2D xWingTexture = Raylib.LoadTextureFromImage(xWing);

            float x = 0;
            float y = 0;

            while (!Raylib.WindowShouldClose())
            {
                if (Raylib.IsKeyDown(KeyboardKey.KEY_D))
                {
                    x += 1f;
                }

                if (Raylib.IsKeyDown(KeyboardKey.KEY_A))
                {
                    x -= 1f;
                }

                if (Raylib.IsKeyDown(KeyboardKey.KEY_S))
                {
                    y += 1f;
                }

                if (Raylib.IsKeyDown(KeyboardKey.KEY_W))
                {
                    y -= 1f;
                }

                Raylib.BeginDrawing();

                Raylib.ClearBackground(Color.BLACK);

                Raylib.DrawCircle(400, 300, 100, Color.GRAY);
                Raylib.DrawCircle(400, 300, 50, Color.DARKGRAY);


                Raylib.DrawTexture(xWingTexture, (int)x, (int)y, Color.WHITE);
                Raylib.EndDrawing();
            }
        }
Пример #21
0
        public void Draw()
        {
            Raylib.DrawCircle(
                (int)Position.X,
                (int)Position.Y,
                Size,
                this.GetColor()
                );

            if (Selected)
            {
                Raylib.DrawCircleLines(
                    (int)Position.X,
                    (int)Position.Y,
                    Size + 2,
                    this.GetHighlightColor()
                    );
            }
        }
Пример #22
0
        public void Update(List <Planet> planets)
        {
            var delta = Raylib.GetFrameTime();

            foreach (var planet in planets)
            {
                if (planet != this)
                {
                    var dir  = Vector2.Normalize(planet.position - position);
                    var dist = Vector2.Distance(planet.position, position);
                    if (dist != 0)
                    {
                        velocity += dir * planet.size / dist * delta;
                    }
                    position += velocity * delta;
                }
            }

            //Raylib.DrawCircleLines((int)position.X, (int)position.Y, orbitSize, Color.WHITE);
            Raylib.DrawCircle((int)position.X, (int)position.Y, size / 1000, Color.WHITE);
        }
Пример #23
0
        //DRAW METHOD
        public static void Draw(Ball ball, Block right, Block left, float midW)
        {
            //Middle line
            Raylib.DrawRectangle((int)((Window.windowW / 2) - (midW / 2)), 0, (int)midW, Window.windowH, Color.GRAY);

            //Score
            Raylib.DrawText(right.SC.ToString(), (Window.windowW / 2) - (Window.windowW / 4), 5, 250, Color.GRAY);

            Raylib.DrawText(left.SC.ToString(), (Window.windowW / 2) + (Window.windowH / 4), 5, 250, Color.GRAY);

            //Draw ball if within window borders
            if (ball.X > 0 && ball.X < Window.windowW)
            {
                Raylib.DrawCircle((int)ball.X, (int)ball.Y, ball.R, Color.WHITE);
            }

            //Blocks
            Raylib.DrawRectangle((int)right.X, (int)right.Y, right.W, right.H, Color.WHITE);

            Raylib.DrawRectangle((int)left.X, (int)left.Y, left.W, left.H, Color.WHITE);
        }
Пример #24
0
        private void DrawMap()
        {
            for (int row = 0; row < map.GetLength(0); row++)
            {
                for (int col = 0; col < map.GetLength(1); col++)
                {
                    var tileValue = GetTileValue(row, col);
                    var tileColor = GetTileColor(row, col);
                    var rect      = GetTileRect(row, col);

                    Raylib.DrawRectangleRec(rect, tileColor);

                    if (tileValue == TileType.DOT)
                    {
                        int pacDotSize = 2;
                        Raylib.DrawCircle
                            ((int)(rect.x + (rect.width / 2)),
                            (int)(rect.y + (rect.height / 2)),
                            pacDotSize, Color.WHITE);
                    }
                }
            }
        }
Пример #25
0
        static void Main(string[] args)
        {
            List <Enemy> enemies = new List <Enemy>();
            List <Block> mapList = new List <Block>();

            Raylib.InitWindow(800, 600, "");

            int mapTarget  = 0;
            int mapDisplay = 1;

            char[,] mapP1 =
            {
                { 'B', 'B', 'B', 'B', 'B', 'B', 'B', 'B', 'B', 'B', 'B', 'B', 'B', 'B', 'B', 'B', 'B', 'B', 'B', 'B' },
                { 'B', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 'B', ' ', ' ', 'B' },
                { 'B', ' ', ' ', ' ', ' ', 'B', 'B', 'B', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 'B' },
                { 'B', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 'B', ' ', ' ', 'B' },
                { 'B', ' ', ' ', ' ', ' ', 'B', 'B', 'B', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 'B' },
                { 'B', ' ', 'E', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 'E', ' ', ' ', 'B', ' ', ' ', 'B' },
                { 'B', ' ', ' ', ' ', ' ', 'B', 'B', 'B', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 'B' },
                { 'B', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 'B', ' ', ' ', 'B' },
                { 'B', ' ', ' ', ' ', ' ', 'B', 'B', 'B', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 'B' },
                { 'B', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 'P', ' ', ' ', ' ', ' ', ' ', ' ', 'B', ' ', ' ', 'B' },
                { 'B', ' ', ' ', ' ', ' ', 'B', 'B', 'B', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 'B' },
                { 'B', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 'B', ' ', ' ', 'B' },
                { 'B', ' ', ' ', ' ', ' ', 'B', 'B', 'B', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 'B' },
                { 'B', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 'B', ' ', ' ', 'B' },
                { 'B', ' ', ' ', ' ', ' ', 'B', 'B', 'B', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 'B' },
                { 'B', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 'B', ' ', ' ', 'B' },
                { 'B', ' ', ' ', ' ', ' ', 'B', 'B', 'B', ' ', ' ', ' ', 'E', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 'B' },
                { 'B', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 'B', ' ', ' ', 'B' },
                { 'B', ' ', ' ', ' ', ' ', 'B', 'B', 'B', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 'B' },
                { 'B', 'B', 'B', 'B', 'B', 'B', 'B', 'B', 'B', 'B', 'B', 'B', 'B', 'B', 'B', 'B', 'B', 'B', 'B', 'B' },
            };
            char[,] mapP2 =
            {
                { 'B', 'B', 'B', 'B', 'B', 'B', 'B', 'B', 'B', 'B', 'B', 'B', 'B', 'B', 'B', 'B', 'B', 'B', 'B', 'B' },
                { 'B', 'P', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 'B', ' ', ' ', 'B' },
                { 'B', ' ', ' ', ' ', ' ', 'B', 'B', 'B', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 'B' },
                { 'B', ' ', ' ', ' ', 'B', ' ', ' ', ' ', 'B', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 'B', ' ', ' ', 'B' },
                { 'B', ' ', ' ', ' ', ' ', 'B', 'B', 'B', ' ', ' ', 'B', ' ', 'B', ' ', ' ', ' ', ' ', ' ', ' ', 'B' },
                { 'B', ' ', ' ', ' ', ' ', ' ', 'B', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 'B', ' ', ' ', 'B' },
                { 'B', ' ', 'E', ' ', ' ', 'B', 'B', 'B', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 'B' },
                { 'B', ' ', ' ', ' ', ' ', ' ', 'B', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 'B', ' ', ' ', 'B' },
                { 'B', ' ', ' ', ' ', ' ', 'B', 'B', 'B', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 'B' },
                { 'B', ' ', ' ', ' ', ' ', ' ', 'B', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 'B', ' ', 'E', 'B' },
                { 'B', ' ', ' ', ' ', ' ', 'B', 'B', 'B', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 'B' },
                { 'B', ' ', ' ', ' ', ' ', ' ', 'B', 'E', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 'B', ' ', ' ', 'B' },
                { 'B', ' ', ' ', ' ', ' ', 'B', 'B', 'B', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 'B' },
                { 'B', ' ', ' ', ' ', ' ', ' ', 'B', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 'B', ' ', ' ', 'B' },
                { 'B', ' ', ' ', ' ', ' ', 'B', 'B', 'B', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 'B' },
                { 'B', ' ', ' ', ' ', ' ', ' ', 'B', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 'B', ' ', ' ', 'B' },
                { 'B', ' ', ' ', ' ', ' ', 'B', 'B', 'B', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 'B' },
                { 'B', ' ', ' ', ' ', ' ', ' ', 'B', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 'B', ' ', ' ', 'B' },
                { 'B', ' ', ' ', ' ', ' ', 'B', 'B', 'B', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 'B' },
                { 'B', 'B', 'B', 'B', 'B', 'B', 'B', 'B', 'B', 'B', 'B', 'B', 'B', 'B', 'B', 'B', 'B', 'B', 'B', 'B' },
            };
            float playerY = 5;
            float playerX = 5;

            float[,] playerPos =
            {
                { playerX },
                { playerY },
            };
            int       mapScale        = 10;
            float     playerXSpeed    = 0f;
            float     playerYSpeed    = 0f;
            float     playerSpeedIncr = 0.0001f;
            float     playerSpeedDecr = 0.0001f;
            bool      playerLock      = false;
            int       playerStill     = 0;
            float     SpeedX          = 0;
            float     SpeedY          = 0;
            float     Xknow           = 1;
            float     Yknow           = 1;
            int       offsetX         = 50;
            int       offsetY         = 50;
            bool      collision       = false;
            mapSelect map             = mapSelect.map0;

            while (!Raylib.WindowShouldClose())
            {
                //Map selector
                if (mapTarget == 0)
                {
                    switch (mapDisplay)
                    {
                    case 1:
                        map = mapSelect.map1;
                        for (int y = 0; y < mapP1.GetLength(0); y++)
                        {
                            for (int x = 0; x < mapP1.GetLength(1); x++)
                            {
                                if (mapP1[y, x] == 'B')
                                {
                                    mapList.Add(new Block(new Vector2(20 * x, 20 * y), new Vector2(20 * x, 20 * y)));
                                }
                                else if (mapP1[y, x] == 'E')
                                {
                                    enemies.Add(new Enemy(new Vector2(offsetX + x * mapScale, offsetY + y * mapScale), new Vector2(3, 3)));
                                }
                            }
                        }
                        Console.WriteLine("map1");

                        break;

                    case 2:
                        map = mapSelect.map2;
                        break;

                    default:
                        Raylib.DrawText("Text Not found.", 200, 100, 50, Color.RED);
                        break;
                    }
                    mapDisplay++;
                    mapTarget = 1;
                }
                //Drawing begins
                Raylib.BeginDrawing();


                Raylib.ClearBackground(Color.GREEN);
                #region Bad code
                // //map writeing
                // for (int y = 0; y < mapP1.GetLength(0); y++)
                // {
                //     for (int x = 0; x < mapP1.GetLength(1); x++)
                //     {
                //         if (map == mapSelect.map1)
                //         {
                //             //Blocks
                //             if (mapP1[y, x] == 'B')
                //             {
                //                 Raylib.DrawRectangle(offsetX + x * mapScale, offsetY + y * mapScale, 10, 10, Color.BLACK);
                //             }
                //             //Player
                //             else if (mapP1[y, x] == 'P')
                //             {
                //                 if (playerLock == false)
                //                 {
                //                     playerY = offsetY + y * mapScale;
                //                     playerX = offsetX + x * mapScale;
                //                 }
                //                 playerLock = true;
                //                 Raylib.DrawCircle((int)playerX + 2, (int)playerY + 2, 3, Color.RED);
                //             }
                //             //Enemy
                //             else if (mapP1[y, x] == 'E')
                //             {

                //                 //enemies.Add(new Enemy(new Vector2(offsetX + x * mapScale, offsetY + y * mapScale), new Vector2(3, 3)));
                //             }
                //             else
                //             {

                //             }
                //         }
                //         else if (map == mapSelect.map2)
                //         {
                //             //Blocks
                //             if (mapP2[y, x] == 'B')
                //             {
                //                 Raylib.DrawRectangle(offsetX + x * mapScale, offsetY + y * mapScale, 10, 10, Color.BLACK);
                //             }
                //             //Player
                //             else if (mapP2[y, x] == 'P')
                //             {
                //                 if (playerLock == false)
                //                 {
                //                     playerY = offsetY + y * mapScale;
                //                     playerX = offsetX + x * mapScale;
                //                 }
                //                 playerLock = true;
                //                 Raylib.DrawCircle((int)playerX + 3, (int)playerY + 3, 3, Color.RED);
                //             }
                //             //Enemy
                //             else if (mapP2[y, x] == 'E')
                //             {
                //                 Raylib.DrawCircle(offsetX + x * mapScale + 3, offsetY + y * mapScale + 3, 3, Color.YELLOW);
                //             }
                //             else
                //             {

                //             }
                //         }
                //         else
                //         {
                //             Raylib.DrawText("Map Not found.", 200, 200, 50, Color.RED);
                //         }
                //     }
                // }
                #endregion
                for (int i = 0; i < enemies.Count; i++)
                {
                    enemies[i].Draw();
                }
                for (int i = 0; i < mapList.Count; i++)
                {
                    mapList[i].Draw();
                }

                if (Raylib.IsKeyDown(KeyboardKey.KEY_A))
                {
                    playerStill = 0;
                    playerX     = playerX + playerXSpeed;
                    if (playerXSpeed > -0.05)
                    {
                        playerXSpeed = playerXSpeed - playerSpeedIncr;
                    }
                }
                else if (Raylib.IsKeyDown(KeyboardKey.KEY_D))
                {
                    playerStill = 0;
                    playerX     = playerX + playerXSpeed;
                    if (playerXSpeed < 0.05)
                    {
                        playerXSpeed = playerXSpeed + playerSpeedIncr;
                    }
                }
                else
                {
                    if (playerXSpeed > 0)
                    {
                        playerStill++;
                        playerX      = playerX + playerXSpeed;
                        playerXSpeed = playerXSpeed - playerSpeedDecr;
                        if (playerStill > 1000)
                        {
                            playerXSpeed = 0;
                        }
                    }
                    if (playerXSpeed < 0)
                    {
                        playerStill++;
                        playerX      = playerX + playerXSpeed;
                        playerXSpeed = playerXSpeed + playerSpeedDecr;
                        if (playerStill > 1000)
                        {
                            playerXSpeed = 0;
                        }
                    }
                }
                if (Raylib.IsKeyDown(KeyboardKey.KEY_S))
                {
                    playerStill = 0;
                    playerY     = playerY + playerYSpeed;
                    if (playerYSpeed < 0.05)
                    {
                        playerYSpeed = playerYSpeed + playerSpeedIncr;
                    }
                }
                else if (Raylib.IsKeyDown(KeyboardKey.KEY_W))
                {
                    playerStill = 0;
                    playerY     = playerY + playerYSpeed;
                    if (playerYSpeed > -0.05)
                    {
                        playerYSpeed = playerYSpeed - playerSpeedIncr;
                    }
                }
                else
                {
                    if (playerYSpeed > 0)
                    {
                        playerStill++;
                        playerY      = playerY + playerYSpeed;
                        playerYSpeed = playerYSpeed - playerSpeedDecr;
                        if (playerStill > 1000)
                        {
                            playerYSpeed = 0;
                        }
                    }
                    if (playerYSpeed < 0)
                    {
                        playerStill++;
                        playerY      = playerY + playerYSpeed;
                        playerYSpeed = playerYSpeed + playerSpeedDecr;
                        if (playerStill > 1000)
                        {
                            playerYSpeed = 0;
                        }
                    }
                }
                //Sjukta
                if (Raylib.IsKeyDown(KeyboardKey.KEY_UP))
                {
                    SpeedY = -0.5f;
                    Yknow  = playerY - 3 + SpeedY;
                    Xknow  = playerX + 2;
                    SpeedX = 0;
                }

                else if (Raylib.IsKeyDown(KeyboardKey.KEY_DOWN))
                {
                    SpeedY = 0.5f;
                    Yknow  = playerY + 7 + SpeedY;
                    Xknow  = playerX + 2;
                    SpeedX = 0;
                }

                else if (Raylib.IsKeyDown(KeyboardKey.KEY_RIGHT))
                {
                    SpeedX = 0.5f;
                    Xknow  = playerX + 7 + SpeedX;
                    Yknow  = playerY + 2;
                    SpeedY = 0;
                }

                else if (Raylib.IsKeyDown(KeyboardKey.KEY_LEFT))
                {
                    SpeedX = -0.5f;
                    Xknow  = playerX - 3 + SpeedX;
                    Yknow  = playerY + 2;
                    SpeedY = 0;
                }
                Xknow = Xknow + SpeedX;
                Yknow = Yknow + SpeedY;
                Raylib.DrawCircle((int)Xknow, (int)Yknow, 2, Color.ORANGE);

                //Reload
                if (Raylib.IsKeyDown(KeyboardKey.KEY_ENTER))
                {
                    mapTarget    = 0;
                    playerLock   = false;
                    playerXSpeed = 0;
                    playerYSpeed = 0;
                    playerX      = 0;
                    playerY      = 0;
                }


                Raylib.EndDrawing();
            }
        }
Пример #26
0
    public void Start()
    {
        int cursorX = (int)Program.mousePos.X;
        int cursorY = (int)Program.mousePos.Y;

        //Mouse Cursor
        Raylib.DrawCircle(cursorX, cursorY, 5, Color.GREEN);

        //Play Butten Texture
        Raylib.DrawTexturePro(
            Textures.playButtonTexture,
            new Rectangle(0, 0, 512, 512),                                             // Source
            new Rectangle(playButton.X, playButton.Y, playButtonSize, playButtonSize), // Dest(ination)
            new Vector2(playButtonSize / 2, playButtonSize / 2),                       // Origin
            Player.rotation,
            Color.WHITE);
        //Select & Press Start Button Functions
        bool leftButtonPressed = Raylib.IsMouseButtonPressed(MouseButton.MOUSE_LEFT_BUTTON);

        playButtonSelected = Raylib.CheckCollisionCircles(playButton, playButtonSize / 2, Program.mousePos, 1);
        if (playButtonSelected == true && leftButtonPressed == true) //Selected & Pressed
        {
            queStart = true;
            Raylib.SetSoundVolume(Assets.playSound, 0f);
            Raylib.PlaySound(Assets.playSound);
            Textures.stevePos.X -= 800;
        }
        else if (playButtonSelected == true) //Selected
        {
            Raylib.SetSoundVolume(Assets.playSound, 1f);
            Raylib.SetSoundVolume(Assets.playButtonSelectSound, 1f);
            Raylib.ClearBackground(Assets.lighterColor);
            playButtonSize = 250;
            Texture.IntentionalBug();
        }
        else //Not Selected
        {
            Textures.steveModifier = 0;
            Raylib.SetSoundVolume(Assets.playButtonSelectSound, 0f);
            Raylib.PlaySound(Assets.playButtonSelectSound);
            playButtonSize = 200;
        }
        //Game Start Delay
        if (queStart == true)
        {
            startDelayCurrentValue--;
            if (startDelayCurrentValue <= 0)
            {
                playButtonSize         = 150;
                Program.State          = "Game";
                startDelayCurrentValue = startDelayMaxValue;
            }
        }

        //Guide Butten Texture
        Raylib.DrawTexturePro(
            Textures.guideButtonTexture,
            new Rectangle(0, 0, 516, 516),                                                 // Source
            new Rectangle(guideButton.X, guideButton.Y, guideButtonSize, guideButtonSize), // Dest(ination)
            new Vector2(guideButtonSize / 2, guideButtonSize / 2),                         // Origin
            Player.rotation,
            Color.WHITE);
        //Select & Press Guide Button Functions
        guideButtonSelected = Raylib.CheckCollisionCircles(guideButton, guideButtonSize / 2, Program.mousePos, 1);
        if (guideButtonSelected == true && leftButtonPressed == true) //Selected & Pressed
        {
            queStart = true;
            Raylib.SetSoundVolume(Assets.guideSound, 0f);
            Raylib.PlaySound(Assets.guideSound);
        }
        else if (guideButtonSelected == true) //Selected
        {
            Raylib.SetSoundVolume(Assets.guideSound, 1f);
            Raylib.SetSoundVolume(Assets.guideButtonSelectSound, 1f);
            Raylib.ClearBackground(Assets.lighterColor);
            guideButtonSize = 250;
        }
        else //Not Selected
        {
            Raylib.SetSoundVolume(Assets.guideButtonSelectSound, 0f);
            Raylib.PlaySound(Assets.guideButtonSelectSound);
            guideButtonSize = 200;
        }
    }
Пример #27
0
        static void Main(string[] args)
        {
            int screenWidth  = 1920;
            int screenHeight = 1000;

            Raylib.InitWindow(screenWidth, screenHeight, "5000 IQ GAME");
            Raylib.SetTargetFPS(60);

            string gamestate = "level1";

            Rectangle startButton = new Rectangle(900, 350, 90, 30);

            Rectangle tree = new Rectangle(1230, 300, 400, 600);

            Rectangle apple = new Rectangle(1500, 350, 50, 50);

            bool appleIsReal = false;

            Rectangle answer2 = new Rectangle(360, 360, 50, 50);


            //KOMPONENTERNA I LISTEN
            List <Rectangle> rectangles = new List <Rectangle>();

            rectangles.Add(new Rectangle(10, 10, 20, 20));
            rectangles.Add(new Rectangle(20, 20, 20, 20));
            rectangles.Add(new Rectangle(30, 30, 20, 20));
            rectangles.Add(new Rectangle(40, 40, 20, 20));



            //VAD SOM HÄNDER NÄR VI ÄR INNE I SPELET
            while (!Raylib.WindowShouldClose())
            {
                if (gamestate == "level1")
                {
                    //LOGIK
                    //OM MAN KLICKAR PÅ startbutton SÅ BYTER VI TILL level2
                    if (Raylib.CheckCollisionPointRec(Raylib.GetMousePosition(), startButton) && Raylib.IsMouseButtonPressed(MouseButton.MOUSE_LEFT_BUTTON))
                    {
                        gamestate = "level2";
                    }
                    //DRAW
                    Raylib.BeginDrawing();
                    Raylib.ClearBackground(Color.WHITE);


                    Raylib.DrawRectangleRec(startButton, Color.WHITE);
                    Raylib.DrawText("5000 IQ TEST", 250, 150, 200, Color.BLACK);
                    Raylib.DrawText("Press PLAY to begin", 800, 350, 30, Color.BLACK);
                    Raylib.DrawText("PLAY", 1000, 680, 130, Color.MAGENTA);
                    Raylib.DrawText("PLAY", 100, 600, 100, Color.BLUE);
                    Raylib.DrawText("PLAY", 500, 800, 80, Color.GREEN);
                    Raylib.DrawText("PLAY", 800, 500, 90, Color.RED);
                    Raylib.DrawText("PLAY", 1600, 650, 110, Color.YELLOW);

                    Raylib.EndDrawing();
                }

                else if (gamestate == "level2")
                {
                    //LOGIK

                    if (Raylib.CheckCollisionPointRec(Raylib.GetMousePosition(), tree) && Raylib.IsMouseButtonPressed(MouseButton.MOUSE_LEFT_BUTTON))
                    {
                        appleIsReal = true;
                    }

                    if (Raylib.CheckCollisionPointRec(Raylib.GetMousePosition(), answer2) && Raylib.IsMouseButtonPressed(MouseButton.MOUSE_LEFT_BUTTON))
                    {
                        gamestate = "level3";
                    }


                    //DRAW
                    Raylib.BeginDrawing();
                    Raylib.ClearBackground(Color.WHITE);
                    Raylib.DrawRectangle(1400, 600, 60, 300, Color.BROWN);
                    Raylib.DrawCircle(1430, 500, 200, Color.DARKGREEN);
                    Raylib.DrawRectangle(1480, 320, 50, 50, Color.RED);
                    Raylib.DrawRectangle(1300, 370, 50, 50, Color.RED);
                    Raylib.DrawRectangle(1400, 420, 50, 50, Color.RED);
                    Raylib.DrawRectangle(1350, 580, 50, 50, Color.RED);

                    DrawKeypad();
                    Raylib.DrawText("How many apples are in the tree?", 120, 250, 30, Color.BLACK);

                    //APPLE FALLING
                    if (appleIsReal)
                    {
                        Raylib.DrawRectangleRec(apple, Color.RED);
                    }

                    if (appleIsReal && apple.y < 600)
                    {
                        apple.y += 3;
                    }
                    Raylib.EndDrawing();
                }
                else if (gamestate == "level3")
                {
                    Raylib.BeginDrawing();
                    Raylib.ClearBackground(Color.WHITE);


                    //VI GÅR FRÅN 0 OCH GÅR UPP ETT STEG VARJE GÅNG TILLS REKTANGLARNA I LISTAN TAR S**T

                    for (int i = 0; i < rectangles.Count; i++)
                    {
                        Raylib.DrawRectangleRec(rectangles[i], Color.BLACK);
                    }

                    Raylib.EndDrawing();
                }
            }
        }
Пример #28
0
 // draw methods
 public static void DrawCircle(Circle circle, Color color)
 {
     Raylib.DrawCircle((int)circle.position.X, (int)circle.position.Y, circle.radius, color);
 }
Пример #29
0
 public override void Draw()
 {
     Raylib.DrawCircle((int)(WorldPosition.X * 32), (int)(WorldPosition.Y * 32), _collisionRadius * 32, _rayColor);
     Raylib.DrawText("GOAL", ((int)(WorldPosition.X * 32) - 100), ((int)(WorldPosition.Y * 32) - 75), 100, Color.BLUE);
     base.Draw();
 }
Пример #30
0
 void DrawBall(Ball b)
 {
     Raylib.DrawCircle((int)b.pos.X, (int)b.pos.Y, b.radius, Color.WHITE);
 }