Squashing Bugs and building robust systems.
I've mostly been fixing up bug lately and it's been REALLY fun!
Two main themes
1. Splitting up the state of the player so I can turn player sprite elements off and on at different times.
2. Implementing my own metadata system.
Having a sprite that is two tiles means you run into a lot of edge cases where things look wrong. When you want to hide the player so it looks like they are behind a wall.
And then i'm wanting to place down a lamp in the world. But I don't want to place it if... ~the light level is 0 (Then the player can loose it) ~if the location you're placing it is solid ~if the location you're placing the lamp is "behind" something (As it would replace the tile)
The only meta data tiles have is solid or not. You can't define a tile as above.
I was planning to simply list many if statements for each "above" tile but @orkn had a better idea. So all credit to him on this one.
"So if the solid function didn't exist, and we wanted some way of knowing if a tile is "solid" or not, and we wanted to check if a tile is solid or not in multiple places around our project, we might decide to make our own version of the solid function. In the game script we add: on isTileSolid do if tile=="white" then tileIsSolid = 0 elseif tile=="black" then tileIsSolid = 1 end end and we can keep adding elseifs for every tile in our game. (As a potential optimisation we realise we could start the event with tileIsSolid = 0 and then only add ifs for those tiles that are solid, but maybe we appreciate the explicit list of all tiles as it makes changing the metadata easier, idk!) Then wherever in our code we want to check if a tile is solid, we do this: tile = name x,y tell event.game to call "isTileSolid" end myTileIsSolid = tileIsSolid and that is functionally equivalent to the actually built-in myTileIsSolid = solid x,y The isTileSolid event is effectively a function with an input tile and an output tileIsSolid, it's just Pulpscript doesn't support event arguments and return values so we just have to be careful juggling global variables. The solid function does exist, so this isn't necessary, but if we want to add new kinds of "metadata" to tiles, like their "aboveness" in this case, then you could take this approach."
I took that and made the following.
In game
I have
on isTileAbove do tileIsAbove = "false" if aboveTarget=="roof top" then tileIsAbove = "true" elseif tile=="other" then // tileIsAbove = "true" end end
And in my on cancel event which I use tileIsAbove
for checking if the player can place the lamp
Place lamp code
on cancel do if lampHeld=="true" then // holding the lamp | There's zero lamps on the screen lampTargetX = event.px lampTargetY = event.py if playerLastMove=="L" then lampTargetX-- elseif playerLastMove=="R" then lampTargetX++ elseif playerLastMove=="U" then lampTargetY-- elseif playerLastMove=="D" then lampTargetY++ end lampTarget = name lampTargetX,lampTargetY lampTargetSolid = solid lampTargetX,lampTargetY aboveTarget = lampTarget tell event.game to call "isTileAbove" end if lightRadius>0 then if lampTargetSolid==0 then if tileIsAbove=="false" then tell lampTargetX,lampTargetY to swap "Lamp" lampHeld = "false" // not holding the lamp lampRoom = event.room if illumination=="dark" then // re-illuminate the room so that the radius now centers around the lamp instead of the player emit "darken_tile" tell event.game to call "darken_room" call "illuminate_tiles" end end end elseif tileIsAbove=="true" then sound "prohibited" say "Can't Place lamp behind things" at 1,10,21,3 end elseif lampTargetSolid==1 then sound "prohibited" end elseif lightRadius==0 then sound "prohibited" say "I don't want to lose this lamp in the darkness" at 1,10,21,3 end end end
Get Comet
Comet
A Light-hearted puzzle adventure.
Status | In development |
Authors | guv_bubbs, aloebach, Will Aryitey, rowdy41, xmenekai |
Genre | Adventure, Puzzle |
Tags | 1-bit, Female Protagonist, Narrative, Pixel Art, Playdate, Relaxing, Sokoban, Story Rich, Top-Down |
Languages | English |
Accessibility | Subtitles, High-contrast |
More posts
- Extreme Makeover: Comet Edition5 days ago
- Milestone 6 | Light Mechanics & Engine Upgrades54 days ago
- Playtesting & Character CreationJul 22, 2024
- Milestone 5 | Chapter 2 Systems, Design & FlavourJun 23, 2024
- Behind the scenes - Announcement TrailerMar 31, 2024
- Milestone 4 | Chapter 2 DraftFeb 28, 2024
- Milestone 3 | Chapter 1 PolishDec 01, 2023
- Camera workNov 06, 2023
- How we use LDtk in CometOct 16, 2023
- Milestone 2 | Performance, Key Art & level design.Oct 10, 2023
Leave a comment
Log in with itch.io to leave a comment.