Terraria

0 favourites
From the Asset Store
An advanced inventory example similar to Terraria.
  • Thanks, I'll check it out!

  • I played with making 2D minecraft style and lighting a while back, still have the source if interested?

    Not sure if it could help at all?

    Demo here:

    andygilbertphotography.co.uk/noname/index.html

    WASD and Mouse. There is a ambient light that follows the player and you can place lamps, also has dynamics shadows.

    Andy

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Very cool. If you don't mind sharing the source, I would take it.

  • AllanR

    I think I already have that project file and it's not really what I was looking for, but thanks anyway.

  • bump.

  • Had a go at attempting to replicate the effect, since it's not super clear how it works. I used C2 and the paster plugin for drawing and compositing. C3 may be able to do the drawing in some other way.

    My first attempt just used a shadowcaster blended with a radial gradient to do the shadows. Made lowres with a lower res paster object. The next step would be to do some kind of bloom to feather the lit area to light the surrounding walls. Maybe could be done with a shader, maybe. Anyways, I stopped there.

    dropbox.com/s/g068azvan5t3m7y/shadowtest.capx

    The next test did a kind of weighted flood fill to expand light gradually outward from a mouse click. When a wall is hit it wouldn't stop the light but make it reduce quicker. Used sprites as a test and only runs on a click.

    dropbox.com/s/0m9gm2fuqz5tdrn/shadowtest2.capx

    The third test used a weighted flood fill as well but in a different way. It referenced a tilemap for walls and used some arrays to keep track of stuff while flood filling. Paster was merely used here to draw the shadow area. The lit area is carved out with a destnation-out blend.

    dropbox.com/s/eo7iafxuoh3fsmz/shadowtest3.capx

    A hybrid between the first and third could look alright. Colored lights could be done with more blending modes with paster instances to do the multiple steps one by one. In C3 you may just need apply the ideas in a similar but different way since paster doesn't run there.

    Anyways just some ideas.

  • Sorry, when I aid in my earlier post that I have the source which you can have.. I should of checked i actually did have it!

    I never every delete old project files but I had realised I did this in C2 and have used C3 for over a year now so I have at a bit of a loss as to where my older C2 project files are.

    I will keep on searching, once found I will be sure to upload it for you.

    Andy

  • Wow! You guys are awesome! Thank you!

  • R0J0hound

    I do not have the paster plugin. I have your other 'canvas' one in C2 for a project I had to open a while back. So far I have been using the second example. Is there any way to do a light strength? For example, if the strength was 1, it would light up one or two blocks. 2 would light up two of three blocks, ect. I would think you could do a function with a parameter called 'brightness'. And then when you click it will call the function with either a set or random brightness.

    Anyway the example is very good. Also would it would be possible to migrate the third example into the 'canvas' plugin so I could open it? If so it would be appreciated.

    Thank you

  • Canvas is obsolete, but here is the third example done without paster at all:

    dropbox.com/s/xrukzy9cdv8p5az/shadowtest4.capx

    Paster just lets it blend more.

  • That's really neat r0j0

  • WackyToaster

    Thanks

    I wasn't satisfied with the diamond shape, so here it is more rounded. Octagonal really. Also changed the falloff rate of light.

    dropbox.com/s/bw3lcf08ascchtv/shadowtest5.capx

    Another tweak to see if i could make it cast shadows instead of wrapping around as much. Ended up looking the same, but should do less checks.

    dropbox.com/s/tr4m8p6burf5uzt/shadowtest6.capx

  • That is utterly AWESOME!!! If nobody ever mentioned you were a genius I just did. . . Thank you sooooo much!

  • Is there a way to change the light strength? Or color?

  • You can change the "steps" variable to control the strength of the light. The default is 20, which makes a 20*8 or 160 pixel radius light.

    Color light is probably done the same way you'd color lights with the shadow caster.

    Here's one way that doubles the amount of objects. Basically a layer to do the shadow, and another layer with the light color which is blended with the scene. This also animates the color and strength of the light.

    dropbox.com/s/y3m0iq02z0b3jbp/shadowtest7.capx

    Multiple lights would be done by doing each light separately and combining the shadow and color layers of each. As is the performance isn't good enough to do that. Also I'd want to reintroduce something like paster to handle the mixing instead of juggling layers.

    It's as far as I'll go with this for now. A significant speedup can be done by doing the floodfill algo with javascript, and the drawing should be simpler/faster to draw directly to textures for the shadows and colors. Less overhead at least, not my cup of tea to do that mixed with construct though.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)