0 Members and 2 Guests are viewing this topic.
Thanks for gathering these resources! space = pSpace(9.8)got turned intospace = pSpace(9.in your code.
So, I looked into the documentation, and could not find any sign of liquidsimulation. Is this present in the physics lib or not?It's sad to see that noone has made a game with it yet, someone should try this out
Sounds interesting, any one have a video?
@Nick My eat nethams game seems to run somewhat faster on 3.2 than it did on 3.1. The lobsters definitely fall smoother when setting it to the 100% spawn rate. It's not much of an improvement, but to me it seems to be something like 5-10%. It also could be I'm just imagining it, sadly I do not own 2 CXes so I can't test :p
Quote from: Augs on January 07, 2013, 02:37:14 pmSounds interesting, any one have a video?A video of the chipmunk engine? Well, if you have the student software a handheld, you could try the code Jim posted above (they're really nice tbh)
----------------------------------------------------------- LUA FALLDOWN, BY ANTOX98 -----------------------------------------------------------platform.apilevel = "2.0"require "physics"--------------------------- BALL CLASS ---------------------------Ball = class()Seg = class()function Ball:init(x, y, w, mass) self.width = w self.body = physics.Body(mass, physics.misc.momentForCircle(mass, 0, 10, ZERO)) self.body:setPos(physics.Vect(x, y)) self.body:setMass(mass) self.shape = physics.CircleShape(self.body, w, ZERO) self.shape:setRestitution(0.6) self.shape:setFriction(0.6)endfunction Seg:init(x1, y1, x2, y2) local a, b = physics.Vect(x1, y1), physics.Vect(x2, y2) local mass = physics.misc.INFINITY() self.coor = {x1,y1,x2,y2} self.body = physics.Body(mass, physics.misc.momentForSegment(mass, a, b)) --self.body:setPos(physics.Vect(x1, y1)) self.body:setMass(mass) self.shape = physics.SegmentShape(self.body, a, b, 18) self.shape:setRestitution(0.6) self.shape:setFriction(0.6)endfunction Ball:paint(gc) local p = self.body:pos() local x, y = p:x(), p:y() local r = self.width / 2 gc:setColorRGB(255,0,0) gc:fillArc(x+r, y+r , self.width, self.width, 0, 360)endfunction Seg:paint(gc) local a = self.shape:a() local b = self.shape:b() gc:setPen("thick") gc:setColorRGB(0,0,0) gc:drawLine(a:x(), a:y(), b:x(), b:y())endfunction initGame() w = 318 h = 212 ZERO = physics.Vect(0,0) LARGE = physics.misc.INFINITY() space = physics.Space() space:setGravity(physics.Vect(0,9.8)) count = 100 walls = {Seg(0,0,0,h), Seg(0,h,w,h), Seg(w,h,w,0)} for i = 1, #walls do space:addShape(walls[i].shape) end seg = {} --space:addBody(sol.body) ball = Ball(w/2-10, 30, 20, 1000) space:addBody(ball.body) space:addShape(ball.shape) timer.start(0.01)endinitGame()function on.timer() space:step(0.1) if count == 100 then count = 0 generate() else count = count + 1 end moveSeg(0.5) platform.window:invalidate()endfunction generate() r = math.random(0, w-40) seg[#seg+1] = Seg(0, h, r, h) seg[#seg+1] = Seg(r+40, h, w, h) space:addShape(seg[#seg-1].shape) space:addShape(seg[#seg].shape)endfunction moveSeg(n) for i = 1, #seg do seg[i].coor = {seg[i].coor[1],seg[i].coor[2]-n,seg[i].coor[3],seg[i].coor[4]-n} local a, b = physics.Vect(seg[i].coor[1], seg[i].coor[2]), physics.Vect(seg[i].coor[3], seg[i].coor[4]) local mass = physics.misc.INFINITY() seg[i].body = physics.Body(mass, physics.misc.momentForSegment(mass, a, b)) --self.body:setPos(physics.Vect(x1, y1)) seg[i].body:setMass(mass) seg[i].shape = physics.SegmentShape(seg[i].body, a, b, 18) seg[i].shape:setRestitution(0.6) seg[i].shape:setFriction(0.6) space:addShape(seg[i].shape) end endfunction on.arrowKey(key) if key == "right" then ball.body:setAngVel(5) elseif key == "left" then ball.body:setAngVel(-5) end endfunction on.paint(gc) ball:paint(gc) for i = 1, #seg do seg[i]:paint(gc) end end