PLATFORM
  • Tails

    Create websites with TailwindCSS

  • Blocks

    Design blocks for your website

  • Wave

    Start building the next great SAAS

  • Pines

    Alpine & Tailwind UI Library

  • Auth

    Plug'n Play Authentication for Laravel

  • Designer comingsoon

    Create website designs with AI

  • DevBlog comingsoon

    Blog platform for developers

  • Static

    Build a simple static website

  • SaaS Adventure

    21-day program to build a SAAS

Written By
Views

GTMK Game Jam - Unity C#

In the Game makers toolkit game jam I had the task of secondary programmer. I coded the gameplay loop of the player and the Monster AI. This game jam took 48 hours and we came in the top 1000 of over 5000 Link to itch: https://jflex.itch.io/the-dice-tower

The player script was simple, movement and fire a projectile.

The monsters where split between a big monster and smaller ones that ran at the player. The bigger monster had an issue where the monster would fire a projectile at the player, it was very easy for the player to dodge it, thus I coded the monster to always move above the player. This would mean that the projectile would have a better chance to hit the player.

Vector2 playerPosition = player.GetComponent<PlayerCharacter>().GetPosition();
monRigidbody.velocity = Vector2.zero;
if (Vector2.Distance(player.GetComponent<PlayerCharacter>().GetPosition(), monRigidbody.position) >= 0.5)
    {
        monRigidbody.velocity = Vector2.zero;
        Vector2 abovePl = new Vector2(playerPosition.x, playerPosition.y + 2.5f);
        monRigidbody.position = Vector2.MoveTowards(monRigidbody.position, abovePl, speed * Time.deltaTime);
    }
    

In the end I was proud with the result though pointed out to me, I failed to hold up to the principle of OOP via encapsulation, since I had many public variables instead of serialised private variables. Using public variables could lead to maliciously changing the variables contents. Since then I have been serialising private variables since.

Comments (0)

loading comments