Example #1
0
        public void DrawSelf()                                                                                               // Default draw, draws sprites from a sprite sheet( Which isn't actually used in game)
        {
            Rectangle destRectangle = new Rectangle(Position.x, Position.y, Dimensions.x * Scale.x, Dimensions.y * Scale.y); // Scales the drawn image

            if (new Vector2(Sprite.width, Sprite.height) == Dimensions)                                                      //Draw flat sprite, i.e not a sprite sheet
            {
                // new Raylib.Vector2 was the best work around i could find, i could use the basic draw class
                // but that doesnt allow rotation and stuff

                Rectangle imageRect = new Rectangle(0, 0, Dimensions.x + 1, Dimensions.y);
                DrawTexturePro(Sprite, MathMore.toRayRect(imageRect), MathMore.toRayRect(destRectangle), new Raylib.Vector2(Origin.x, Origin.y), Rotation, Blend);
            }
            else
            {
                float sheetXPos = Dimensions.x * ImageIndex;

                if (sheetXPos > Sprite.width) // Sets the animation back to first frame
                {
                    sheetXPos  = 0;
                    ImageIndex = 0;
                }

                Rectangle imageRect = new Rectangle(sheetXPos, 0, Dimensions.x + 1, Dimensions.y);
                DrawTexturePro(Sprite, MathMore.toRayRect(imageRect), MathMore.toRayRect(destRectangle), new Raylib.Vector2(Origin.x, Origin.y), Rotation, Blend);
            }
        }
Example #2
0
        public void GunDraw()
        {
            Rectangle ImageRect = new Rectangle(0, 0, GunSprite.width, GunSprite.height);                   // Image rectangle (Whole Image)
            Rectangle DestRect  = new Rectangle(Position.x, Position.y, ImageRect.width, ImageRect.height); // World Rect

            DrawTexturePro(GunSprite, MathMore.toRayRect(ImageRect), MathMore.toRayRect(DestRect), new Raylib.Vector2(GunOrigin.x, GunOrigin.y), GunRotation * RAD2DEG, Color.WHITE);

            DrawCircleLines((int)MousePos.x, (int)MousePos.y, 3, Color.BLACK);
        }
Example #3
0
        public override void Draw()
        {
            if (!BeenHit || HitTimer % 5 == 0)
            {
                DrawSelf();
                GunDraw();
            }

            //Draw HealthBar
            Rectangle PlayerHealthBack  = new Rectangle(8, 8, 96, Program.GameHeight * 0.05f);
            Rectangle PlayerHealthFront = new Rectangle(PlayerHealthBack.x, PlayerHealthBack.y, PlayerHealthBack.width, PlayerHealthBack.height);

            HP = (int)Clamp(HP, 0, MaxHp);
            PlayerHealthFront.width *= ((float)HP / (float)MaxHp);

            int Alpha = 255;

            DrawRectangleRec(MathMore.toRayRect(PlayerHealthBack), new Color(Color.DARKGRAY.r, Color.DARKGRAY.g, Color.DARKGRAY.b, Alpha));
            DrawRectangleRec(MathMore.toRayRect(PlayerHealthFront), new Color(Color.GREEN.r, Color.GREEN.g, Color.GREEN.b, Alpha));
            DrawRectangleLinesEx(MathMore.toRayRect(PlayerHealthBack), 1, new Color(Color.BLACK.r, Color.BLACK.g, Color.BLACK.b, Alpha));

            //Draw Dead Text
            if (HP <= 0)
            {
                DeadTimer++;
                Vector2 Pos = new Vector2(Program.GameWidth / 2, Program.GameHeight / 2);

                DrawRectangleRec(MathMore.toRayRect(new Rectangle(0, Pos.y - 8, Program.GameWidth, 16)), Color.BLACK);

                if (DeadTimer % 20 > 5)
                {
                    Raylib.Vector2 Measure = MeasureTextEx(Program.Romulus, "Dead", 12, 1);
                    DrawTextEx(Program.Romulus, "Dead", new Raylib.Vector2(Pos.x - (Measure.x / 2), Pos.y - (Measure.y / 2)), 12, 1, Color.WHITE);
                }

                if (!HasDied && DeadTimer > 60)
                {
                    gameScene.game.CurrentGameScene = new GameScene(gameScene.game);
                    HasDied = true;
                }
            }
        }