// Project: weld joints
// Created: 2015-06-29
// set window properties
SetWindowTitle( "weld joints" )
SetWindowSize( 1024, 768, 0 )
// set display properties
SetVirtualResolution( 1024, 768 )
SetOrientationAllowed( 1, 1, 1, 1 )
obstacle = createSprite(0)
setSpriteSize(obstacle, 200, 200)
setSpritePositionByOffset(obstacle, 552, 550)
setSpritePhysicsOn(obstacle, 1)
dim sprites[5] as integer
for n = 1 to 5
spr = createSprite(0)
setSpriteColor(spr, 255, 50, 50, 255)
setSpriteSize(spr, 64, 64)
setSpritePositionByOffset(spr, 200 + (n * 64), 100)
setSpritePhysicsOn(spr, 2)
sprites[n] = spr
if n > 1
createWeldJoint(sprites[n], sprites[n], sprites[n-1], getSpriteXbyOffset(sprites[n-1]) + 32, getSpriteYByOffset(sprites[n-1]), 0)
endIf
next n
setPrintSize(20)
setPhysicsDebugOn()
state = 1
do
if state = 3
print("Example 3: SetSpritePhysicsCanRotate is set to 0 on all five sprites")
print("Click mouse to end program")
elseIf state = 2
print("Example 2: SetSpritePhysicsCanRotate is set to 0 on ONE sprite (the third one)")
print("Click mouse for next example")
if getPointerPressed() = 1
inc state
for n = 1 to 5
setSpritePhysicsVelocity(sprites[n], 0, 0)
setSpriteAngle(sprites[n], 0)
setSpritePositionByOffset(sprites[n], 200 + (n * 64), 100)
setSpritePhysicsCanRotate(sprites[n], 0)
next n
endIf
elseIf state = 1
print("Example 1: SetSpritePhysicsCanRotate is 1 on every sprite")
print("Click mouse for next example")
if getPointerPressed() = 1
inc state
for n = 1 to 5
setSpritePhysicsVelocity(sprites[n], 0, 0)
setSpriteAngle(sprites[n], 0)
setSpritePositionByOffset(sprites[n], 200 + (n * 64), 100)
setSpritePhysicsCanRotate(sprites[3], 0)
next n
endIf
endIf
Sync()
loop
There, I've included the exe in this post as well if someone doesn't feel like compiling it
My hovercraft is full of eels