You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: examples/box2dxt-contraption-builder.livecodescript
+51-41Lines changed: 51 additions & 41 deletions
Original file line number
Diff line number
Diff line change
@@ -9149,8 +9149,8 @@ on buildRecipeBalloonLift
9149
9149
put (gArenaL+gArenaR) div2intotCx
9150
9150
putgArenaB-36intotBaseY
9151
9151
put placeBox(tCx, tBaseY, 42, 42, "120,200,232") intotBox
9152
-
b2kSetDensity tBox, 0.35-- light enough for one balloon to lift
9153
-
setthe uDensity oftBoxto0.35
9152
+
b2kSetDensity tBox, 0.1-- light enough that one balloon's buoyancy (0.6g) actually lifts it
9153
+
setthe uDensity oftBoxto0.1
9154
9154
put placeBalloon(tCx, tBaseY-150) intotBalloon
9155
9155
get connectJoint("rope", tBalloon, tBox, tCx, tBaseY-80, 0)
9156
9156
renderBuild
@@ -9162,14 +9162,15 @@ end buildRecipeBalloonLift
9162
9162
onbuildRecipePlateBomb
9163
9163
ifgModeis"run"then toggleMode
9164
9164
clearAll
9165
-
localtCx, tPlateX, tTowerX, tI, tBomb
9165
+
localtCx, tPlateX, tTowerX, tI, tBomb, tPlate
9166
9166
put (gArenaL+gArenaR) div2intotCx
9167
9167
puttCx-130intotPlateX
9168
9168
puttCx+120intotTowerX
9169
-
get placePlate(tPlateX, gArenaB-8)
9169
+
put placePlate(tPlateX, gArenaB-8)intotPlate
9170
9170
get placeBall(tPlateX, gArenaT+60, 40, "232,182,92")
9171
9171
put placeBomb(tTowerX, gArenaB-28) intotBomb
9172
-
setthe uFuseOnRun oftBombtofalse-- this bomb fires from the PLATE, not its own fuse
9172
+
setthe uFuseOnRun oftBombtofalse-- this bomb fires from the PLATE's wire, not its own fuse
9173
+
addWire tPlate, tBomb-- the trigger link (this was missing): plate -> bomb
9173
9174
repeatwithtI=1to4
9174
9175
get placeBox(tTowerX, gArenaB-66-tI*34, 46, 30, "214,92,92")
9175
9176
end repeat
@@ -9234,13 +9235,19 @@ end buildRecipeFanTower
9234
9235
onbuildRecipeMagnetCatch
9235
9236
ifgModeis"run"then toggleMode
9236
9237
clearAll
9237
-
localtCx, tCy, tMag, tI
9238
+
localtCx, tCy, tMag, tI, tLoX, tHiX, tLoY, tHiY
9238
9239
put (gArenaL+gArenaR) div2intotCx
9239
9240
put (gArenaT+gArenaB) div2intotCy
9240
9241
put placeMagnet(tCx, tCy) intotMag
9241
-
setthe uMagRange oftMagto340
9242
+
setthe uMagRange oftMagto360
9243
+
-- Scatter the balls INSIDE the magnet's reach (clamped to the arena), so every
9244
+
-- one is actually caught -- not just whichever happened to land within range.
9245
+
putmax(gArenaL+40, tCx-280) intotLoX
9246
+
putmin(gArenaR-40, tCx+280) intotHiX
9247
+
putmax(gArenaT+40, tCy-170) intotLoY
9248
+
putmin(gArenaB-50, tCy+170) intotHiY
9242
9249
repeatwithtI=1to6
9243
-
get placeBall(rnd(gArenaL+50, gArenaR-50), rnd(gArenaT+40, gArenaB-60), 30, "206,124,206")
9250
+
get placeBall(rnd(tLoX, tHiX), rnd(tLoY, tHiY), 30, "206,124,206")
9244
9251
end repeat
9245
9252
renderBuild
9246
9253
put"Magnet Catch — press Run: the magnet pulls the scattered balls toward it."intogStatus
@@ -9254,15 +9261,15 @@ on buildRecipeCatapult
9254
9261
localtCx, tBaseY, tFulcrum, tArm, tBall, tWeight
9255
9262
put (gArenaL+gArenaR) div2intotCx
9256
9263
putgArenaB-70intotBaseY
9257
-
put placeAnchor(tCx, tBaseY) intotFulcrum
9264
+
put placeAnchor(tCx, tBaseY-16) intotFulcrum-- pivot ON the arm centreline; was 16px below its CG (an unstable inverted pivot that tipped the arm over before the weight landed)
9258
9265
put placeBox(tCx, tBaseY-16, 200, 14, "180,150,90") intotArm
9259
9266
setthe uDensity oftArmto0.6
9260
9267
b2kSetDensity tArm, 0.6
9261
9268
get connectJoint("hinge", tArm, tFulcrum, tCx, tBaseY-16, 0)
9262
-
put placeBall(tCx-84, tBaseY-36, 30, "232,182,92") intotBall
9263
-
put placeBox(tCx+78, tBaseY-172, 54, 54, "214,92,92") intotWeight
9264
-
setthe uDensity oftWeightto2.6
9265
-
b2kSetDensity tWeight, 2.6
9269
+
put placeBall(tCx-84, tBaseY-39, 30, "232,182,92") intotBall-- rests on the left arm
9270
+
put placeBox(tCx+78, tBaseY-110, 54, 54, "214,92,92") intotWeight-- drops a short, fast way onto the right arm
9271
+
setthe uDensity oftWeightto3.4
9272
+
b2kSetDensity tWeight, 3.4
9266
9273
renderBuild
9267
9274
put"Catapult — press Run: the heavy block drops on the right arm and flings the ball off the left."intogStatus
put placeBox(tX+18, tBaseY+34, 66, 30, "92,70,52") intotBase-- carriage
@@ -9290,12 +9297,15 @@ on buildRecipeCannon
9290
9297
put placeBall(tX+88, tBaseY, 26, "40,42,50") intotBall-- cannonball at the muzzle
9291
9298
setthe uDensity oftBallto2.6
9292
9299
b2kSetDensity tBall, 2.6
9293
-
setthe uLaunchSpeed oftBallto1150
9294
-
setthe uLaunchDir oftBallto18--across and slightly up
9300
+
setthe uLaunchSpeed oftBallto1000
9301
+
setthe uLaunchDir oftBallto8--a near-flat shot, so it strikes the stack instead of arcing over it
9295
9302
setthe uLayer oftBallto1
9296
9303
applyCollisionLayer tBall
9297
-
repeatwithtI=0to4-- crate stack downrange
9298
-
get placeBox(gArenaR-150, gArenaB-22-tI*30, 46, 28, "200,120,80")
9304
+
-- Put the stack a fixed distance downrange (inside the flat shot's range), not
9305
+
-- at the far wall — otherwise on a wide stage the ball drops short or sails past.
9306
+
putmin(tX+688, gArenaR-110) intotStackX
9307
+
repeatwithtI=0to4-- crate stack
9308
+
get placeBox(tStackX, gArenaB-22-tI*30, 46, 28, "200,120,80")
9299
9309
end repeat
9300
9310
renderBuild
9301
9311
put"Cannon — press Run: the ball fires across the field. Knock the crate stack down!"intogStatus
@@ -9320,7 +9330,7 @@ on buildRecipeTrebuchet
9320
9330
setthe uDensity oftWeightto4
9321
9331
b2kSetDensity tWeight, 4
9322
9332
get connectJoint("weld", tWeight, tArm)
9323
-
put placeBall(tCx+162, tBaseY+6, 26, "232,182,92") intotBall
9333
+
put placeBall(tCx+162, tBaseY-19, 26, "232,182,92") intotBall-- rests ON TOP of the long arm so the whip-up flings it (was below the arm)
9324
9334
setthe uDensity oftBallto0.8
9325
9335
b2kSetDensity tBall, 0.8
9326
9336
renderBuild
@@ -9340,12 +9350,12 @@ on buildRecipeCrane
9340
9350
put placeBox(tX, tBaseY-110, 26, 220, "92,98,112") intotMast
9341
9351
setthe uBodyType oftMastto"static"
9342
9352
b2kSetType tMast, "static"
9343
-
put placeAnchor(tX, tTop) intotPivot
9344
-
put placeBox(tX+96, tTop, 210, 14, "180,150,90") intotJib
9353
+
put placeAnchor(tX+13, tTop) intotPivot-- pivot at the mast's right edge
9354
+
put placeBox(tX+118, tTop, 210, 14, "180,150,90") intotJib-- jib cantilevers RIGHT from the pivot, clear of the mast (its left end used to overlap the mast and jam the swing)
9345
9355
setthe uDensity oftJibto0.4
9346
9356
b2kSetDensity tJib, 0.4
9347
-
get connectJoint("hinge", tJib, tPivot, tX, tTop, 26) -- 26 deg/s motor swings the jib
9348
-
put placeBall(tX+184, tTop+92, 34, "232,182,92") intotLoad
9357
+
get connectJoint("hinge", tJib, tPivot, tX+13, tTop, 26)-- 26 deg/s motor swings the jib
9358
+
put placeBall(tX+200, tTop+92, 34, "232,182,92") intotLoad
9349
9359
setthe uDensity oftLoadto2
9350
9360
b2kSetDensity tLoad, 2
9351
9361
get connectJoint("rope", tJib, tLoad)
@@ -9359,31 +9369,31 @@ end buildRecipeCrane
9359
9369
onbuildRecipeWreckingBall
9360
9370
ifgModeis"run"then toggleMode
9361
9371
clearAll
9362
-
localtX, tBaseY, tTop, tLeg, tBeam, tPivot, tBall, tI
9363
-
putgArenaL+120intotX
9364
-
putgArenaB-30intotBaseY
9365
-
puttBaseY-210intotTop
9366
-
put placeBox(tX, tBaseY-105, 18, 210, "92,98,112") intotLeg
9367
-
setthe uBodyType oftLegto"static"
9368
-
b2kSetType tLeg, "static"
9369
-
put placeBox(tX+230, tBaseY-105, 18, 210, "92,98,112") intotLeg
9370
-
setthe uBodyType oftLegto"static"
9371
-
b2kSetType tLeg, "static"
9372
-
put placeBox(tX+115, tTop, 260, 16, "92,98,112") intotBeam
9372
+
localtX, tTop, tMast, tBeam, tPivot, tBall, tWallX, tI
9373
+
putgArenaL+130intotX
9374
+
putgArenaB-250intotTop
9375
+
-- A mast with a beam cantilevered to the right; the ball hangs off the beam end and
9376
+
-- swings RIGHT into the wall. (The old gantry pinned the ball between two legs, so its
9377
+
-- short arc never reached the far wall.)
9378
+
put placeBox(tX, (gArenaB+tTop) div2, 22, gArenaB-tTop, "92,98,112") intotMast
9379
+
setthe uBodyType oftMastto"static"
9380
+
b2kSetType tMast, "static"
9381
+
put placeBox(tX+100, tTop, 200, 16, "92,98,112") intotBeam
9373
9382
setthe uBodyType oftBeamto"static"
9374
9383
b2kSetType tBeam, "static"
9375
-
put placeAnchor(tX+40, tTop) intotPivot
9376
-
put placeBall(tX+40, tTop+140, 40, "60,64,74") intotBall
9377
-
setthe uDensity oftBallto4.5
9378
-
b2kSetDensity tBall, 4.5
9384
+
put placeAnchor(tX+188, tTop) intotPivot
9385
+
put placeBall(tX+188, tTop+150, 44, "60,64,74") intotBall-- heavy ball roped to the beam end
9386
+
setthe uDensity oftBallto5
9387
+
b2kSetDensity tBall, 5
9379
9388
get connectJoint("rope", tPivot, tBall)
9380
-
setthe uLaunchSpeed oftBallto540
9389
+
setthe uLaunchSpeed oftBallto600
9381
9390
setthe uLaunchDir oftBallto0-- shove right, into the wall
9391
+
puttX+300intotWallX-- inside the ball's forward swing reach
9382
9392
repeatwithtI=0to5
9383
-
get placeBox(gArenaR-160, gArenaB-22-tI*30, 60, 28, "200,120,80")
9393
+
get placeBox(tWallX, gArenaB-22-tI*30, 60, 28, "200,120,80")
9384
9394
end repeat
9385
9395
renderBuild
9386
-
put"Wrecking Ball — press Run: the ball swings into the brick wall and smashes it down."intogStatus
9396
+
put"Wrecking Ball — press Run: the ball swings off the beam into the brick wall and smashes it down."intogStatus
0 commit comments