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.

Newcomers AppGameKit Corner / Bubble-like Physics

Author
Message
trietias
8
Years of Service
User Offline
Joined: 20th Jul 2015
Location:
Posted: 20th Jul 2015 07:28
Hi all,

First and foremost, I would like to say hello to everyone. I downloaded AppGameKit through the Humble Bundle this week and have been playing around with it for the past couple of days and have been able to find out most of what I need through the help section of the AppGameKit website.

The concept of my game is that there will be bubbles floating around which the player must dodge. I have my platforms, player, and games stage set up, but am getting stuck with the bubbles.

Is there any command / function I can use to give my bubble sprite bubble-like physics? I mean for it to float instead of just dropping down like a boulder. I have looked through the command index and tried lowering the mass and damping, but it doesn't look like it changes much.

Here is what I am using for my bubbles so far:



Any help would be much appreciated. Thanks!

BONUS QUESTION:
Would there be any way for my bubbles to go through the platforms I have set up (fixed sprites) without making my player go through the platforms?

Thank you!
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 20th Jul 2015 11:00
Welcome to the forums

Thinking about how a bubble behaves...

1. It's almost weightless, so mass needs to be near zero.
2. With a mass of near zero it will ricochet around like a bullet if touched. So damping needs to be really high
3. They bounce off each other easily so restitution should be high (probably 1)
4. In a wind-free environment, a bubble would be suspended in mid-air, dropping to the ground extremely slowly. To "bounce" the bubble around the screen could be tricky. The only thing I can think of it to set restitution greater than 1. In this way, every time it collides it will increase it's inertia and then quickly drop again due to the high damping.

The only other options are to get a bit smarter and dynamically change damping to 0 at a particular velocity so they retain momentum. If the velocity increases after collision, ramp up damping until it reduces speed again.

Quidquid latine dictum sit, altum sonatur
TutCity is being rebuilt
trietias
8
Years of Service
User Offline
Joined: 20th Jul 2015
Location:
Posted: 20th Jul 2015 17:57
Wow, thanks for the quick response! I think I was confused about what the damping and restitution would do. While the bouncing isn't doing exactly what I want, it's a step forward! Thank you for the help, I will work on fine tuning it and hopefully will be posting in the AppGameKit showcase eventually

Do you have any insight on the bonus question I had? Making only a specific dynamic body (the bubble) pass through a fixed body (platforms) without letting other dynamic bodies pass through (the player)?

If not, that's okay! I'll find a way to work around it.

Thanks so much for your help!
29 games
18
Years of Service
User Offline
Joined: 23rd Nov 2005
Location: not entirely sure
Posted: 20th Jul 2015 19:33
I was having a think about your bonus question and it would depend on what you want the bubbles to do.

If you don't want or need for the bubbles to bounce off each other and the player simply loses a life if they hit one then you can turn physics off for the bubbles, have them moving around simply by adjusting their position with code - I can give examples if you want - and then do a simple sprite collision of the bubbles against the player (but not against anything else).

I'm not entirely sure if you can ignore physics based collisions between some sprites and not others - i.e. the player can have physics collision with the platform and the bubbles but the bubble can only have collision with the player. It's kind of an all or nothing situation.

Invaders of the 29th Dimension - available now on Google Play
Find me on indieDB
Van B
Moderator
21
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 20th Jul 2015 20:53
I tried something like this a while ago, with balloons, but they do work - I'm sure you'll be happy with the results.
I'll have a look and see how I did it, but it was probably straightforward - maybe just manually adding velocity each frame to each bubble... would be something like that.

trietias
8
Years of Service
User Offline
Joined: 20th Jul 2015
Location:
Posted: 20th Jul 2015 20:57
I didn't even think about turning off the physics! The first few AppGameKit tutorials on the website use physics so I guess I just didn't look past using physics in my game. I'll play around with code re-positioning for the bubble!

Any examples would be great, but I think with the help you guys have given me, I can get my desired results.

Thanks a lot guys
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 21st Jul 2015 00:14 Edited at: 21st Jul 2015 00:17
Bonus question - I did exactly this for a Bingo machine. There are 2 sets of balls that collide only with their own group. It gives a layered effect to the balls in the machine.

You do this by assigning sprites to categories - setSpriteCategoryBit(). Then you determine which categories the sprite can collide with - setSpriteCollideBit()

In your example your bubbles would be in one category (if you want them to collide with each other), and your scenery would be in another. You could set it up so that bubbles do not collide at all, and then they would overlap with one another too.

Quidquid latine dictum sit, altum sonatur
TutCity is being rebuilt
trietias
8
Years of Service
User Offline
Joined: 20th Jul 2015
Location:
Posted: 21st Jul 2015 01:54
The physics of those balls look really smooth! Right now I'm only working with one bubble and trying to get the physics down for it... but once I start splitting the bubbles up and working with having it go through the platforms, I will look into the categories.

Thank you so much for the help!
29 games
18
Years of Service
User Offline
Joined: 23rd Nov 2005
Location: not entirely sure
Posted: 21st Jul 2015 12:44
I never knew about categories before so that's good to know and someone put a rather decent example in the help file which is helpful, see link:

https://www.appgamekit.com/documentation/Reference/Sprite/SetSpriteCategoryBits.htm

However, in this specific issue with the bubble, the player needs to collide with the platform and the bubbles, but the bubbles aren't allowed to collide with the platform. But I suppose the collision between the bubbles and the player can just be done using the GetSpriteCollision() command as there isn't any need for anything else.

@trietas

If you want to have a look at non-physics based movement you can have a look at this:

http://forum.thegamecreators.com/?m=forum_view&t=208001&b=41

it's a fairly simple 2D scolling shooter which might give you some ideas.

Invaders of the 29th Dimension - available now on Google Play
Find me on indieDB
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 21st Jul 2015 13:46
Quote: "However, in this specific issue with the bubble, the player needs to collide with the platform and the bubbles, but the bubbles aren't allowed to collide with the platform."


You can set a sprite to collide with multiple categories.
You can also set a sprite to not collide with it's own category.

Quidquid latine dictum sit, altum sonatur
TutCity is being rebuilt
29 games
18
Years of Service
User Offline
Joined: 23rd Nov 2005
Location: not entirely sure
Posted: 21st Jul 2015 18:00
You learn something new every day

Invaders of the 29th Dimension - available now on Google Play
Find me on indieDB
trietias
8
Years of Service
User Offline
Joined: 20th Jul 2015
Location:
Posted: 22nd Jul 2015 04:28
Thanks for all the info and links guys. I think I'm going to try creating the game using physics and without physics to practice and I'll post something up eventually if I ever get a finished product

I started messing around with categories and they are definitely what I was looking for earlier haha.

Thanks!

Login to post a reply

Server time is: 2024-04-24 18:34:33
Your offset time is: 2024-04-24 18:34:33