MichaelSinsbeck / platformer

A ninja platformer written in LÖVE
7 stars 0 forks source link

[LE] Add hanging lines for sliding (white Bandana) #128

Closed Germanunkol closed 10 years ago

michalove commented 10 years ago

At the moment, the lines will not work, if they cross. I will have to fix this, because we cannot prevent the user from making crossed lines in the editor.

Germanunkol commented 10 years ago

I was starting to implement these lines for the editor, but noticed it's more involved than I thought. Main problem: How would you want to visualize them? On the object panel in the editor, I only draw visualizers at the moment. But this won't work for the line... Maybe we could add another :draw method to the object?

michalove commented 10 years ago

The placement of the lines is different from the other objects, too. You need to click twice, not once. Maybe they should be treated completely different?

Germanunkol commented 10 years ago

Well, I thought about adding two invisible objects. When you select the line from the object panel, the "start" object is selected for you. When you click the first time, the selected object automatically changes to the second invisible object (the "end" object). Whenever the end object is placed, the actual line object is created. This way, in the editor, we could leave the invisible objects there and they could be draggable, removable etc, just like normal objects. When you delete one of them, the other one gets deleted as well. When loading the map for running it in a game, we simply don't load the invisible end and start object, we only load the line... What do you think? I'd really like to avoid a new tool for it....

michalove commented 10 years ago

You are right. That is a good idea.

The objects would then get and "id" or something to represent, which other invisible object is the end of the rope. And when one of them is deleted, the other one has to be deleted, too. That means that we create a new object, that is placable in the editor, which, on loading, creates a line (anchor, or hook or lineEnd?). These objects need an extra flag, that tells the editor, that they always occur in pairs.

Germanunkol commented 10 years ago

All right. I'll make the lineHook element and add it to the game...

Germanunkol commented 10 years ago

Done. That was much simpler than I thought! I think it works relatively well. I avoided the ID so far. Instead, the order of adding line hooks is the only thing that matters: Two line hooks in the file which come after each other will always be connected.

Could you draw some visualizer for the lineHook, to be used in the editor? To set it, just add it to the animationDB and then change the visualizer's animation in scripts/objects/lineHook.lua. For the moment, I'm using the ninja's sliding animation as a placeholder.

Currently, it's impossible to add a line that starts where another one ends, because objects (lineHooks) can't be placed in the same tile. We can change that, if you want to.

michalove commented 10 years ago

Looks and feels good! I will see, if I can come up with an appropriate image.

For the multi-line idea: This is not implemented yet, so for now, the solution is alright. If we wanted to start one line at the end of the other, then the line object would need to know about this and the physics have to be adapted. I don't know if this is worth it.

Also currently, the lines behave unpredictably, when they cross. What behavior would you expect, when you slide down one line and cross another one? Just stick to the original one or switch to the one that is higher?

Germanunkol commented 10 years ago

I also don't think we need multi-lines. One can easily get something very similar by placing a new line one tile away from the last one - that way the player has to jump, which is more fun, anyway.

Yes, I noticed that they're unpredictable. If you're sliding down its easy to switch to the crossing (higher) line by jumping once. However, if we automatically switch to the higher line then it's impossible to continue down the old line, without dropping manually. So I think it would be best to stick to the old line, because that way the player can easily choose which line to follow...

michalove commented 10 years ago

Agreed!

michalove commented 10 years ago

I took the editorPin, changed the color and used it for the lineHook. What do you think? The tooltip should explain what it is for (or, we have the whiteBandanaSlide image in the object palette and use the pin in the editor screen.

I also solved the unpredictable behavior.

I found a bug in the object palette. It might be related to the lineHook, but not necessarily. After using the editor for some time, the last object was placed in the wrong position (a bit higher and to the left). objects_displaced Any ideas, why? Sorry, I cannot tell how to reproduce it, but I used the line tool a couple of times, went back to the main menu and then back to the editor. (the crumble thing is displaced, too, but that is due to the visualizer-representation of it)

Germanunkol commented 10 years ago

This is weird. It happens to other objects, too (appearblock, door ... ). And I can reproduce it every time: open the editor, choose an object, place it onto the canvas a few times, exit editor and go back to editor - object will be displaced.

I noticed that the visualizer used for the button has no more animation (it's nil). The visualizer is NOT copied at the moment, it just uses the object's visualizer. But I can't figure out where the animation of the object is being reset...

Germanunkol commented 10 years ago

Ah, found it. When clicking, the animation of each button was set to self.imgOn. But the object buttons have not imgOn, so it was set to nil. Now, the animation is only changed if the new animation is not nil...

P.S. The black pin looks very nice! You're right, maybe the visualizer in the object panel should have a line added, though... or something else to show that you're actually placing lines. Maybe the white ninja, hanging with his bandana from the pin?