Find the poops! My first Playdate game made in Pulp
Tags: gamedev, beginners, playdate, pulp
Published: 2023-02-02 02:47:17

## My journey
1. Considering my audience
2. Recognizing my skill range
3. Preparing the room and tiles
4. Placing the four player-adjacent tiles
5. Placing the poop tile at a random location
5. Revealing poop when it is one tile away
5. Resetting the adjacent tiles
9. Adding a hint
6. Why won't this end?
7. Embracing the bug
8. Making the title card
10. Outstanding bugs
11. Published on itch.io
11. Celebrating my accomplishments

### Considering my audience
- My son: a 3.5 year old boy
- Who loves talking about poop, toots and other gross bodily activities
- And who enjoys fiddling around with my Nintendo Switch and iPhone

### Recognizing my skill range
- I can swap tiles
- I can respond to player movement events
- I can generate random numbers
- I can place text on the screen
- I can generate messages
- I can identify adjacent tiles

I can do this!

### Preparing the room and tiles
- Make the room all black
- Switch the color of the player
- Make the player's background pixels transparent
- Create a poop tile
- Create a poop-in-the-dark tile

### Placing the four player-adjacent tiles
First, generating the X and Y coordinates:
```
px = event.px
py = event.py
above = py
above -= 1
below = py
below += 1
right = px
right += 1
left = px
left -= 1
```

### Placing the poop tile at a random location
Generating the coordinates:
```
poopX = random 0,24
poopY = random 0,14
```

Briefly revealing the location:
```
tell poopX,poopY to
  swap "poophidden"
end
wait 1 then
  tell poopX,poopY to
    swap "black"
  end
end
```

### Revealing poop when it is one tile away
This is part pseudo-code, since each of the four conditionals is very similar:
```
if [within the room's bounds] then
  tell X,Y to
    if X==poopX then
      if Y==poopY then
	swap "poop"
      end
    end
  end
end
```

### Resetting the adjacent tiles
In `player`, a custom `reset` event is emitted on each `update` event.

The `reset` event is attached to both poop tiles.

It simply swaps the tile for `black`.

### Adding a hint
While play-testing, I would miss or forget where the poop is.

So, I made the `A` button briefly show the poop again:
```
on confirm do
  tell poopX,poopY to
    swap "poophidden"
  end
  wait 1 then
    tell poopX,poopY to
      swap "black"
    end
  end
end
```

### End after collecting one or more poops
I added an `on collect do` event to the poop tile.

Inside it, I called `fin` with a game-ending message.

### Why won't this end?
I play tested in the pulp browser simulator.

Everything worked as expected.

The game-ending message appeared after collecting the poops.

I downloaded the PDX file.

I opened it in the Playdate Simulator.

I collected the poop.

The console spit out a cryptic error.

I spent an hour attempting to address the error.

I couldn't figure out why the game crashed when it attempted to end.

### Embracing the bug
I decided the game just wouldn't end.

Instead, the player just collects poop that appears in different locations.

Here is my updated poop tile collect function:
```
on collect do
  poops++
  say "You found {poops} poops!" then
    tell event.game to
      call "movePoop"
    end
  end
end
```

`movePoop` is the code you've now seen several times, with a new poopX and poopY generated prior.

### Making the title card
I exported the font and imported it for use as World tiles.

I created a few rounded-corner tiles to make the poop look...cooler?

I duplicated and inverted the three letters, 'THE', to appear inside the poop.

![Title card for my game](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dnfj5wpg5vemvy0zfwjo.png)

### Outstanding bugs
- The game doesn't end
- If the poop newly appears really close to the player, it won't properly swap the poop and poop hidden tiles immediately
- If the poop appears in the same position as the overlaid text, it is invisible but still collectable

### Published on itch.io
- I registered
- I made a game page with description, cover image and links to download
- [I published that page](https://rmion.itch.io/find-the-poops)

### Celebrating my accomplishments
- I built a game almost entirely from scratch in pulp!
- I debugged an issue where the player couldn't move to the top or bottom rows. And got stuck in place!
- I worked around a game-non-ending bug!
- [I published it on itch.io](https://rmion.itch.io/find-the-poops)!

I showed my son the game.

Sadly, it didn't hold his attention for more than 10 seconds.

Oh well. It was still a great learning experience making it!