Let's say you feel cramped by the 8 × 8 px size of the player tile in Pulp. Well, you can make a player that consists of two tiles!
Here's the basic way I achieve this in PulpScript:
[player object]:
// This function runs every time the player attemps a move
on update do
call "calculateMove"
end
on calculateMove do
playerHeadX = event.px // event.px is where the player moved
playerHeadY = event.py
playerHeadY -= 1 // the head is one tile above
end
on draw do
// the "player" (the feet) gets drawn automatically;
// here, we manually draw the tile called "player head"
draw "player head" at playerHeadX,playerHeadY
end
And here's the whole game, with some fancier code:
Player tricks.json.zip (4.4 KB)
In the starting room, the design is such that the head can overlap walls, for a depth effect:
In the second room, on the left, the player never overlaps the walls. If you want this behavior, it's achieved by simply placing invisible walls below each "real" wall tile; the head is still drawn over those invisible walls, but the player can't enter them.
This game demoes some other potentially interesting Pulp solutions:
- I create a "blink" animation cycle on the player's head by repeating the "eyes open" frame 10 times, then having one blink frame.
- The player faces the direction they're walking. This is done by checking which direction they attempted to move in, then swapping their frame to a flipped version. (Yes, the player can have multiple tiles for different appearances!) I also flip the other player tile—the head—based on a variable that tracks which way the player is facing.
- I drew walk cycles as well (one for each direction). When the player moves, I switch their frame to those tiles; then after 0.3 s, I switch to the static frame. The effect is—hopefully—that of animating while walking.
- If the player "bumps" into a wall (tries to move into it but can't) I play a bump sound effect.
Hopefully you find these useful—if you find better ways of achieving these effects, or you have other player tricks, let me know!