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 / Physics platform game

Author
Message
Max Tillberg
18
Years of Service
User Offline
Joined: 16th Jul 2005
Location:
Posted: 29th Jul 2013 12:57
I am making a physics platfrom game with a complex geometry and I wonder how I can create the ground? I notised that AppGameKit does not support the box2d chain shape. I am thinking of using lots of sprites but they do not have that many surfaces. I also need some way to define the different surfaces like "ground", "wall" and so on for collision detection and wonder if it is possible to group them somehow?

Sincerely,
Max Tillberg
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 29th Jul 2013 13:11 Edited at: 29th Jul 2013 13:14
for the sprite shape you can use max. 12 points then you need
a new sprite.
maybe you can use sprites as block(line) as your surface.
i think you need a little level editor for it.
(can you upload a level pic?)

my favorite functions:
SetSpriteGroup wall/ground/...
GetSpriteGroup at collision

GetSpriteFirstContact
GetSpriteNextContact
GetSpriteContactSpriteID2
GetSpriteContactWorldX
GetSpriteContactWorldY
Van B
Moderator
21
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 29th Jul 2013 13:32
If you add the shape lines manually, then you can have more than 12 - I have these massive planet sprites, and I use a 1D heightmap to calculate the sprite shape, adding each line in turn through 360 degrees.

This can be complicated, but it might be the only way - like making a poly shape editor, to let you add lines to a sprite and save and reload the data. Automatically calculating a sprite shape can be slow and innacurate, and doesn't leave you with a lot of control. For example, if you have a tree sprite, you might only want to collide with some of the branches, so being able to specify the polygon shape with an editor would let you do that - wheras auto-shaping would probably give you terrible results, or you'd have to use seperate sprites.

I suggest taking a little time to make a poly shape editor, I think you need that level of control and a removal of that 12 line auto-shape limit to do things right.

I got a fever, and the only prescription, is more memes.
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 29th Jul 2013 13:45
Alternatively you can download my shape editor for free: Shape Up


this.mess = abs(sin(times#))
Max Tillberg
18
Years of Service
User Offline
Joined: 16th Jul 2005
Location:
Posted: 29th Jul 2013 14:58
Thanks a lot, the shape editor looks very useful. The platform is actually a tree (not very original I know) inspired by the art of Peter McClory http://petermcclory.com/2010/04/experimenting-with-homemade-photoshop-brushes/ To check for collisions right now I use something like this


Would it be possible to use SpriteGroup or some other method to group the sprited depending on the usage (ground, ladders, walls, items and so on)?

Sincerely,
Max Tillberg
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 29th Jul 2013 15:00
Quote: "Thanks a lot, the shape editor looks very useful."

You're welcome

Quote: "Would it be possible to use SpriteGroup or some other method to group the sprited depending on the usage (ground, ladders, walls, items and so on)?"

Yes, just use setSpriteGroup(spriteID, groupID) to set the group of a sprite as Markus suggested, you can then test collisions against these groups.


this.mess = abs(sin(times#))
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 29th Jul 2013 15:21
... the collision check n:m is not really fast.
using GetSpriteFirst/NextContact is much better.
in GetSpriteContactSpriteID2 you have the group id you had set before.
Max Tillberg
18
Years of Service
User Offline
Joined: 16th Jul 2005
Location:
Posted: 3rd Sep 2013 10:26
Hmm, this was harder than I thought. Could someone help me with an example to make a physics collision check between sprite number one and sprite group number 2?

Sincerely,
Max Tillberg
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 3rd Sep 2013 11:22 Edited at: 3rd Sep 2013 11:23
This function will return 1 if a sprite collides with a specific group and 0 if not:


EDIT: fixed blooper

"Here I am trying to do some good for the world..." - Fluffy Rabbit
Max Tillberg
18
Years of Service
User Offline
Joined: 16th Jul 2005
Location:
Posted: 3rd Sep 2013 11:40
A complete function! You are the best baxslash. By the way it worked great but I guess you knew that

Sincerely,
Max Tillberg
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 3rd Sep 2013 12:36
Quote: "A complete function! You are the best baxslash. By the way it worked great but I guess you knew that"

Glad to hear it I coded here without checking if it worked but I had a feeling it was right after fixing the minor blooper

"Here I am trying to do some good for the world..." - Fluffy Rabbit

Login to post a reply

Server time is: 2024-05-09 08:21:47
Your offset time is: 2024-05-09 08:21:47