Endless Mode Part 6: Daily Runs

Yeeeaaaahh!! Bleed 2’s Endless Mode is now out on PC, Xbox One and PS4!

The perfect little cherry on top of the new Endless Mode is that (on PC, at least) it comes with daily challenges, too! This feature was put in very last-minute, in literally the final week of development. I had no idea what I was doing at first, but thanks to help from Vertex Pop’s Mobeen Fikree, this pastebin snippet and my dad, I managed to get it done! I thought I’d share the process of making daily runs, since I couldn’t find many resources online for this kind of thing.

Warning, this is a very wordy post. I use images to try and break it up but if you really wanna know how to do this… you gotta read!

Okay, so, first challenge: how do you give everyone the same run each day? This one’s actually really easy: there’s a thing called Unix Time, which tells you the number of seconds that have passed since Jan 1, 1970 in UTC. Given that information, you can find the number of days passed since Jan 1, 1970 UTC, and that gives you a number that goes up by one, every day, at the same time, for everyone! Use that number as the seed for the level-generating RNG and bam! Good to go!

(Endless Mode also uses its level-generating RNG to pick a run’s difficulty, the player characters and other constraints, so it ensures everyone plays with the same rules, too. The gameplay RNG and the level-creation RNG are completely separate, so no matter what happens in the game during a level, it won’t affect the next level’s generation. Everyone gets the same set of levels.)

Second challenge: how do you store the scores on leaderboards? Steam does let you auto-create leaderboards, so I could auto-create a new set every day and be done with it, but that seems wasteful to me (plus, Steam has a hard limit of 10,000 leaderboards max. It’d take almost seven years to reach that cap for me, but I still don’t like designing the system knowing it will eventually break.) Steam also doesn’t let you auto-delete leaderboards, so clearing them would be a nightmare.

ANYWAYS!! My solution is to use leaderboards in sets of 7 (one for each day of the week), and the sets are constantly re-used. I begin their labels with numbers, like 0_DAILY_SOLO_TIME, 1_DAILY_SOLO_TIME, all the way to 6_DAILY_SOLO_TIME. I take the days passed in Unix Time, divide by 7, and the remainder is the leaderboard number you’re using. Tadaa! It makes looking up past days easy, too — you just find the remainder of “days passed in Unix Time” minus one, or minus two, or however many days back you want to go (up to seven.)

Third, biggest challenge: what about the scores that go on the leaderboards? What if last Monday you scored 50,000 points, but this Monday you score 40,000? We want this Monday’s score to overwrite last week’s, because it’s newer, but by default ir won’t because last Monday’s score was higher. We don’t even want to show last Monday’s score on the leaderboards this week, but as mentioned, there’s no way to auto-delete or auto-clear leaderboards. What do we do? The solution: the score Endless Mode uploads isn’t actually your score, but a a hybrid number, made up of your score, and an index. Let me explain!

Think of it like this! The max score Endless Mode will accept is 999,999. Let’s say today we achieved the maximum score, and today’s index is 1. The index gets added on the beginning of our score to make 1,999,999, and that’s what gets uploaded to Steam’s leaderboards. This day next week the counter will be 8 (it’s been 7 days so the index has gone up by 7), and uploading a max score then will look like 8,999,999. It works great, because even if we get a max score this week, and then get the worst score possible (0) next week, 1,999,999 is smaller than 8,000,000, so the new score always overrides the old one.

This is more-or-less what’s happening behind the scenes — it’s just being done in binary. (You might want to check out this awesome Mario 64 TASing video for a fun explanation of how binary works, if you’re curious! The explanation starts at about 8mins, though I think the whole video is really cool.) Having the index also lets you hide any entry that’s from a past day — you only show leaderboard entries with today’s index. You use Unix Time to get the index, so everyone’s indexes are always in sync, too. Finally, starting a daily run auto-uploads a score of 0, which blocks repeat attempts, since the game only lets you start a daily run if you haven’t uploaded a score for that day.

Aaaaaand… that’s the basics of how it works! From a design perspective, it was fun to play around with daily runs, too. They start pretty easy on Monday, peaking on Saturday with a Too Hard run (!!), and ease back down slightly on Sunday (I modeled it after how newspaper crossword difficulties work, haha.) Many runs are freestyle, so you can use whatever characters and weapons you like, but some force everyone to use the same randomly-selected character, or play in “New Game” mode, or under other special conditions.

You can see the specifics of the run in the menu before you start it. Like above, it’s a Very Hard run, forcing you to play under New Game rules! I think it’s pretty fair for you to know what you’re going in to! Best of all, replays fully work with Endless Mode too, so you can see how everyone get their scores (or if they cheated…!!)

All in all, Endless Mode was a lot of work, but I’m glad to have it in, and am excited to unleash it. I hope it gives you some enjoyment, and lets you spend a more time with the game. See you on the leaderboards!