Log In  

Cart #urlcat-0 | 2023-09-09 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
2


This is a demo I made as a challenge to create a whole game to fit in Pico 8 Education edition's URL functionality. The whole game fits into (EDIT: THE URL DOESN'T WORK ANYMORE, I'LL FIX IT SOON) this URL. 431 tokens and 1196 total characters, this was hard for me because im still learning new things everyday about pico 8.

Features:

  • Smooth Camera (Found it somewhere online, can't find the original. If you can find it telling me qould be greatly appreciated because I want to credit the original creator. )
  • Map to text Compression and vice versa (Also not my code. Couldn't really simplify this by modifying, because I don't understand it.)
  • too many one letter variables (Not really a feature. :/)
  • not perfect collision (It still works, so who's complaining?)
  • 64x64 resolution (Achieved through poke(24364,3))
  • 60 fps (Achieved by using _update60)

Behind the Scenes

Backstory

This game originally was posted on my blog around 2021 called duck game (the original main character was a duck.) and was created through to different templates and some knowledge on how lua works. 95% of the code wasn't mine and I unlisted it only to later delete it, because the collision was messed up and it wasn't really a game. Fast forward to a little over a month ago, i posted my first game Catatac and I remembered about the duck game, and tried to recreate it, BUT I wanted to create all of the code myself and that didn't turn out so well, got stuck on collision again (Curse you, collision!). Here is that project:

Cart #cat_col_broken-0 | 2023-09-09 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
2


I'll soon fix that project but right now it's still looking pretty ugly. Later I was scrolling through BBS the other day and went on my account, and clicked and looked at my unlisted, and turns out, I saved an older version of the duck game, missing some features and broken, still, but it's still the original! I saved the graphics and I had the idea to create it into a URL so I can't lose it anymore, and here I am, writing a post about it.
TLDR: Created game long time ago through copied code, deleted it out of shame, tried to recreate it, found a broken version of the game, stole graphics and created this.

How it was achieved

Once I got the older version, I started up a new project, found a camera that I can use (I still can't find the post, if you somehow know who made it, which is probably slim to none, please comment and tell me, because i want to credit them.) Created simple movement and collision, that is not perfect but works. Instead of creating a object for the player, all of the variables are independent variables, which would be bad because of organizing but this is a small project so who cares? created a map, and used Shrinko8 to compress the code. once I tried to save it to the URL, I couldn't. The problem was that it was to big. Here are some optimizations I made:

1. Optimizing sprite space

I had too many sprites that I didn't need, and I tried to keep most original sprites.

here is a before:

and here's an after:

This is self explanatory what I did here, but there were some revisions and specific optimizations made, like how the first 11 sprites (not counting the main character) are "walls" so I can just loop starting at 2 and going to 12 to find out what sprite is in front of the player. I got rid of similar sprites and created a mutual sprite, and I got rid of most decorations.

2. Using one main loop

Instead of using an _init, _update60, and _draw, I'm only using _update60 as a loop, to get rid of extra unneeded functions. here's a link to a explanation of how I did it.

3. Creating extra variables for constants that are used frequently

This is a no-brainer, but for sx and sy and some other variables, they all change by .2, so I just added a variable that is a constant of .2, and I used it 5 times, saving me 1 character! this is a small change, but it adds up if you keep doing simple tweaks like this. Here is a comprehensive list of tweaks like these if you want to optimize tokens (and sometimes characters) using small tweaks.

TLDR: Sprites take up too much, simplified it. Used only one main loop, and did lots of small tweaks.

Problems along the way

By far the biggest problem I had was character count and that there is a caveat to the URL feature:
map's didn't save in the URL.
I almost gave up because of this problem but I found the map to text converter (here) and I figured out how to implement it. The only limitation now is that I will need space to store the text, and I have a limited character count. A small solution was to optimize even further and zoom in the camera to create the map bigger. the map spans a total of 4 screens, the house, school, store, and sea, when it used to take up alot more space, specifically the whole map size, not including the shared space. some excluded areas were the lake, the flower field, the forest, and the caves, which took up most of the space because it was a maze. It's funny how you're reading this now, which means you've read my text dump on how I created this game, so thank you, person on the internet.

TLDR: Had to create map smaller to fit into a string, zoomed in camera to make it "feel" bigger.

Credits:

  • @dw817: Used his Map to text/Text to map code, click here for the cartridge
  • @thisismypassword: Shrinko8 was used heavily for this project, everytime i made a change I used this to compress it even more. I highly recommend using this tool, click here for the post
  • unknown creator: for creating the camera I used, can't find the original post anywhere, so I can't credit him/her directly.
P#134094 2023-09-09 17:05 ( Edited 2023-09-09 17:36)


[Please log in to post a comment]