40KB was the standard game size for NES cartridges back in the late 80s and early 90s.
This 40KB Project was created as a personal challenge to test myself. I was able to fit 25 games into this 40KB file. These games were created in HTML5 and will work on almost any browser or operating system. Below is how it was accomplished.

๐Ÿ’พ Link to code and games: https://github.com/TheThornZ/40KB

Without any form of compression, this project would be approximately 10MB.
By swapping out graphics with emojis and drawing graphic shapes instead of using 256KB graphics, I saved an estimated 8,960KB. This reduced the project size to 140KB, with a size on disk of 116KB.

After manually compressing the text by hand and using ChatGPT on larger games, I managed to reduce it to 69.5KB, with a size on disk of 104KB. This was achieved by removing all notation, shortening variable names, and eliminating unnecessary line breaks and indents. While this makes the code difficult to edit/navigate, I will provide both the compressed and uncompressed versions.

Finally, compressing it as a standard ZIP file resulted in a file size of 39.6KB, with a size on disk of 40KB. I could have reduced the size further using WinRAR, saving an additional 3KB, but I chose not to require extra software.

๐Ÿค– If you enjoyed this video and want to support the channel, consider hitting that Super Thanks button! It really helps me keep making content like this, and I appreciate every bit of your support!

Check out more videos youtube.com/TheThorns & don't forget to like, subscribe & share.

Chapters:
00:00:00 About the project
00:03:09 showcase of all 25 games
00:12:23 Polygons and 3D shapes in HTML5
00:12:57 Games I didn't finish or include

#computerscience #gaming #html5games #40kbproject #html5games #retrogaming #nesgames #gamecompression #browsergames #indiegamedev #html5dev #emojigames #floppydiskgames #gamedevelopment #microgames
Transcript
00:01Hello again! This week I would like to share a project that I've been working on for about a month.
00:06It's my 25 and 1 40kb project. I started this project to test myself and it's inspired by the Krieger
00:13project of the early 2000s. To give you an idea of how big 40kb is, the standard NES cartridge game
00:19of the late 80s and early 90s was about 40kb. And so let's go ahead and just dive right in.
00:29First I'm gonna show you an example of how I was able to fit 25 games in 40 KB So
00:36I'm gonna pick the game flappy bat, which is just a Flappy clone and as you can see, it's a
00:45very basic game It's using basic shapes for the pipes and I'm actually using an emoji That bat is not
00:52an image in the game It's actually an emoji that was already in the computer and this is part of
00:58the reason why I wanted to do it in HTML5
01:01All these games are HTML5 because every computer is going to have a web browser and every computer is going
01:07to have emojis. So pretty much these games will work on any operating system and any browser. So you've seen
01:13the game. Now let's look at the actual code. So we have FlappyBat here. And as you can see, this
01:26code is very well organized. I have my notation. I have variable names that make sense. And it's...
01:33indented it's spaced out so very easy to read very easy to edit so this is coming up as about
01:414kb or 3.63 kb we need to get that extremely lower or as low as possible so we can
01:50fit as many games as we can in the 40kb so to do that i went ahead and took all
01:56the comments out as many spaces out as possible
02:00and even change variable names. So for instance, if I had a variable in there called gravity, I'd change it
02:06to GR or something that wasn't gonna conflict with anything else. And even naming it, I made it as one
02:13character and many of them are just HTM because it's the whole, hey, you know what? I can save one
02:18character. It looks like I forgot to do that on some of them, but for the most part, I put
02:23HTM on all the files. So you can save a character on the extension. So let's go ahead and open
02:30up this code.
02:31and that's the entire game look at how much more condensed that is so for comparison let's get this up
02:41here we have 3.63 kb on that and let's go to this 1.70 okay and then we put
02:57it into a zip file which brings it down even further 1.10 kb all right so
03:09Moving on, let's actually go through some of these games real quick. Now that you know how it's been compressed
03:14and how it's been recoded to fit in such a small package. Just to give you an idea of the
03:20size of this 40 KB project, you can put this on a floppy disk 36 times. You can have 36
03:28copies of the 25 games 36 times on a floppy disk. So that just gives you an idea of how
03:35small these games actually are.
03:38Just real quick, Black Eyed is a Black Eyed Children's Choose Your Own Adventure game. Blackjack, self-explanatory. It's against
03:54the computer or the dealer. Blastoff, a shooter game using the rocket emoji, the alien monster emoji, and circles and
04:07starfield. You can actually do quite a bit with the emoji graphics and the draw graphics in HTML5 to make
04:16pretty small unique games box smash that is just a breakout clone card match this is a two-player card
04:31matching game that you can either play by yourself and try to get all the matches or go back and
04:37forth like it says player two's turn there it was okay boop boop just so you can see at least
04:42one match okay ketchums very fast-paced catch game you only get you can only miss five so you try
04:53to get as many of these as possible to get the high score
05:01So 31, okay. Checkers, basic checkers game. The only thing about this one is I put force jumping in, meaning
05:14you have to jump the player if they are near you. Connecting fours, connect four clone. Yep, it's not too
05:37hard to outsmart that computer. Fighting to destiny. This is a, oh man, they got me already. This is a
05:50first person shooter using emojis.
06:01it's more of a maze game because you just basically have to find your way out and obviously if the
06:07enemy emojis touch you it does take health off but uh there are four levels i won't get too much
06:17into it because i don't want to give too much away so you can actually have some fun with it
06:20if you want flappy bat we already saw that one just real quick in case somebody skipped ahead ghoul busting
06:37this is a space invaders clone match me basic simon game i didn't see what it flashed i'll just hit
07:10yellow so i can lose
07:12Just so you can see it working. Close your score, reset game. Nort Cycles. Nort Cycles is a two-player
07:21Tron Cycle game. If you're with me here, I'm playing both players where you try to get your opponent to
07:32either crash into you or crash into a wall. Since it's a two-player game on one keyboard, it is
07:40arrow keys for one player, WASD for the other. Poker is five-card draw or poker against...
07:50The computer. Puckdude. This is a quick Pac-Man clone. I did not code that the big dots allow you
08:08to eat the enemies, but I did program that they are worth extra points. So if you can get them
08:14before dying, then you have a higher score. Sometimes they jump around, sometimes they hit you, but overall it's a
08:26Pac-Man clone. Puzzle is just a move boxes around up and down to clear the board as much as
08:39you can.
08:41And obviously when you can't anymore, you lose. And whatever your score is, that's your score. Slots, realistic slot machine.
08:54Let me just hit this a couple times and see if I win. Now this is programmed like an actual
08:59slot machine so you do not win too often. Obviously you can increase your bet. Hey, I did win. I
09:13got the three watermelon. I don't know if you guys saw that or not. But yeah, when you win, my
09:20final score was 58. I lost obviously, but I still gotta win.
09:25Okay, let's see here. Snake, self-explanatory. Very fast-paced Snake game. Okay. Tank Combat. Tank Combat is a two
09:44-player tank combat game like the one on the 2600. How am I missing him? Boom, there we go. WASD
09:56for one player with spacebar. And then arrow keys and enter for the other. T-Fighter. T-Fighter is inspired
10:08by Star Fox and Star Wars Arcade.
10:12So this is a true polygon game in HTML5. The goal is to destroy a hundred ships to win. And
10:27I'm going to just let them kill me so you can see it. Tetrus instead of Tetris, obviously. It's a
10:43quick Tetris clone. It is fully operational. It works very much like the original version of Tetris. Tic-tac-toe,
11:01you versus the computer. This almost always ends in a tie.
11:14Toadie! Frogger clone. Okay. TV Tennis. Pong clone. Two player, one player. Same as before. WASD is the WASD and
11:40arrow keys. So I'll just go one player. That way I can burst the computer. And UFO Lander. UFO Lander
11:57is a Moon Lander clone. And that's all 25 games. Now I did have some failure games. Games that I
12:16was working on that I just could not get working or just were...
12:20an awful disaster um oh this is a good one this is for this is a great way to show
12:25progression uh this was me learning the way to draw polygons on the screen for html5 here that's t fighter
12:35so that's the original tie fighter design then i just kept tweaking and messing with things till we get to
12:54this here donkey kong or sorry
13:02Monkey versus man or man versus monkey was the working title of this one But I really couldn't get the
13:13barrels to work in this Got the jump down to where I needed it got the climbing and everything and
13:21Being able to jump over things and win, but I just I couldn't get the barrels to Do what I
13:28wanted them to do It would always just get stuck on the corner here and not move even though
13:36My character can fall off. I couldn't get those to fall off. Worst one was probably me trying to do
13:49a pinball game. The physics and the gravity and the paddles, the flippers, it just... Yeah, it's bad. Yeah, I
13:58couldn't get this to really go all that well. Not for lack of trying, though. I don't even know where
14:14the ball went there. Hey, I actually scored a little bit. Yeah. So that's...
14:25that was a huge failure a chess game i couldn't get working well i may revisit these at some point
14:32in time but for the sake of argument i got my 25 games i got them working i got them
14:37compressed so that's the project
14:40I hope you guys found some of this informative. Like I said, I will leave the code for the uncompressed
14:44and compressed version online in links below. Feel free to use the code in any way, shape, or form that
14:50you'd like. Just please give credit where credit is due. Give credit to the channel or put my name in
14:55there. And yeah, until next time, have a great one.

Recommended