Tutorial 02 - Static And Dynamic Objects!
This tutorial shows how to create static and dynamic objects.
SuperStrict
Import pyroplay.ppisaac
Graphics 800,600
ppIsaac.Start()
Local ground:ppBox = ppBox.Create(400, 500, 600, 50, 0)
Local box01:ppBox = ppBox.Create(300,100, 50,50, 10)
While Not KeyHit(KEY_ESCAPE) And Not AppTerminate()
Cls
ppIsaac.Update()
ppIsaac.Draw()
Flip
Wend
ppIsaac.Stop()
End
This tutorial introduces the ppBox type that creates a rectangle geometry in the ppIsaacs world. In Listing 2.1 I have created to boxes with the ppBox.Create() function. The parameters of ppBox.Create are x position, y position, width, height and mass. When you execute Listing 2.1 nothing happens without two boxes that gets drawn on the screen. I bet you expect the upper box to fall down. It seems there is no gravity!
To set up gravity the ppIsaac type provides an gravity object with two fields for gravity in x and y direction. Add the following line after the ppISaac.Start() function:
ppIsaac.gravity.y = 50000
Now execute the listing again and see the results. The upper box should fall down.
Let's add some more action, so that the upper box collides more dramatically with the ground box. Add the following line after the box01 object has been created:
box01.SetOmega(2.5)
Now the upper box has an angular velocity and rotates.
Last questions is, why does the ground object does not move? This is because of the masses. If you set the mass of an object to zero, the object becomes a static object and is unmoveable.
Links:
ppIsaac Product Page
Tutorial 01 - Hello Isaac!
Tutorial 03 - Texture and Materials
Tutorial 04 - Joints
Tutorial 05 - Collision Detection and Material Collision