[Chipmunk2D4PB] 2D Physics Engine
Re: [Chipmunk4PB] v0.1 is released (2D Physic Engine Wrapper
Thanks, i was working on a wrapper too, it will be usefull
Re: [Chipmunk4PB] v0.1 is released (2D Physic Engine Wrapper
I know.atomo wrote:Thanks, i was working on a wrapper too, it will be usefull
But it will be better you use/test the Chipmunk4PB wrapper and write some examples too
Belive!
<Wrapper>4PB, PB<game>, =QONK=, PetriDish, Movie2Image, PictureManager,...
<Wrapper>4PB, PB<game>, =QONK=, PetriDish, Movie2Image, PictureManager,...
Re: [Chipmunk4PB] v0.1 is released (2D Physic Engine Wrapper
A window with 10 bouncing boxes
Development time: 10min
http://www.morty-productions.de/icesoft ... Bounce.zip
Development time: 10min
http://www.morty-productions.de/icesoft ... Bounce.zip
Belive!
<Wrapper>4PB, PB<game>, =QONK=, PetriDish, Movie2Image, PictureManager,...
<Wrapper>4PB, PB<game>, =QONK=, PetriDish, Movie2Image, PictureManager,...
Re: [Chipmunk4PB] v0.1 is released (2D Physic Engine Wrapper
would be nice to see the sourceIceSoft wrote:A window with 10 bouncing boxes
Development time: 10min
http://www.morty-productions.de/icesoft ... Bounce.zip
Re: [Chipmunk4PB] v0.3 released (2D Physic Engine Wrapper)
Chipmunk4PB v0.3 released
Belive!
<Wrapper>4PB, PB<game>, =QONK=, PetriDish, Movie2Image, PictureManager,...
<Wrapper>4PB, PB<game>, =QONK=, PetriDish, Movie2Image, PictureManager,...
Re: [Chipmunk4PB] v0.3 released (2D Physic Engine Wrapper)
Nice.
I tried an old sample (4.X.X).
It works great but I can't detect any collision.
- Does collision detection work ? (cpArrayEach)
- Your cpSpaceEachBody function has 4 arguments. I didn't found this 4th in chipmunk doc ?
Here is my example :
I tried an old sample (4.X.X).
It works great but I can't detect any collision.
- Does collision detection work ? (cpArrayEach)
- Your cpSpaceEachBody function has 4 arguments. I didn't found this 4th in chipmunk doc ?
Here is my example :
Code: Select all
XInclude "Chipmunk4PB_v0.3.pbi"
Global *space.cpSpace
Global *staticBody.cpBody
Global ticks
Procedure DrawPolyShape(*poly.cpPolyShape)
Protected *verts.cpVect=*poly\verts
Protected *last.cpVect
Protected v.cpVect
Protected first.cpVect
Protected last.cpVect
*last=*verts+SizeOf(cpVect)*(*poly\numVerts-1)
cpvrotate(v, *last, *poly\shape\body\rot)
cpvadd(v, v, *poly\shape\body\p)
cpv(last, v\x, v\y)
For i=0 To *poly\numVerts-1
cpvrotate(v, *verts, *poly\shape\body\rot)
cpvadd(v, v, *poly\shape\body\p)
LineXY(last\x, last\y, v\x, v\y, RGB(0, 0, 0))
cpv(last, v\x, v\y)
*verts+SizeOf(cpVect)
Next
Circle(*poly\shape\body\p\x, *poly\shape\body\p\y, 2, RGB(0, 0, 255))
EndProcedure
Procedure DrawCircleShape(*circle.cpCircleShape)
Protected x=*circle\tc\x
Protected y=*circle\tc\y
Protected r.f=*circle\r
Protected a.f=*circle\shape\body\a
Circle(x, y, r)
LineXY(x, y, x+Cos(a)*r, y+Sin(a)*r)
EndProcedure
Procedure DrawSegmentShape(*seg.cpSegmentShape)
Protected a.cpVect
Protected b.cpVect
cpvrotate(a, *seg\a, *seg\shape\body\rot)
cpvrotate(b, *seg\b, *seg\shape\body\rot)
cpvadd(a, a, *seg\shape\body\p)
cpvadd(b, b, *seg\shape\body\p)
LineXY(a\x, a\y, b\x, b\y, RGB(0, 0, 0))
EndProcedure
ProcedureC DrawShape(*shape.cpShape, *datas)
Select *shape\klass\type
Case #CP_CIRCLE_SHAPE
DrawCircleShape(*shape)
Case #CP_SEGMENT_SHAPE
DrawSegmentShape(*shape)
Case #CP_POLY_SHAPE
DrawPolyShape(*shape)
EndSelect
EndProcedure
ProcedureC DrawCollisions(*arbiter.cpArbiter, *datas)
Protected i
For i=0 To *arbiter\numContacts-1
*contacts.cpContact=*arbiter\contacts+SizeOf(cpContact)*i
Circle(*contacts\p\x, *contacts\p\y, 2, #Red)
Next
EndProcedure
ProcedureC FixBodyPositions(*body.cpBody, *datas)
;check if object is offscreen
If *body\p\y>500 Or *body\p\x>680 Or *body\p\x<-20
;reset its position if necessary
*body\p\x=Random(640)
*body\p\y=-20*Random(30)
EndIf
EndProcedure
Procedure InitObjects()
Protected *shape.cpShape
Protected *body.cpBody
Protected i, j
cpInitChipmunk()
cpResetShapeIdCounter()
;{/// PHYSIC ENVIRONMENT
*staticBody=cpBodyNew(#INFINITY, #INFINITY)
*space=cpSpaceNew()
*space\iterations=5
cpv(*space\gravity, 0, 100)
cpSpaceResizeStaticHash(*space, 40.0, 999)
cpSpaceResizeActiveHash(*space, 30.0, 2999)
;}
;{/// TRIANGLES
Dim TRIANGLE.cpVect(3)
cpv(TRIANGLE(0), 15, 15)
cpv(TRIANGLE(1), 0, -10)
cpv(TRIANGLE(2), -15, 15)
For i=0 To 8
For j=0 To 5
s.l=j%2
Protected stagger.f=s*40
Protected offset.cpVect
cpv(offset, i*80+stagger, 100+(j*70) )
*shape=cpPolyShapeNew(*staticBody, ArraySize(TRIANGLE()), @TRIANGLE(), offset)
*shape\e=1.0
*shape\u=1.0
cpSpaceAddShape(*space, *shape)
Next
Next
;}
;{/// FALLING COINS
Dim COIN.cpVect(5)
For i=0 To ArraySize(COIN())-1
Protected angle.f=-2*#PI*i/ArraySize(COIN())
cpv(COIN(i), 10*Cos(angle), 10*Sin(angle))
Debug Str(10*Cos(angle))+" "+Str(10*Sin(angle))
Next
For i=0 To 299
*body=cpBodyNew(1.0, cpMomentForPoly(1.0, ArraySize(COIN()), @COIN(), cpvzero))
cpv(*body\p, Random(640), -20*Random(200) )
cpSpaceAddBody(*space, *body)
*shape=cpPolyShapeNew(*body, ArraySize(COIN()), @COIN(), cpvzero)
*shape\e=0.0
*shape\u=0.4
cpSpaceAddShape(*space, *shape)
Next
;}
EndProcedure
Procedure MoveObjects()
ticks+1
Protected steps.f=1.0
Protected dt.f=1.0/60.0/steps
Protected i
For i=0 To steps
cpSpaceStep(*space, dt)
cpSpaceEachBody(*space, @FixBodyPositions(), #Null, #Null)
Next
EndProcedure
Procedure DrawObjects()
ClearScreen(RGB(255, 255, 255))
StartDrawing(ScreenOutput())
DrawingMode(#PB_2DDrawing_Outlined)
cpSpaceHashEach(*space\activeShapes, @DrawShape(), #Null)
cpSpaceHashEach(*space\staticShapes, @DrawShape(), #Null)
DrawingMode(#PB_2DDrawing_Default)
cpArrayEach(*space\arbiters, @DrawCollisions(), #Null)
StopDrawing()
FlipBuffers()
EndProcedure
Procedure FreeObjects()
cpSpaceFree(*space)
cpBodyFree(*staticBody)
EndProcedure
InitSprite()
InitKeyboard()
InitObjects()
OpenWindow(100, 0, 0, 640, 480, "Test : Chipmunk 4.1.0 / 5.X.X - PACHINKO", #PB_Window_ScreenCentered | #PB_Window_SystemMenu)
OpenWindowedScreen(WindowID(100), 0, 0, 640, 480, 0, 0, 0)
Repeat
DrawObjects()
MoveObjects()
ExamineKeyboard()
Until KeyboardPushed(#PB_Key_Escape) Or WaitWindowEvent(1)=#PB_Event_CloseWindow
FreeObjects()
End
win10 x64 5.72 | IDE | PB plugin | Tools | Sprite | JSON | visual tool
Re: [Chipmunk4PB] v0.3 released (2D Physic Engine Wrapper)
Both are fixed. Will come with the next version.eddy wrote:It works great but I can't detect any collision.
- Does collision detection work ? (cpArrayEach)
- Your cpSpaceEachBody function has 4 arguments. I didn't found this 4th in chipmunk doc ?
Belive!
<Wrapper>4PB, PB<game>, =QONK=, PetriDish, Movie2Image, PictureManager,...
<Wrapper>4PB, PB<game>, =QONK=, PetriDish, Movie2Image, PictureManager,...
Re: [Chipmunk4PB] v0.3 released (2D Physic Engine Wrapper)
Short demo: shows the collisionshandler functions
http://www.morty-productions.de/icesoft ... andler.zip
http://www.morty-productions.de/icesoft ... andler.zip
Belive!
<Wrapper>4PB, PB<game>, =QONK=, PetriDish, Movie2Image, PictureManager,...
<Wrapper>4PB, PB<game>, =QONK=, PetriDish, Movie2Image, PictureManager,...
Re: [Chipmunk4PB] v0.4 released (2D Physic Engine Wrapper)
Update: Chipmunk4PB_v0.4:
Demo (with Source) +Collisionshandler +Constraints
Have fun!
Download link:
http://www.morty-productions.de/icesoft ... unk4PB.zip
Demo (with Source) +Collisionshandler +Constraints
Have fun!
Download link:
http://www.morty-productions.de/icesoft ... unk4PB.zip
Belive!
<Wrapper>4PB, PB<game>, =QONK=, PetriDish, Movie2Image, PictureManager,...
<Wrapper>4PB, PB<game>, =QONK=, PetriDish, Movie2Image, PictureManager,...
Re: [Chipmunk4PB] v0.4 released (2D Physic Engine Wrapper)
I created an own forum for the Chipmunk4PB Wrapper:
http://chipmunk4purebasic.freeforums.org/index.php
http://chipmunk4purebasic.freeforums.org/index.php
Belive!
<Wrapper>4PB, PB<game>, =QONK=, PetriDish, Movie2Image, PictureManager,...
<Wrapper>4PB, PB<game>, =QONK=, PetriDish, Movie2Image, PictureManager,...
- DoubleDutch
- Addict
- Posts: 3219
- Joined: Thu Aug 07, 2003 7:01 pm
- Location: United Kingdom
- Contact:
Re: [Chipmunk4PB] v0.4 released (2D Physic Engine Wrapper)
Thanks for the info, will join your forum later today.
but, imho, either this or Box2D needs to be built-in to the PB native libs.
but, imho, either this or Box2D needs to be built-in to the PB native libs.
https://deluxepixel.com <- My Business website
https://reportcomplete.com <- School end of term reports system
https://reportcomplete.com <- School end of term reports system
Re: [Chipmunk4PB] v0.4 released (2D Physic Engine Wrapper)
Here a nice example code:
http://www.file-upload.net/download-373 ... D.exe.html
http://www.file-upload.net/download-373 ... D.exe.html
Belive!
<Wrapper>4PB, PB<game>, =QONK=, PetriDish, Movie2Image, PictureManager,...
<Wrapper>4PB, PB<game>, =QONK=, PetriDish, Movie2Image, PictureManager,...
Re: [Chipmunk4PB] 7.01 Preview (2D Physic Engine Wrapper)
After a long time:
Chipmunk4PB_7.01 (preview) is available:
(it works well)
Download:
http://www.morty-productions.de/icesoft ... B_7.01.zip (143.4 KB)
Please replace on HelloNewton2D_Chipmunk4PB.pb (line 140):
Contains:
Chipmunk4PB_7.01 (preview) is available:
(it works well)
Download:
http://www.morty-productions.de/icesoft ... B_7.01.zip (143.4 KB)
Please replace on HelloNewton2D_Chipmunk4PB.pb (line 140):
Code: Select all
cpSpaceStep(*space, 0.1) with cpSpaceStep(*space, timeStep)
How to configure it:PB example file: Chipmunk4PB_7.01\HelloNewton2D_Chipmunk4PB.pb
Residents file: Chipmunk4PB_7.01\Residents\Chipmunk4PB.res
UserLibrary: Chipmunk4PB_7.01\UserLibraries\Chipmunk4PB
How to test/use it:1) Copy the Chipmunk4PB.res into folder "PureBasic\Residents"
2) Copy the Chipmunk4PB into folder "PureBasic\UserLibraries"
1) Start PureBasic => load "HelloNewton2D_Chipmunk4PB.pb" => run this example
Belive!
<Wrapper>4PB, PB<game>, =QONK=, PetriDish, Movie2Image, PictureManager,...
<Wrapper>4PB, PB<game>, =QONK=, PetriDish, Movie2Image, PictureManager,...