MichaelSinsbeck / platformer

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

[LE] Background class #114

Closed Germanunkol closed 10 years ago

Germanunkol commented 10 years ago

I've been thinking about how to implement the background tiles (non object). They should work just like the ground class.

michalove commented 10 years ago
Germanunkol commented 10 years ago

To the last point: I think one of theses solutions will be best: a) There is only one pen tool, all ground and background types are visible when this tool is active. In this case, the eraser will first erase the foreground (if any) and then the background (if any) b) There are two tools, one for grounds/walls (foreground) and one for backgrounds. The corresponding tiles are only displayed when one of the two tools are picked. Any preferences?

Eyes sound like a good idea. Maybe we could use the Ninja's Eyes?

P.S. I think shifting the grid will look weird/confusing. But I like the idea of changing the color a bit...

michalove commented 10 years ago

I prefer b). Mainly because the functionality of the eraser together with the line-drawing would be ambiguous.

For the eyes: Yes, why not?

Germanunkol commented 10 years ago

True, I did not think of the line-drawing. That would be really annoying to use. However, then we'll need two fill-tools as well (unless we use pen-tool + CTRL for bucket fill).

Or we really do make a layer-panel, where the user can choose between layers...? Then we only need one tool for bucket fill, one eraser, one pen and one stamp. Whenever the user chooses a different layer, the grounds/backgrounds would automatically change.

michalove commented 10 years ago

I like the idea of having modifier-buttons for the different shape modes (point - none, line - SHIFT fill - CTRL).

The switch (draw/erase) is independent from the three shape modes. Both can be combined with all three.

On top we have a third aspect: "Layer". It has four possible values: Background, Background Objects, Ground/Walls, Objects (some of them have the option "line" and "fill" disabled.)

How about that: We remove the different buttons for Drawing, Erasing, Stamping. Instead we put four buttons there for the different layers. According to the choice we can adapt the panel on the left side and we can also adapt the view, if we want that. Then the user can use the modifier-buttons for lines and filling. And to differentiate between draw and erase, the user can just press the left or the right mouse button.

That would cover all possible combinations, that come to my mind. The selection panel for the objects will be rather big, while the one for walls is small. We would have to decide, if both of them use the same code or if they behave differently in the end.

Germanunkol commented 10 years ago

I noticed one more problem: Some background tles that I was going to place as background objects are actually part of the background layer, not part of the background objects. For example, the cracks in the walls (Tiles x=0,y=12 and x=0,y=6) cannot be placed with the normal pen since they're not regular. So how do we add them? Making another color type just for them on the background pallete is stupid. Adding them as random variations isn't good either, since they really change the whole look (from non-broken to broken) and since there are more that are problematic (water mill) which can't be placed randomly.

The only solutions I can think of:

It's really stupid because a lot of tiles that are objects blend with tiles of the background...

Germanunkol commented 10 years ago

Ah, one more idea: We could also remove the window and the two cracks entirely from the game. These are the only tiles that would look wrong when drawn over the background (because of their transparency). All other tiles - when placed on the background - should just cover it and work fine.

michalove commented 10 years ago

The first solution will be difficult, because, the crack and the window only work in special cases and not in front of all possible tiles. And the second one sound too complicated to me, for only two different tile types. So for now, we could just remove them from the game.

Besides that, I like the idea of "variations". So if we decide to put them into the game, we could maybe add a "variation brush", that when clicked on a tile, replaces the tile by its variation. Then each tile type can only have one variation. But I haven't really thought this through.

michalove commented 10 years ago

I found a bug: When I am in "edit" mode and delete an object, then the tool tips of the edit-menu (move up one layer, etc... ) are still there, when I am at the right spot on screen with my mouse.

Germanunkol commented 10 years ago

Fixed the bug above.

Also, I started work on the background class.... well, it works. Sort of. It's a little annoying and there's way too many updates at the moment, when placing new tiles. I don't know if I should optimize that - it works fine on my PC. It makes the code cleaner, but is a bit of a brute-force approach.

I have an idea for the tile-transitions for the background. I currently have three backgrounds (concrete, dirt/soil and darker soil). I think it would be possible (and neat) to create a sprite batch for each of them. Then, the concrete is always drawn first, then the soil and then the dirt and then the darker dirt. I would also make the concrete "similar" to the dirt and the dirt "similar" to the darker dirt. That should make sure that they're always connected and should take care of all the necessary transitions.

This is almost the same approach as the one I currently use for spikes vs grounds, which seems to work well.

The alternative would be to manually create and input all possible transitions between backgrounds. With three backgrounds, thats a whole ton of transitions, and I don't want to do that. When we add more later (castle tiles, for example), it gets worse...

michalove commented 10 years ago

Good idea. Fully approved!!

Germanunkol commented 10 years ago

Thanks :)

I think I'm on the right track: 2014-01-30-154706_1536x960_scrot

michalove commented 10 years ago

Did I understand correctly, that still in each cell there is only one tile, but the graphical representation is constructed by placing multiple layers of tiles? On the bottom center, I see the lighter background vanish behind the darker one, but the lighter one seems to bend to the right there.

Germanunkol commented 10 years ago

There is one tile layer for every type of background. When drawing on one of the upper layers (layers are automatically "selected" by choosing a ground type) then the lower layers automatically update and fill that area. So when I draw on a tile, yes, the lower layers are also updated and there will be tiles underneath them.

It's possible that there are ways to optimize that as well, as I mentioned above, this is the brute-force method I'm using right now (i.e. When placing a tile, all surrounding tiles are updated - but when I draw with the background brush 4 tiles are placed at once. That means some tiles around these tiles will be updated mutliple times, and the 4 tiles placed will force updates on each other - which is all useless, of course.) I have thought of some methods to reduce the number of update calls drastically, I will do that soon (once the other mechanisms are in place - line drawing and filling). However, I'd be great if you could test it first, because I don't want to redo this all in case it's not working.

There are still some cases which look weird, because there's so much interpolating and when you then erase adjacent tiles, a lot of other tiles around them also dissapear. I think it works and one can draw pretty much anything one wants to, but it might sometimes not behave a 100% intuitively. Just try it out and tell me if it works for you, please, or whether it's absolutely unusable.

Edit: And also, a note on whether it runs smoothly on your system or not would be great...

Germanunkol commented 10 years ago

Works. If there are no further problems, I consider this done.