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 / About Shape Drawing

Author
Message
Subbir
12
Years of Service
User Offline
Joined: 20th Jun 2012
Location:
Posted: 3rd Sep 2012 11:08
How Can I draw this round shape with the physics? Its a golf game. I need to make that half round surface as a static body of the ground with collision. But as per AppGameKit tool Polygon drawing it only supports 12points. So its getting hard to draw this surface. Can Anyone help??

Subbir Rahman

Attachments

Login to view attachments
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 3rd Sep 2012 11:50 Edited at: 3rd Sep 2012 11:51
Hi Subbir, try my tool called "ShapeUp". You'll have to draw it from multiple polygons but my tool supports this. Let me know if you have any problems!

ShapeUp


this.mess = abs(sin(times#))
Subbir
12
Years of Service
User Offline
Joined: 20th Jun 2012
Location:
Posted: 3rd Sep 2012 12:42
Thaks for the quick reply.. Bt I have tried that one. But it took too many polygons to draw that circle. I Think it would be more time consuming. Is there any alternative way??

Subbir Rahman
JimHawkins
15
Years of Service
User Offline
Joined: 26th Jul 2009
Location: Hull - UK
Posted: 3rd Sep 2012 12:52
SetSpriteShape allows to to specify a circle rather than a polygon. Would that not do?

-- Jim DO IT FASTER, EASIER AND BETTER WITH AppGameKit FOR PASCAL
Subbir
12
Years of Service
User Offline
Joined: 20th Jun 2012
Location:
Posted: 3rd Sep 2012 13:08
I dont have the full circle. It more than half. Thats why it creates problem. SetSpriteShape works almost same as declaring a sprite polygon. It can only draw 12 point. It doesn't work

Subbir Rahman
Marl
13
Years of Service
User Offline
Joined: 19th Nov 2011
Location: Bradford, UK
Posted: 3rd Sep 2012 13:39 Edited at: 3rd Sep 2012 13:40
Are you talking about area which represents the green?

If so - and you are wanting collision with the outside of the green - then you could make it from several shapes, that way each one gets the 12 points.

edit: embed (poorly sketched) image

Attachments

Login to view attachments
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 3rd Sep 2012 13:43
It's also an inverted circle. I'm surprised my tool didn't work, I didn't know there was a limit to the number of polygons allowed by a single object in box2d?


this.mess = abs(sin(times#))
Hodgey
15
Years of Service
User Offline
Joined: 10th Oct 2009
Location: Australia
Posted: 3rd Sep 2012 13:54
@baxslash: Looks like it.

I'm not a big user of AppGameKit physics (don't really need it yet) but skimming over the commands it could be possible to take it off autopilot and program the physics for the almost-circle yourself. Using a bit of trigonometry, distance-checking and Get/SetSpritePhysicsVelocity you could theoretically do it. I don't have time to write up a demo right now but when I get the chance, I'll give it a shot (unless someone else has solved the dilema) .

Subbir
12
Years of Service
User Offline
Joined: 20th Jun 2012
Location:
Posted: 3rd Sep 2012 14:10
Thanks Marl.... That Logic is less time consuming..

Subbir Rahman
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 3rd Sep 2012 15:09 Edited at: 3rd Sep 2012 15:09
Marl's shapes won't quite work as they are concave in shape. You'll have to use a number of smaller shapes like this:



this.mess = abs(sin(times#))

Attachments

Login to view attachments
bjadams
AGK Backer
16
Years of Service
User Offline
Joined: 29th Mar 2008
Location:
Posted: 3rd Sep 2012 23:36
Shapeup is the best AppGameKit tool out there!
Subbir
12
Years of Service
User Offline
Joined: 20th Jun 2012
Location:
Posted: 4th Sep 2012 08:27
Thanks baxslash. U have made a great tool...

Subbir Rahman
Subbir
12
Years of Service
User Offline
Joined: 20th Jun 2012
Location:
Posted: 5th Sep 2012 08:20 Edited at: 5th Sep 2012 09:09
I am facing some problem with converting the loadPhysicsSprite into native Xcode language. I have converted it like this way:



But the app is Not drawing the shapes. I have the background and all other images, but the static shapes r not in there. So what I have is the image only. Can you help me out of this problem? It works fine in AppGameKit, but creating problem in Xcode

@@@@baxslash

Subbir Rahman
Subbir
12
Years of Service
User Offline
Joined: 20th Jun 2012
Location:
Posted: 5th Sep 2012 10:26
I have solved the problem. Thanks to Baxslash who have made this great tool. It saves thousands of minutes to draw a level.

The solved code is here:



Subbir Rahman
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 5th Sep 2012 11:13
Glad to help


this.mess = abs(sin(times#))
Subbir
12
Years of Service
User Offline
Joined: 20th Jun 2012
Location:
Posted: 24th Sep 2012 13:09
Can U please tell me the way to delete those shapes from the code?

I have called this function like this:
loadPhysicsSprite(480, 320, 240.0, 160.0, "LevelFourBak.png", 3, 3)

where the last 3 is the imagenum. I Do have a lots of polygon as shown above to draw the circle arounD the whole. I have written the code to delete those shapes like this:

SetSpritePhysicsDelete(3)
ClearSpriteShapes(3)
DeleteSprite(3)

But its not working. It is saying that Sprite 3 is not existed in AppGameKit root. What am I suppose to do?

Subbir Rahman
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 24th Sep 2012 13:15
My original function returns the number of the sprite created. Perhaps you should use it that way so you know the number of the sprite created? Are you perhaps using imagenum 3 more than once?


this.mess = abs(sin(times#))
Subbir
12
Years of Service
User Offline
Joined: 20th Jun 2012
Location:
Posted: 24th Sep 2012 13:39
No. I have used this number only one time. Can u give me a sample code how to delete those shapes?

Subbir Rahman
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 24th Sep 2012 13:42
Quote: "It is saying that Sprite 3 is not existed in AppGameKit root."

Can you work out which line of code is causing this exception?
SetSpritePhysicsDelete(3)
ClearSpriteShapes(3)
or DeleteSprite(3)?

Unless you are deleting the sprite somewhere else in your code then it should exist...

You could try using setSpriteShape(3,0). That should remove any existing shapes on the sprite but if the sprite has been deleted it will just throw an exception.


this.mess = abs(sin(times#))
Subbir
12
Years of Service
User Offline
Joined: 20th Jun 2012
Location:
Posted: 24th Sep 2012 13:49
Yes.. It works at here: SetSpritePhysicsDelete(3)
if u comment this line, then it works at here: ClearSpriteShapes(3)

I have tried to work with SetSpriteShape(3,0). But it shows the same error.

Subbir Rahman
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 24th Sep 2012 13:51
Are you perhaps checking for physics collisions with sprite 3 somewhere? If you are checking for collisions on a sprite with no shape it will possibly throw this error.

Mind if I ask why you are deleting the shape and not the sprite?


this.mess = abs(sin(times#))
Subbir
12
Years of Service
User Offline
Joined: 20th Jun 2012
Location:
Posted: 24th Sep 2012 13:58
Ohh.. SUre... I have implimented 17levels of this game. I have removed every shapes and physics and then drawing them again. So I have drawn those shapes and then delete them to draw another level. Bt I dont check them for collision. Bt they r static walls. Is this the reason they r not deleting? I am surprised the it is saying that sprite 3 is not existing at root ...

Subbir Rahman
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 24th Sep 2012 14:01
No, static shapes should delete fine. I just thought if you were doing a check on a sprite with no shape it might cause the problem. "root" just means the root / main source file I believe.

So whatever line is causing the problem is in that file.


this.mess = abs(sin(times#))
Subbir
12
Years of Service
User Offline
Joined: 20th Jun 2012
Location:
Posted: 24th Sep 2012 14:03
Thanks.. Because I am confused with the word root. I have several files in my project. But it only saying that it occurs in root.

Subbir Rahman
Subbir
12
Years of Service
User Offline
Joined: 20th Jun 2012
Location:
Posted: 24th Sep 2012 14:04
Bt the funny thing is its working fine in xcode template. I have deleted those sahpes. But its not working in AGK..

Subbir Rahman
Cliff Mellangard 3DEGS
Developer
18
Years of Service
User Offline
Joined: 20th Feb 2006
Location: Sweden
Posted: 24th Sep 2012 18:29 Edited at: 24th Sep 2012 18:37
Quote: "Thanks.. Because I am confused with the word root. I have several files in my project. But it only saying that it occurs in root."


It means the main file

All apps start with an file called main that is refferred as root when an error occurs.

I get this alot when fooling around

Edited .........
Sorry bax already answered that

Couldt you test by doing this?

If sprite exits(3)
delete sprite (3)
endif

And a simple question is that if you delete the sprite it self last after the shapes?

Could throw you an error if you delete the sprite and then the shapes after!

My only excuse today is that iam extremely tired ZZZzzzzz

Android 2.3 Gingerbread , ZTE Skate , 480x800 , 800 mhz cpu , Samsung Galaxy Y , 240x320 , 832 mhz cpu
Android 4.0 Sandwich , Dmtech 3g 9738B , 1024x768 , 9.7 inches , cortex A8 1.2 cpu , 1 gb ram.
Subbir
12
Years of Service
User Offline
Joined: 20th Jun 2012
Location:
Posted: 25th Sep 2012 08:09 Edited at: 25th Sep 2012 08:19
Thanks cliff. I have tested it by several way. Here is my code


I have the array of allSprite. I am deleting it one by one. After deleting the sprite I am marking that position of the array by 0. If I dont clear shapes it runs. Every other shapes are deleting except the 3 sprite which I have configured with the ShapeUp tool. If I add clearSpriteShapes(allSprites[i]) then compiler error occur. I am attaching the error as pic.

Subbir Rahman

Attachments

Login to view attachments
Subbir
12
Years of Service
User Offline
Joined: 20th Jun 2012
Location:
Posted: 25th Sep 2012 09:19
Well Finally I have found the problem.

baxslash have used the sprite variable instead the sprite index.

Here is the code after modify:



Now it will remove the shapes as well as the image also.

Subbir Rahman
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 25th Sep 2012 12:44
I guess in your case it might be ok to use the same image number as the sprite index but in most cases this is not advisable, otherwise you cannot have two sprites that use the same image.


this.mess = abs(sin(times#))
Subbir
12
Years of Service
User Offline
Joined: 20th Jun 2012
Location:
Posted: 26th Sep 2012 08:03
Yahh.. Thanks. Its not possible. In my case it works. Thanks again for ur help and the great tool.

Subbir Rahman

Login to post a reply

Server time is: 2024-11-24 00:03:37
Your offset time is: 2024-11-24 00:03:37