Breakdown · Solo project
Pinnable
A 2D arcade score-attack game. You steer a metal bucket along the base of the screen with the mouse, catch the marbles fired from a moving cannon, dodge the pins raining down, and push for a high score as the game steadily raises the pressure the longer you last.
- Scale33 scripts · ~2,400 lines
- Board64 pins
- Power-ups3, ten seconds each
- Lives3
Overview
One loop that gets harder as you score
Pinnable is a single-screen arcade game with one goal: survive and score for as long as you can. A cannon at the top of the screen fires marbles, you catch them in the bucket to bank points, and a board of pins supplies both the hazards and the opportunities. There is no level select and no story. The whole game is the loop, and the loop is built to grow harder in step with how well you are doing.
Underneath, it is a handful of small systems that each do one job: a spawn director that decides what the game throws at you, per-pin behaviour that decides how those hazards move, and a physics catch loop that carries the moment-to-moment feel.
Difficulty
A weighted spawn director
Difficulty is decided per pin. Each pin rolls its own type from a weighted random pool, and those weights are gated two ways: hazardous types stay locked until you pass a survival-time threshold, after which their weight scales with your score. The better you play, the more hazards the pool deals.
The first time a newly unlocked type is due to appear, its weight is spiked so the introduction is guaranteed, then it settles back to normal scaling. A new threat always announces itself cleanly rather than hiding inside a random roll.
private void SetPinType()
{
if (PlayerController.playercontroller.TimeAlive > 40) // Minimum time to pass before this pin can begin spawning
{
RedPinWeight = 1 + (int)Math.Floor(Main.main.Points / 240f); // Sets the weight (spawn likelyhood), correlating directly with the player's points
if (Main.main.RedIntroduced == false) // If the pin hasn't been introduced after it's become allowed to spawn, this runs
{
RedPinWeight = 999999; // Guarentees the introduction of this pin after the Time Alive exceeds the value
}
}
else
{
RedPinWeight = 0;
}
Hazards
Pins with behaviour of their own
Some hazards move. Once bumped, homing pins turn continuously to face the player and accelerate as they close, so ignoring one becomes a slowly tightening trap. Drill pins watch the player's position, charge up when you line up beneath them, then bore downward with an accelerating fall and a slowdown zone that reads as grinding through the floor.
Each behaviour is one routine tied to its own animation state.
if (HomingActivated == true)
{
// ... sound effect omitted
if (transform.position.y > -1)
{
anim.SetBool("isActiveHomingRedPin", true);
transform.right = PlayerController.playercontroller.PlayerPosition - transform.position;
}
else
{
anim.SetBool("isEndingActiveHomingRedPin", true);
}
if (HomingWindup > 0)
{
HomingWindup -= Time.deltaTime;
AppliedJitter = (Vector3)(UnityEngine.Random.insideUnitCircle * 0.06f);
}
else
{
transform.Translate((HomingAcceleration * HomingSpeed) * Time.deltaTime, 0, 0);
HomingAcceleration *= 1 + Time.deltaTime;
}
}
Game feel
A physics catch loop, and the feel around it
Marbles are Rigidbody2D objects. They launch from the cannon with a velocity biased by both the player's position and the cannon's own lateral movement, arc across the screen, and bounce off the bucket. The fire rate tightens over time, so the screen grows busier the longer you survive.
The bucket itself is layered from small effects: velocity-proportional sway and tilt, clamped so it never flips; a wheel that rotates with movement; a hull sprite that swaps with the tilt angle; and a cursor-follow drive that scales speed with distance to the pointer. Sitting over all of that are three ten-second power-ups, including a zero-gravity mode that rewrites the world's gravity for its duration.
In hindsight
What I'd change
This is the oldest project here, and the excerpt above shows it. Every hazard type repeats that block with its own numbers typed in. One table of thresholds, an unlock time and a score step for each type, would replace all of the copies with one loop.
The guaranteed introduction works by setting a weight to
999999, which is a number standing in for a rule. A
flag that says "this type goes next" would say what it means. And
every pin reaches for Main.main and
PlayerController.playercontroller directly, so
nothing in the director can be run without the whole game around
it.