Hi,
We've added a COPY button to the code section. For example below, open up the code and to the right you can Copy the code from that section, ready to be pasted into AppGameKit IDE.
// set window properties
SetWindowTitle( "Simple Penny Falls" )
SetWindowSize( 1024, 768, 0 )
// set display properties
SetVirtualResolution( 1024, 768 )
SetOrientationAllowed( 1, 1, 1, 1 )
SetScissor(0,0,0,0)
// Tell AppGameKit we are going to be using 3D physics
Create3DPhysicsWorld()
// Create and position a box (the 'pusher' to our penny falls machine)
createObjectBox( 1, 300,20,120 )
SetObjectColor(1,50,50,255,255)
SetObjectPosition(1,0,-10,105)
// Let the physics engine know we want this box to interact with the physics world
// This command also sets the physics shape to a box.
// A KinematicBody can interact with dynamic bodies, but will pass through static bodies.
Create3DPhysicsKinematicBody( 1 )
// Another box for the base of our machine
createObjectBox( 2, 300,1,100 )
SetObjectColor(2,20,200,200,255)
SetObjectPosition(2,0,-20,0)
Create3DPhysicsStaticBody( 2 )
SetObjectShapeBox(2)
SetObject3DPhysicsRestitution(2,0.95)
SetObject3DPhysicsFriction(2,0.3)
// and another box for the back of our machine
createObjectBox( 3, 300,70,10)
SetObjectColor(3,60,222,200,255)
setobjectposition(3,0,-10,90)
Create3DPhysicsStaticBody( 3 )
setobjectshapebox(3)
// Position the camera so it is facing our penny falls machine
SetCameraPosition( 1, 0,50,-150 )
SetCameraLookAt( 1, 0,10,0, 0 )
// Set a few variables that we'll be using in the main loop
pusherpos# = 70
speed# = 0.5
coins = 1
Wait = 0
do
// Make the 'pusher' move in and out
pusherpos#=pusherpos#+speed#
if pusherpos#<35 or pusherpos#>100 then speed# = 0-speed#
SetObjectPosition(1,0,-15,pusherpos#)
// Create a new coin every six frames
wait=wait+1
if wait>6
wait=0
CreateObjectCylinder( coins+3, 5,18,12 )
// CreateObjectSphere( coins+3,15,15,15)
SetObjectPosition( coins+3, -25+random(0,50),30+random(1,4),55+random(0,3) )
Create3DPhysicsDynamicBody( coins+3 )
setObjectShapeCylinder(coins+3,1)
// SetObjectShapeSphere(coins+3)
// Restitution is the bounciness of an object. Setting to a value greater than 1
// means objects will GAIN energy when they collide.
// Uncomment the next line for some fun!
//SetObject3DPhysicsRestitution(coins+3, 1.5)
SetObject3DPhysicsFriction(coins+3,0.3)
SetObject3DPhysicsMass(coins+3,4.0)
SetObjectColor(coins+3,random(20,255),random(20,255),random(20,255),255)
coins = coins + 1
endif
Print( ScreenFPS() )
Print( "number of coins created: " + str(coins) )
Step3DPhysicsWorld()
Sync()
loop
Development Director
TGC Team