Simple Scorched Earth, Worms game

Get help using Construct 2

Post » Mon Dec 11, 2017 12:42 pm

I think I’ve answered better many times in the past. To read pixels of an image you need a plugin like canvas. To read the collision polygon of a sprite per pixel you could use a bunch of overlapping point checks.
B
94
S
33
G
122
Posts: 5,443
Reputation: 77,949

Post » Mon Dec 11, 2017 12:48 pm

Here is an idea - set "Blend mode=source atop" for buildings and use tilemap as a mask. (and also as a solid surface for tanks)

https://www.dropbox.com/s/bpy9vgw7df50z ... .capx?dl=0
Image

Did I help to fix a problem in your game? You can buy me a cup of coffee :) If you'd like to hire me, please see this post
B
17
S
9
G
100
Posts: 1,427
Reputation: 53,921

Post » Mon Dec 11, 2017 2:33 pm

dop2000 wrote:Here is an idea - set "Blend mode=source atop" for buildings and use tilemap as a mask. (and also as a solid surface for tanks)

https://www.dropbox.com/s/bpy9vgw7df50z ... .capx?dl=0


Oh! The source Atop do the job well, thanks :D

But i not understand why you dfill the objects in that way, is more faster/optimized after in runtime than this?:
https://cdn.pbrd.co/images/GXI2AX5.png

Ok, so now only the sprites with alpha left, so i guess in this case is use the canvas plugin to detect the alpha and erase the tiles with them or rework the tiles addition to run all coordinates in the canvas an set 1 tile in the tilemap for the ones that not have alpha, i don't know wich one will be better. BTW, i guess if after run i can save it as .json as described and load fast i think no matter.

PD: @dop2000 i bought you a coffe, i think, i don't know how much cost in australia XD
B
27
S
10
G
3
Posts: 619
Reputation: 4,690

Post » Mon Dec 11, 2017 3:10 pm

@matriax
Yes, your method of building tilemap is definitely better if buildings are rectangular. With complex shape buildings you might need to check overlapping for every pixel.

What do you mean by sprites with alpha? Your buildings will have transparent parts ("windows") and you want to remove tiles in windows?
You can make windows as another separate invisible sprite.
So first you fill tiles where building sprites are, then erase tiles where window sprites are.

Edit: Made a demo, with complex-shaped windows!
https://www.dropbox.com/s/sywx2gcxi9qsh ... .capx?dl=0

Cheers for the coffee! :)
Although it's all based on R0j0's original idea, you should be thanking him.
Image

Did I help to fix a problem in your game? You can buy me a cup of coffee :) If you'd like to hire me, please see this post
B
17
S
9
G
100
Posts: 1,427
Reputation: 53,921

Post » Mon Dec 11, 2017 5:10 pm

@dop2000

"With complex shape buildings you might need to check overlapping for every pixel."

Are you saying is possible do complex buildings or recreate sprites with alpha in tileson tilemap without use the canvas plugin or i misunderstood you? :O if true, how? In your examples i tried to modify the sprite but not just fill the rectangular.

Love what you did with the complex windows, maybe i can use that for explosion to make complex holes instead the round one.


EDIT: Oh! :O just realized that changin the erase tile by set tile in your last example you can recreate that sprite based on their collision that is great. Wonder if there is a way to make them pixel precise using the sprite transparency instead the collision, but here maybe the canvas plugin is required
B
27
S
10
G
3
Posts: 619
Reputation: 4,690

Post » Tue Dec 12, 2017 12:48 am

Yeah, if you need very complex (or non-polygon, rounded etc.) shapes and pixel precision, the only option is canvas plugin.
Or you can make some shapes like pixel-perfect circles, ovals, sine waves etc. with math formulas.
Image

Did I help to fix a problem in your game? You can buy me a cup of coffee :) If you'd like to hire me, please see this post
B
17
S
9
G
100
Posts: 1,427
Reputation: 53,921

Post » Tue Dec 12, 2017 1:34 am

I see, at the moment i will continue without canvas plugin wonder the limit i can go .

Also was thinking on destructible moving objects and if i'm right to do that will be something like:

On start layout + for each SpriteMovable(Family) create a tilemap with Sprite width/height, set tiles for the sprite form and pin pos+angle. I don't know if i'm missing something.

If all this is possible(And perfomance is still good) i can see a good destruction game here, i'm gonna do some tests :P
B
27
S
10
G
3
Posts: 619
Reputation: 4,690

Post » Tue Dec 12, 2017 2:30 am

If there are performance issues, try increasing the tile size to 2x2. The edges will look a little bit rougher but the performance should be much better.

I just noticed than in my demo there are 2 identical instances of tilemap object, one on top of another. And it still works pretty fast :)
Image

Did I help to fix a problem in your game? You can buy me a cup of coffee :) If you'd like to hire me, please see this post
B
17
S
9
G
100
Posts: 1,427
Reputation: 53,921

Post » Tue Dec 12, 2017 2:44 am

This is probably off from the direction you're going but here is a way to get the pixels of an image without the canvas plugin.
https://www.dropbox.com/s/soijvpnt8vjkc ... .capx?dl=1

It actually just gets the alpha as in transparent 0 or not 1. Every line is separated by a newline.
It could be modified to give a width and height then a list of pixels but as is is fine imo.

Anyways it may be useful to someone. To make it work with C3 all that should be needed is to replace 'c2_callFunction' with 'c3_callFunction' in the js file in the files folder.
B
94
S
33
G
122
Posts: 5,443
Reputation: 77,949

Post » Tue Dec 12, 2017 2:51 am

Wow, R0J0hound, you never seize to amaze!
Image

Did I help to fix a problem in your game? You can buy me a cup of coffee :) If you'd like to hire me, please see this post
B
17
S
9
G
100
Posts: 1,427
Reputation: 53,921

PreviousNext

Return to How do I....?

Who is online

Users browsing this forum: No registered users and 46 guests