Confidently Incorrect - Pico-8
Tags: beginners, programming, codenewbie, codereview
Published: 2024-01-30 10:45:53

####_Confidently Incorrect since 1987_

##Pico-8 and the first collaborative project


![MouseGame](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tn0pvpj283y08hkptfli.png)

So for those who don't know, [Pico-8](https://www.lexaloffle.com/pico-8.php) is a virtual console for people to design and develop their own games with, and enables the sharing of these games for others to use. 

Famously the first version of the game [Celeste](https://store.steampowered.com/app/504230/Celeste/) was created with Pico-8, [here is that version.](https://www.lexaloffle.com/bbs/?tid=2145)

My first time working as part of a group on any coding project, the goal was to create a simple video game using Pico-8 during the 2 weeks and to present our creation at the end of the project.
Simple enough, some fairly basic conditions to be fulfilled :

* Moving entities
* Events
* Interactions

Happily, our group quickly settled on the idea which we were going to use as the basis of our game, that of a mouse foraging and collecting various foodstuffs from a garden/outdoor environment to unlock the door to their home and feed their family inside.

Setting up our [GitHub repository](https://github.com/adatechschool/projet-collectif---pico-8-eline-bradley-france) was relatively painless, despite it being the first time for some of us, but due to our lack of experience to avoid conflicts we did most of our actual coding as a mob, with us all taking turns at the keyboard, which worked well given the small size of the team and small scale of the project.

We had been provided various useful resources to help us :

* [User Manual/Documentation](https://www.lexaloffle.com/dl/docs/pico-8_manual.html)

* [Cheat Sheet](https://www.lexaloffle.com/bbs/files/16585/PICO-8_Cheat-Sheet_0-9-2.png)

* [Game Dev e-zine](https://mboffin.itch.io/gamedev-with-pico-8-issue1)

* [Pixel Art Tutorials](https://saint11.org/blog/pixel-art-tutorials/)

Which all proved to be very useful, to greater or lesser degrees.
The main game loop is contained within the _init(), _update() and _draw() functions. 

_init() function is initialising the game state, creating the player entity, setting the score and displaying a welcome message, all pretty simple once we had checked the code in some of the demos provided with Pico-8 and a few YouTube tutorials watched.

_update() function contains the game logic, the meat of the sandwich, player movement and collisions we also locked the player from moving whilst the welcome message was still being displayed, camera movement so that the player sprite stayed central on-screen and also kept the screen the other side of the door hidden until it was unlocked, collecting items, the player sprite animation cycle, the unlocking of the door and updating the encouraging message displayed for the player to continue collecting items.

This is very much the section where we spent the greatest amount of time working on, as well as breaking and fixing the game. The _init() function, by its nature of only being necessary at the start of the game was comparatively easy to put in place, as our ideas for our game shifted and evolved we had to add and tweak the _update() function to follow our vision for the game. The collision logic and using the flags took some time for us to use appropriately, but once implemented successfully we found it easy to reproduce, for blocking player movement and collecting the food sprites.

_draw() function is responsible for rendering the game UI, Map and Sprites. The main tricky parts here were updating the map after the door unlocks once enough food had been collected, and displaying the messages and updating them with the score.


![Mousing About](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zbf4d08a48nfb1x4bnqt.png)

Altogether, it was a very enjoyable project, especially for the first time working together as part of a team on the same project. There are definitely things we could have added in if we had more time to work on it, notably some more work on the end-state of the game, adding in sounds and music. But considering that it was our first time using Pico-8 and the Lua language, I am pleased with what we created. The animation of our mouse moving in particular is a point of pride, as well as the sprites made. We did write the majority of our code using VSCode, simply because we found the built-in IDE of Pico-8 a bit...uncomfortable on the eyes.

Next week, our project for introducing us to the notion of asynchronous calls and API's and Data Visualisation!