Can anybody explain me how to make ball shadow on the ground so that it makes the plaer feel that the ball is moving up in the ground .The code helps me make the ball move in the desired location but I want also the shadow to be there so that it looks as if the ballis moving in the air and not in the ground.How to make it?Can anybody suggest me any help regarding this?
[code]
function vyf(v, a)
return v * math.cos(a * math.pi / 180)
end
function vxt(v, a, t)
return v * math.sin(a * math.pi / 180) - 9.8 * t
end
function xt(v, a, t)
return v * math.sin(a * math.pi / 180) * t - 0.5 * 9.8 * t * t
end
–[[worker functions]]–
function totalRangeHeightFlightTime(v, ag)
local h = vxt(v, ag, 0) * vxt(v, ag, 0) / (2 * 9.8)
local t = 2 * vxt(v, ag, 0) / 9.8
local r = v * v * math.sin( 2 * ag * math.pi / 180 ) / 9.8
return r, h, t
end
function positionAtTime(v, ag, t)
local vy = vyf(v,ag) – horizontal velocity
local y = vyf(v,ag) * t – horizontal distance
local vx = vxt(v, ag, t) – vertical velocity
local x = xt(v, ag, t) – height at time ‘t’
return x, y, vx, vy
end
–[[environment setup]]–
local offsetX, offsetY = 384, 900
local iteration = .1
local v = 70 – launch velocity v/ms
local ag = 60 – launch angle (theta) degrees
local r, h, f = totalRangeHeightFlightTime(v, ag) – total flight time
print( 'range: ', r )
print( 'height: ', h )
print( 'flight time: ', f )
–[[trajectory plotting]]–
for t = 0, f, iteration do
local x, y, vx, vy = positionAtTime(v, ag, t)
print( math.round(x), math.round(y) )
local cir1=display.newCircle( x + offsetX, y * -1 + offsetY, (vx+vy)*.1 )
end
[/code] [import]uid: 82446 topic_id: 32868 reply_id: 332868[/import]