Experience fast-paced gameplay with unique power-ups and collectible skins!
Unlock and upgrade various abilities:
Choose from 30 unique animal skins including Bear, Buffalo, Chick, and many more!
Features include:
Comprehensive gameplay features including:
Features an engaging scoring system with:
The game features a robust save system using JSON serialization:
Block Dodge implements robust software design patterns including:
Due to Unity's UI limitations, several custom systems were developed:
Key custom scripts that power Block Dodge's functionality:
Custom frame rate control system that ensures consistent performance across mobile devices:
// FrameRateManager.cs
// Maintains consistent frame timing using coroutines and thread sleep
using System.Collections;
using System.Threading;
using UnityEngine;
public class FrameRateManager : MonoBehaviour
{
[Header("Frame Settings")]
int MaxRate = 9999;
public float TargetFrameRate = 60.0f;
float currentFrameTime;
void Awake()
{
QualitySettings.vSyncCount = 0;
Application.targetFrameRate = MaxRate;
currentFrameTime = Time.realtimeSinceStartup;
StartCoroutine("WaitForNextFrame");
}
IEnumerator WaitForNextFrame()
{
while (true)
{
yield return new WaitForEndOfFrame();
currentFrameTime += 1.0f / TargetFrameRate;
var t = Time.realtimeSinceStartup;
var sleepTime = currentFrameTime - t - 0.01f;
if (sleepTime > 0)
Thread.Sleep((int)(sleepTime * 1000));
while (t < currentFrameTime)
t = Time.realtimeSinceStartup;
}
}
}
I acquired this code from TechGeeker's amazing video on the topic.
Solves Unity's UI limitations with runtime content adjustment:
// InheritGUIScale.cs
// Automatically adjusts UI container height based on dynamic content
using UnityEngine;
using UnityEngine.UI;
[RequireComponent(typeof(RectTransform))]
public class InheritGUIScale : MonoBehaviour
{
private RectTransform rectTransform;
void Start()
{
rectTransform = GetComponent();
AdjustHeight();
}
void AdjustHeight()
{
if (transform.childCount == 0) return;
float minY = float.MaxValue;
float maxY = float.MinValue;
foreach (RectTransform child in transform)
{
float childMinY = child.localPosition.y - (child.rect.height * child.pivot.y);
float childMaxY = child.localPosition.y + (child.rect.height * (1 - child.pivot.y));
if (childMinY < minY) minY = childMinY;
if (childMaxY > maxY) maxY = childMaxY;
}
float totalHeight = maxY - minY;
rectTransform.sizeDelta = new Vector2(rectTransform.sizeDelta.x, totalHeight);
}
void Update()
{
AdjustHeight();
}
}
Disclaimer: I am aware this code is not the best, but for my usecase (the small amount of upgrades/skins) it's more that sufficient and does not cause performance degradation.
These implementations showcase: