Pixel-by-pixel destructible terrain?[Yup, why not]

Get help using Construct 2

Post » Tue Dec 24, 2013 3:01 pm

Pixel by pixel isn't so bad if you split a tile-able image into 1 pixel tiles, and use the rectangle tool to place multiple tiles. Like the bitwise/ Salt method.

Then again Im quite sure the mask method would work using an fx.

Edit:

Scratch that first suggestion, it seems a bunch of different tiles really brings the fps down!
It might work if it wasn't all 1 pixel. 2, 4, or 8 might be ok, but you might run into symmetry issues finding a single point in an even number.newt2013-12-24 15:34:37
Image ImageImage
B
168
S
50
G
169
Posts: 8,282
Reputation: 108,193

Post » Tue Dec 24, 2013 4:31 pm

Looks like the Overlay fx will work nicely.

Also its painfully hard to edit anything at that size without a zoom in the tiles menu. I noticed Tiled does not have that feature either. Any possibilities there @Ashley?

If not perhaps some other type, or new object would be better suited for this. I say that since it seems one pixel is the way to go.
Image ImageImage
B
168
S
50
G
169
Posts: 8,282
Reputation: 108,193

Post » Tue Dec 24, 2013 4:35 pm

Tiled has a drop-down to increase the size of the tileset.
If your vision so exceeds your ability, then look to something closer.
Moderator
B
134
S
30
G
84
Posts: 5,375
Reputation: 58,432

Post » Tue Dec 24, 2013 5:24 pm

@newt I still think that filling entire tilemap by hand inside layout editor.. with 1px tiles.. is a real pain in the butt, pardon my french.
At least until we get an adjustable "tile brush" or something like that.

I guess, generating tilemap (as a collision mask, just one tile) and using sprites as a reference is a way to go. Probably I'm wrong:(

And i really have no idea how to implement generation of non-rectangular shapes, due to the limitaions of C2 and tilemap system.

@Everyone and especially @R0J0hound :P
=
( Caution! Abusive logic detected. Author is not responsible for any brain damage caused by reading the following text )
=
But! Imagine that we have a method to detect alphachannel value of a particular pixel in a raster image?
Something like pixelalpha(x,y)=[0..255]. Where (x,y) is the position of the pixel inside an image.
(I believe it's not too hard to implement it as plugin or something..
No idea how it works, tho :P)

Then we could set up our layout with sprite scenery( lets call it MaskSprites ), like I did in the example..
NOTE that MaskSprites should have origin at top-left.
On start of layout we just need to populate a huge array.
Here it gets tricky and will definitely take a while to do..
So, for each MaskSprite we run a loop like

|   for i from 0 to MaskSprite.width
|     {
|        for j from 0 to MaskSprite.height
|          {
|             if pixelalpha(i,j)=255 set Tilemap At(MaskSprite.X + i, MaskSprite.Y + j)
|          }
|     }

So we'll get our collisionmask tilemap generated, following the shape of all MaskSprites we have.. And we have our layout scenery underneath. Then give our tilemap something like Addictive blendmode or Overlay fx and TADAM! We have our level :D

Does that make any sense, guys?:P

UPD: I do understand that generating entire level each time we start our layout ingame is insane xD
But we can use it in level editor or something, then save our tilemap as JSON( or however we save tilemaps ) and just load it from that file?JJList2013-12-24 18:01:59
B
18
S
5
G
1
Posts: 74
Reputation: 2,672

Post » Tue Dec 24, 2013 6:09 pm

I think your best bet is to do a separate editor, and load a map at runtime, perhaps using Rojo's Canvas plug. It can do per pixel comparisons.
The reason for that is that kind of generation would take a long time.

As to the corners:
http://www.saltgames.com/2010/a-bitwise-method-for-applying-tilemaps/

Seems to me you could check the offset for more than one tile.
Image ImageImage
B
168
S
50
G
169
Posts: 8,282
Reputation: 108,193

Post » Tue Dec 24, 2013 7:18 pm

@newt Indeed, I've been thinking of a separate editor for the last hour or so:) Maybe even like a simple raster editor.. MSPaint via tilemaps, huh?:)

But I would still like to know, if the method I've described is possible ^_^
Ofcourse, this way of generation will take a while.
And I don't really mind it:) I mean, we'll need to do it just once per generated level, inside a level editor.. Then we save tilemap to a file and simply use that file in our game. So, in this case, does it really matter how long it takes to generate?
Well, not speaking about 4096x4096 sprites xD
Let's say, we have a level built of 100 MaskSprites, 64x32 each.
To generate this one, we'll need to run 100 loops, 2048 iterations each.. That doesn't really sound like eternity to me;))JJList2013-12-24 19:45:50
B
18
S
5
G
1
Posts: 74
Reputation: 2,672

Post » Tue Dec 24, 2013 7:55 pm

That's completely doable, just take a look at the Canvas object's Canvas.rgbaAt(), or Canvas.alphaAt().

Personally I would just fill a layer with tiles, and erase those not needed by using the mouse, and layer scale.
Image ImageImage
B
168
S
50
G
169
Posts: 8,282
Reputation: 108,193

Post » Tue Dec 24, 2013 8:11 pm

@newt Thanks! :D I will definitely look into Canvas plugin:) Haven't tried it yet

[QUOTE=newt]Personally I would just fill a layer with tiles, and erase those not needed by using the mouse, and layer scale.[/QUOTE]

Yeah that'd be easy for simple shapes.. But if we want some complex scenery?:)

Anyways, thanks for help again:D
I'm now working on a tilemap editor, and I'll try both methods to compare them:)

(Tho using Canvas object is a brillinat idea, question about pixelalpha(x,y) as a regular expresson is still up :P)

Hopefully I'll get it running in a couple of hours ^_^
B
18
S
5
G
1
Posts: 74
Reputation: 2,672

Post » Tue Dec 24, 2013 9:55 pm

Btw, take a look at tilemap+physics :)
link
B
18
S
5
G
1
Posts: 74
Reputation: 2,672

Post » Tue Dec 24, 2013 10:50 pm

:o thats pretty sexy *assimilates*
Who dares wins
B
57
S
17
G
21
Posts: 1,878
Reputation: 19,562

PreviousNext

Return to How do I....?

Who is online

Users browsing this forum: plinkie and 30 guests