Welcome, Guest. Please login or register.
May 25, 2013, 04:06:30 pm

Login with username, password and session length
Members
Total Members: 488
Latest: Wimmie
Stats
Total Posts: 7309
Total Topics: 1178
Online Today: 7
Online Ever: 229
(April 05, 2011, 09:10:50 am)
Users Online
Users: 0
Guests: 3
Total: 3
Permissions

A Squeakyduck Design product
Cobra 2D Physics Demo 4
File Repository
Cobra 2D Physics Demo 4 Cobra 2D Physics Demo 4
Small tech demo showing off the 2d Physics engine which will be available as a Beta in the next version of Cobra.

This demo has a number of features:
  • Cobra2D the OpenGL accelerated 2d Engine
  • Physics controlled sprites (Once physics enabled, the sprite position/angle is auto controlled)
  • Collision hulls are used to define the sprite regions along with physical properties like mass, restitution (bounce) and friction (notice the bouncy ping pong balls, less bouncy tennis balls).
  • All media is packed into the exe
Just to show how easy it is, here is the code :

var
b1,afloor:element


i,c : integer
lt:integer

procedure Newthing
var
cc:integer
begin
cc = Rand(1,8) // pick a sprite at randon
b1=loadSprite('shape'+cc+'.png') // load it up

// load it's hull
SpriteLoadHulls(b1,'shape'+cc+'.hull')

// place it at a Random position
PositionSprite(b1,400+rand(-350,350),32)

// link sprite to physics engine, with defaults
// for mass, friction and restitution
// (can be overriden in the hull definition)
D2DLinkPhysics(b1,1,0.3,0.2)
end

begin
openscreen


// Freeze the timers so the physics
// doesn't jump at the start
 Freeze

// set up the physics world
D2DWorldCreate(-100,-100,100,100,0,10,true)
D2DSetScaling(0,0,10,10)

// and an invisible Floor for things to land on
afloor = d2daddbox(200,5,0,0.5,0,0,60,0)

// start off with one thing
newthing
c=1
UnFreeze // release the timer

lt = millisecs
while not keydown(vk_escape)

// create new sprites every half second
if (c<80) and (millisecs-lt > 500) then
newthing
lt = millisecs
inc(c)
endif

flip
wend

closescreen
end
1811 Kb | Views: 1677   Downloads: 392   Last accessed: May 23, 2013, 01:25:05 am
Uploaded by : GrahamK (February 25, 2008, 09:35:51 pm)