Example #1
0
        public void Update()
        {
            foreach (var s in springs)
            {
                s.Update();
            }

            foreach (var p in points)
            {
                if (Raylib.CheckCollisionCircleRec(p.position, 5, ground) && p.velocity.Y > 0)
                {
                    p.position.Y = ground.y;
                    p.velocity.Y = 0;
                }
            }

            foreach (var p1 in points)
            {
                foreach (var p2 in points)
                {
                    if (p1 != p2 && Raylib.CheckCollisionCircles(p1.position, springLength / collapseFactor, p2.position, springLength / collapseFactor))
                    {
                        var dir = p2.position - p1.position;
                        p1.velocity -= dir * Raylib.GetFrameTime();
                    }
                }
            }
        }
Example #2
0
    public static void Main(string[] args)
    {
        Raylib.InitWindow(w, h, "");
        Raylib.InitAudioDevice();
        Raylib.SetMasterVolume(1.0f);
        Raylib.SetTargetFPS(60);
        Raylib.SetExitKey(0);
        Raylib.SetWindowTitle("A Game");
        Image icon = Raylib.LoadImage(@"Images/Cola.png");

        Raylib.SetWindowIcon(icon);
        Bot            Bot        = new Bot();
        Player         P1         = new Player();
        Menu           Menus      = new Menu();
        PlayerMovement Controller = new PlayerMovement();
        Textures       Texture    = new Textures();

        rects.Add(new Rectangle());

        while (!Raylib.WindowShouldClose())
        {
            mousePos = Raylib.GetMousePosition();
            Raylib.BeginDrawing();
            Raylib.ClearBackground(Assets.bg);

            if (State == "Start")
            {
                Menus.Start();
                Texture.Steve();
            }
            if (State != "Start")
            {
                P1.Draw();
                Bot.AI();
                Texture.ShowPlayer();
                Menus.CheckWin();
            }
            if (State == "Game")
            {
                Controller.Move();
            }

            bool areOverlapping = Raylib.CheckCollisionCircles(Player.position, Player.playerSize / 2, Bot.position2, Player.playerSize / 2);
            if (areOverlapping == true)
            {
                Raylib.ClearBackground(Color.WHITE);
                Raylib.SetSoundVolume(Assets.screamSound, 1f);
            }
            else
            {
                Raylib.SetSoundVolume(Assets.screamSound, 0f);
                Raylib.PlaySound(Assets.screamSound);
            }
            Raylib.EndDrawing();
            UpdateVisual = true;
        }
    }
        private void DetectCrash()
        {
            foreach (var meteor in meteors.meteorTypesAndLocations)
            {
                int centerpointX = meteor.x + (int)((meteors.GetTexture(meteor.index).width / 2) * meteor.scale);
                int centerpointY = meteor.y + (int)((meteors.GetTexture(meteor.index).height - (meteors.GetTexture(meteor.index).height *(1 / 3))) * meteor.scale);
                int radius       = (int)((meteors.GetTexture(meteor.index).width / 2) * meteor.scale);

                if (Raylib.CheckCollisionCircles(new Vector2(centerpointX, centerpointY - radius), radius, new Vector2(x + 40, y + 45), (lunarModuleTexture.width * (0.20f)) / 2))
                {
                    avoidMeteorGame.gameComplete = true;
                }
            }
        }
Example #4
0
        static int health(Vector2 playerVec, Vector2 enemyVec, int playerHP, float damageTimer)
        {
            bool areOverlapping = Raylib.CheckCollisionCircles(playerVec, 33, enemyVec, 30);



            if (Raylib.IsKeyDown(KeyboardKey.KEY_M))
            {
                playerHP = +1;
            }



            while (areOverlapping && damageTimer == 0)
            {
                playerHP = -1;

                damageTimer += Raylib.GetFrameTime();
            }


            if (damageTimer >= 20000)
            {
                damageTimer = 0;
            }



            if (playerHP <= 0)
            {
                Raylib.DrawRectangle(0, 0, 1200, 800, Color.RED);
            }

            if (playerHP == 2)
            {
                Raylib.DrawRectangle(0, 0, 1200, 800, Color.YELLOW);
            }

            return(playerHP);
        }
Example #5
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;
        }
    }