Interested in adding a points system to my game, have a few questions about how to start inside

Hey everyone,

I’m looking to add the following points system into my game
1 hit block destroyed: 1
2 hit block destroyed: 2
3 hit block destroyed: 3
2 blocks destroyed at the same time: (x1.5 multiplier)
Blocks killed in succession (combo): 2 blocks in under .5s (x2 multiplier), 3 blocks in under .5s (x3 multiplier)

I have the first three implemented perfectly right now. I created a UI component that reads the points and they count up as you play. However I am not quite sure where to start with the bottom two. How can I keep track of blocks that have been destroyed in a certain amount of time, or at the same time?

If anyone has any ideas that would be awesome!

Well at a really quick spitball on the 1.5x bonus, each time a block is destroyed, update a LastBlockDestroyedAt time in a static field on your Block. Then, each time you destroy a block, compare the destruction time to LastBlockDestroyedAt, and if it’s within a certain threshold (e.g. 0.5s) award the bonus.

For the 2x/3x bonus, you’ll need to check that there was a bat hit in between the two or three block hits.


Actually if you used a Stack with size 5, you could push simple objects onto that which represent your collisions, and they’ll pop off the bottom as more are added.

The Collision object would represent a type of collision (bat/block/blockdestroyed) and a timestamp. Implement IComparable on it so the times can be compared. That might be a more elegant approach.

1 Like

How would I go about actually comparing the objects in the stack?

The Stack is a Collection, so you can iterate it with a foreach statement. As for the Collision object, to implement IComparable you must implement a method called CompareTo which in this case would return based on the timestamps on the Collision objects.

It’s probably better explained in pseudocode but I’m at work right now, will try later :slight_smile: I want to build something similar into my own version of Block Breaker anyway.

Here’s sort of what I meant:

public class Collision : System.IComparable {

    public float collisionTime {get; private set;}
    public CollisionType collisionType {get; private set;}
    public enum CollisionType {Bat, Crack, Break}

    public Collision(float time, CollisionType type) {
        collisionTime = time;
        collisionType = type;    

    public int CompareTo(object obj) {
        if (obj == null) return 1;
        Collision other = obj as Collision;
        if (other != null) {
            return this.collisionTime.CompareTo(other.collisionTime);
        } else {
            throw new System.ArgumentException("object is not a Collision");


edit You can see my source here:


Good luck!

1 Like