Can anybody guide me in creating a game like soccer.Can somebody provide me some samples to play around with it.I just dont know how to start with or were to start from.Please help me if possible. [import]uid: 82446 topic_id: 32794 reply_id: 332794[/import]
You could try looking at the air hockey sample to start -
http://www.coronalabs.com/blog/2011/05/16/sample-code-air-hockey/
Imagining puck as ball and changing paddles to players then adding more. [import]uid: 52491 topic_id: 32794 reply_id: 130393[/import]
Thanks for the help btu I want to have a penalty shootout in soccer game where player selects the power ,angle and elevation to kick the ball.Just like [html] http://www.2dfootballgames.com/2314/Free-Kick-Specialist-3.html [/html] kind of game [import]uid: 82446 topic_id: 32794 reply_id: 130395[/import]
You could try looking at the air hockey sample to start -
http://www.coronalabs.com/blog/2011/05/16/sample-code-air-hockey/
Imagining puck as ball and changing paddles to players then adding more. [import]uid: 52491 topic_id: 32794 reply_id: 130393[/import]
Thanks for the help btu I want to have a penalty shootout in soccer game where player selects the power ,angle and elevation to kick the ball.Just like [html] http://www.2dfootballgames.com/2314/Free-Kick-Specialist-3.html [/html] kind of game [import]uid: 82446 topic_id: 32794 reply_id: 130395[/import]
Then a good start might be learning how to make your power meter: http://developer.coronalabs.com/forum/2011/05/29/how-make-bar-moving-and-down-beginner-question [import]uid: 52491 topic_id: 32794 reply_id: 130481[/import]
Then a good start might be learning how to make your power meter: http://developer.coronalabs.com/forum/2011/05/29/how-make-bar-moving-and-down-beginner-question [import]uid: 52491 topic_id: 32794 reply_id: 130481[/import]
Hi,This is what I have come up with after few days of exploration.I am facing problem with the projectile motion of the ball.
What I have done is first I have calculated the initial velocity component in 3d using the given parameters(ie velocity,angle and elevation).Then I have converted the 3d coordinates into 2d coordinates.Now I am facing problem with the range that I should keep for all the parameters(ie velocity,angle and elevation).can anybody help me out with the problem?also how to manipulate the timer duration in the MARKED line “timer duration(300)”?
[code]
local g = -9.8
local range = 0
local nearPoint = 0.9677
local timeInc = 0
local selected = false
–Get the initial velocity component and the initial location
function CoordinatesIn3D(thetha,phi,velocity)
–Initial location in 3D world
local initObjX = 0;
local initObjY = 0;
local initObjz = 100;
–Components Of the Ball Velocity in X,Y,Z direction
local compVelX = velocity * math.cos(thetha*math.pi/180) * math.cos(phi*math.pi/180)
local compVelY = velocity * math.sin(thetha*math.pi/180)
local compVelZ = velocity * math.cos(thetha*math.pi/180) * math.sin(phi*math.pi/180)
return initObjX,initObjY,initObjz,compVelX,compVelY,compVelZ
end
–Convert the 3D Co-ordinates into 2d Co-ordinates
function transform3DTo2D(t)
local coordX = initObjX + (compVelX * t) - (1/2)*0.5*t^2
local coordY = initObjY + (compVelY * t) + (1/2)*g*t^2
local coordZ = initObjz + (compVelZ * t)
if coordY > 0 and selected == false then
range = (t + 0.4)/0.4
end
local bx = coordX/(coordZ + 100)
local by = coordY/(coordZ + 100) + (nearPoint * (coordZ + 100))
return bx,-by
end
–Move the rect
function fun()
t = (timeInc - 1)*.40
local x,y = transform3DTo2D(t)
if sc~= nil then
sc:removeSelf()
end
local rect = display.newCircle(384 + x * 200 ,900 + y,10)
timeInc = timeInc + 1
end
local function startGame()
initObjX,initObjY,initObjz,compVelX,compVelY,compVelZ = CoordinatesIn3D(60,10,70)
for i = 1, 100 do
local t = (i-1)*.40
local x,y = transform3DTo2D(t)
end
selected = true
timer.performWithDelay(20,fun,300) --timer duration(300)
end
startGame() [import]uid: 82446 topic_id: 32794 reply_id: 131722[/import]
Hi,This is what I have come up with after few days of exploration.I am facing problem with the projectile motion of the ball.
What I have done is first I have calculated the initial velocity component in 3d using the given parameters(ie velocity,angle and elevation).Then I have converted the 3d coordinates into 2d coordinates.Now I am facing problem with the range that I should keep for all the parameters(ie velocity,angle and elevation).can anybody help me out with the problem?also how to manipulate the timer duration in the MARKED line “timer duration(300)”?
[code]
local g = -9.8
local range = 0
local nearPoint = 0.9677
local timeInc = 0
local selected = false
–Get the initial velocity component and the initial location
function CoordinatesIn3D(thetha,phi,velocity)
–Initial location in 3D world
local initObjX = 0;
local initObjY = 0;
local initObjz = 100;
–Components Of the Ball Velocity in X,Y,Z direction
local compVelX = velocity * math.cos(thetha*math.pi/180) * math.cos(phi*math.pi/180)
local compVelY = velocity * math.sin(thetha*math.pi/180)
local compVelZ = velocity * math.cos(thetha*math.pi/180) * math.sin(phi*math.pi/180)
return initObjX,initObjY,initObjz,compVelX,compVelY,compVelZ
end
–Convert the 3D Co-ordinates into 2d Co-ordinates
function transform3DTo2D(t)
local coordX = initObjX + (compVelX * t) - (1/2)*0.5*t^2
local coordY = initObjY + (compVelY * t) + (1/2)*g*t^2
local coordZ = initObjz + (compVelZ * t)
if coordY > 0 and selected == false then
range = (t + 0.4)/0.4
end
local bx = coordX/(coordZ + 100)
local by = coordY/(coordZ + 100) + (nearPoint * (coordZ + 100))
return bx,-by
end
–Move the rect
function fun()
t = (timeInc - 1)*.40
local x,y = transform3DTo2D(t)
if sc~= nil then
sc:removeSelf()
end
local rect = display.newCircle(384 + x * 200 ,900 + y,10)
timeInc = timeInc + 1
end
local function startGame()
initObjX,initObjY,initObjz,compVelX,compVelY,compVelZ = CoordinatesIn3D(60,10,70)
for i = 1, 100 do
local t = (i-1)*.40
local x,y = transform3DTo2D(t)
end
selected = true
timer.performWithDelay(20,fun,300) --timer duration(300)
end
startGame() [import]uid: 82446 topic_id: 32794 reply_id: 131722[/import]