Skip to content

Asset Tutorial

Jasdac edited this page Mar 15, 2021 · 4 revisions

Let's create a custom obstacle! Each obstacle type has its own header file located in /headers/Obstacles. If your obstacle doesn't fall under any of those categories, you can create your own obstacle header. See Obstacle Header File for more information about how it's defined.

Let's assume we wanted to port over the anemone from GoThongs. There's already definitions for traps in the Trap.lsh obstacle header that we can use.

We see that the trap has its own channel TrapConst$CHAN to listen to. It has 3 tasks that can be used: seat, attack, unSeat. In our case we'll make a simple "you walk into it, it traps you" trap. So we'll handle the seat and unSeat tasks. You can pick any tasks you want to handle in your obstacle, but the more tasks you handle the more flexible it becomes for developers.

As far as events go, we can see LevelCustomEvt$TRAP$hit, LevelCustomEvt$TRAP$seated, LevelCustomEvt$TRAP$unseated, and all 3 makes sense for our trap. So we'll use them.


Clone this wiki locally