DEV Community

Aditya Mishra
Aditya Mishra

Posted on

From Python to Physics: How I Built a Chrome Dino Clone in 24 Hours (Scaler YIIC Task 5)

๐ŸŽฎ From AI to Game Dev

As a Python and AI developer (and a Class 12 student), I usually live in the world of data pipelines and backend logic. But for Task 5 of the Scaler Young India Innovation Challenge (YIIC 6.0), we were thrown a curveball: Game Development.

Our assignment? Recreate the iconic Chrome Dino Run game using the Unity Engine.

This was a massive shift from my usual tech stack. Here is how I built the physics, the logic, and the "Infinite Spawner" system from scratch.

๐Ÿ› ๏ธ The Setup

I used Unity 6 (LTS) with the 2D Core template. The goal was to keep it lightweight but functional.

Core Components:

  1. The Dino: A sprite with a Rigidbody2D (for gravity) and a BoxCollider2D (to detect hits).
  2. The Ground: A static object tagged as "Ground" so the Dino knows when it can jump.
  3. The Enemy: A Red Triangle spike that moves relentlessly to the left using a Kinematic body.

๐Ÿ’ป The Logic (C# Scripting)

The hardest part wasn't the graphics; it was the physics and the logic.

1. The Jumping Logic

I had to ensure the Dino couldn't "double jump" or fly away. I used Unity's Tagging system (CompareTag) to check if the player was touching the ground before allowing a jump.

// Simple Jump Logic
if (Input.GetKeyDown(KeyCode.Space) && isGrounded)
{
    rb.velocity = Vector2.up * jumpForce;
    isGrounded = false;
}
Enter fullscreen mode Exit fullscreen mode

2. The "Homework" Challenge: Infinite Spawning

The session taught us how to make one enemy manually. But a real game needs infinite enemies. We were tasked with figuring out the "Spawner" logic ourselves.

I solved this by creating a Spawner.cs script that utilizes Time.deltaTime. Every 2 seconds, it "Instantiates" (clones) the enemy Prefab at the edge of the screen.

// The Spawner Logic
void Update()
{
    timer += Time.deltaTime;
    if (timer >= spawnRate)
    {
        SpawnEnemy();
        timer = 0f; // Reset timer
    }
}
Enter fullscreen mode Exit fullscreen mode

๐Ÿ”ง Refining the Feel

At first, the game felt "floaty"โ€”the Dino stayed in the air too long and was hard to control.

The Fix:

  • I increased the Gravity Scale on the Rigidbody to 3.
  • I adjusted the Jump Force to 7.

This made the movement snappy and responsive, just like the real Chrome game.

๐Ÿš€ Conclusion

This task proved that engineering principles transfer across domains. Whether it's Python for AI or C# for Unity, it's all about breaking down a big problem (a game) into small, solvable logic blocks (gravity, collision, loops).

Task 5 Complete! Next stop: Final Submission.

ScalerYIIC #GameDev #Unity #StudentDeveloper #CodingJourney

Top comments (0)