Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / Box2D and shapes substraction ? Digging with finger...

Author
Message
Riusz
8
Years of Service
User Offline
Joined: 27th Feb 2016
Location:
Posted: 4th Jan 2020 19:43
Hello,

Some phone games propose to have a 2D object like a ball and to dig the ground with the finger. The object will fall in real time.
I'm thinking how would be the best method to that with AGK.
Box2D doesn't propose to substract a cercle from a shape so the only solution I see is to use ShapeChain after doing complexe calculations…
Cuting the ground from one shape to a grid of statics shapes will surly make the calculations more easy but there's maybe something better.

Someone have another better idea ?

Thank you,
Riusz
vennis73
7
Years of Service
User Offline
Joined: 12th Sep 2016
Location:
Posted: 4th Jan 2020 20:23
I didn't think this through (not for more then the last few minutes). But i could imagine a line of dots and if the pointer comes to close to a dot, that dot would move away of the pointer.

Then if you draw lines or create a shape with help of the dots you might get an effect that resembles this?

Riusz
8
Years of Service
User Offline
Joined: 27th Feb 2016
Location:
Posted: 4th Jan 2020 21:32
Thank you vennis73 for the idea : a cirlce of dots.

With all given ideas I'll try to prototype a solution…
I'll check if your idea work with muliple objects with holes.

Exemple of game : [video=youtube]https://www.youtube.com/watch?v=TW8UtwRrMSQ[/video]
smallg
Valued Member
18
Years of Service
User Offline
Joined: 8th Dec 2005
Location: steam
Posted: 5th Jan 2020 00:28 Edited at: 5th Jan 2020 00:41
you could do it like a fog of war effect where you start with large sprites and make the areas that are near "explored"/"dug" areas become smaller sprites (so you get the desired shape definition) - it's quite a poor method for fps but probably easiest.
something like this from an old project i had, if you imagine the ships are "digging"
if i remember correctly it uses a system where you split the map into 4 sprites then based on if a ship hit a sprite it would split the sprite into 4... and repeat till no more fog is being hit or if the sprite is now too small delete it... that way areas that are not dug up can stay as a large sprite (for performance) - the only difference for you would be to create an extra system to update the images displayed (using getimage on a full image based on location of the new sprite i guess)
life's one big game
spec= i5 4ghz, 16gb ram, Nvidia 1070ti gpu
vennis73
7
Years of Service
User Offline
Joined: 12th Sep 2016
Location:
Posted: 5th Jan 2020 14:19 Edited at: 5th Jan 2020 15:22
Ok, i might gone a bit far here but i spent almost a hour on this

You could create a (virtual) grid of smaller then the size of the ball. Then create a baseline with small physical dots.

When you move the pointer to a dot, the dot dissapears and new dots are placed on the gridpoints around the pointer.
Placing the pointer in the middle of the earth would just create a circle of dots around the pointer.

Because the grid is smaller then the ball you can use plain physics for the ball to roll around. The smaller the grid the more detailed the movement will be ofcourse

edit:
Sorry the grid is a bit off in the image but you probably get the concept.

edit2:
The dots in game would be invisible but do force physics on the ball. And removing earth could be a parellel painting on an image. So you got the visual and the physical as two seperate.

Attachments

Login to view attachments

Login to post a reply

Server time is: 2024-04-24 01:22:29
Your offset time is: 2024-04-24 01:22:29