Re: Euphoria Chipmunk Physics

new topic     » goto parent     » topic index » view thread      » older message » newer message

Well I have tried my hand at this again. http://www.rapideuphoria.com/uploads/euchipmunkphy.zip

I re-wrote the sequence parts as atoms and declared them as C_FLOATS. While this isn't perfect, I believe it is a step up. I also started work on a demo, but I got machine level exception errors on some calls. The commands commented out are where the machine-level exceptions occur. I simply treat cpVect and cpv as two separate x and y vars. I have declared them in the wrapper like this as well.

--Demo not currently working 
include std/machine.e 
include std/get.e 
 
include EuChipmunk.ew 
 
atom grav_x = 0 
atom grav_y = -100 
 
sequence gravity = {grav_x,grav_y} 
 
atom space = cpSpaceNew() 
cpSpaceSetGravity(space,gravity[1],gravity[2]) 
 
atom ground = cpSegmentShapeNew(cpSpaceGetStaticBody(space),-20,5,20,-5,0) 
cpShapeSetFriction(ground,1) 
cpSpaceAddShape(space,ground) 
 
atom radius = 5 
atom mass = 1 
 
atom moment = cpMomentForCircle(mass,0,radius,0,0) 
atom ballBody = cpSpaceAddBody(space,cpBodyNew(mass,moment)) 
 
--cpBodySetPos(ballBody,0,15) 
 
atom ballShape = cpSpaceAddShape(space,cpCircleShapeNew(ballBody,radius,0,0)) 
cpShapeSetFriction(ballShape,0.7) 
 
atom timeStep = 1.0 / 60.0 
 
--atom pos = cpBodyGetPosition(ballBody) 
--atom vel = cpBodyGetVelocity(ballBody) 
 
cpSpaceStep(space,timeStep) 
 
printf(1,"Ball: %d",{ballBody}) 
position(2,1) 
puts(1,"Press ESC to exit!\n") 
 
integer key  
while 1 do 
	key = get_key() 
	 
	if key = 27 then 
		exit 
	end if 
end while 
 
cpShapeFree(ballShape) 
cpBodyFree(ballBody) 
cpShapeFree(ground) 
cpSpaceFree(space) 
 
new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu