CheeseLord / plaid

PLAtformer In D
MIT License
0 stars 0 forks source link

Add more types of platforms #35

Closed kronmillerg closed 8 years ago

kronmillerg commented 8 years ago

Idea for handling different types of platforms (writing it down before I forget):

Each platform has a bit, which indicates whether it should be considered for collisions. Initially, this is set on all platforms. Each frame, the physics engine works out the player's trajectory assuming there's no collisions, then (conceptually at least) enumerates all the potential collisions and then iterates over them one at a time. For each potential collision, it calls the appropriate handler function for the platform. The handler function possibly changes the player's velocity or that bit, then returns to the physics engine a Boolean indicating whether it had any effect on the player's trajectory. If not, then the physics engine moves on to the next potential collision; if so, then it recalculates.

kronmillerg commented 8 years ago

We now have a hacky implementation of PASSTHRU platforms (platforms that you can jump up through but that are solid when you collide with them from above); see cadea9ea53e1ff56d2cc34d54e3322854a79b294. It needs some cleanup.

kronmillerg commented 8 years ago

Probably we want to have a bunch of bits for different properties of platforms (passthru, bounce, crumble). Also, it may be wise to keep two lists of platforms, one for each type of collision detection. Also, to avoid coupling the YAML with our internal way of storing platforms, we're probably going to need to rework the YAML parsing code for platforms so that it parses all the platform nodes into an intermediate list of objects whose structure matches the YAML, and then copies the information into our internal representation (2 lists, different structs) afterward.

kronmillerg commented 8 years ago

Bouncy platforms added in ad0443531565db055f6a2f2650b8c367cb48b715.

kronmillerg commented 8 years ago

The game's representation now stores separate bits, but the intermediate representation used when parsing the yaml only stores a single value. The fix is pretty simple: change the intermediate representation to store a list of such values, then iterate over them to set the bits.

kronmillerg commented 8 years ago

The purpose of this issue was to create a few types of platforms, so that we could see what goes into them and then clean up the code (maybe factor some common stuff out). We have created enough platforms for demo purposes; if we need more types of platforms, we should create separate issues for them. Closing issue.