-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTrainingLevel.lua
30 lines (25 loc) · 1.26 KB
/
TrainingLevel.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
local WIDTH = 30
local HEIGHT = 80
local GRAVITY_Y = -30
local PLAYER_SPAWN_X = 4
local PLAYER_SPAWN_Y = 4
local JUMP_DELTA_Y = 1.3
local KICKOFF_DELTA_Y = 3.5
fixtureDef.isSensor = false
box2DFactory:createEdge(levelBody, fixtureDef, 0, 0, WIDTH, 0)
box2DFactory:createEdge(levelBody, fixtureDef, 0, 0, 0, HEIGHT)
box2DFactory:createEdge(levelBody, fixtureDef, WIDTH, 0, WIDTH, HEIGHT)
box2DFactory:createEdge(levelBody, fixtureDef, 0, JUMP_DELTA_Y, 5, JUMP_DELTA_Y)
box2DFactory:createEdge(levelBody, fixtureDef, 7, JUMP_DELTA_Y*2, 9, JUMP_DELTA_Y*2)
box2DFactory:createEdge(levelBody, fixtureDef, 10, JUMP_DELTA_Y*2 + KICKOFF_DELTA_Y, 11, JUMP_DELTA_Y*2 + KICKOFF_DELTA_Y)
box2DFactory:createEdge(levelBody, fixtureDef, 0, JUMP_DELTA_Y*2 + KICKOFF_DELTA_Y*2, 5, JUMP_DELTA_Y*2 + KICKOFF_DELTA_Y*2)
box2DFactory:createEdge(levelBody, fixtureDef, 10, JUMP_DELTA_Y, 11, JUMP_DELTA_Y)
local ladderX = WIDTH - 2
for i = 0, 10, 1 do
local platformHeight = JUMP_DELTA_Y+i*(KICKOFF_DELTA_Y-.3)
box2DFactory:createEdge(levelBody, fixtureDef, ladderX, platformHeight, WIDTH, platformHeight)
end
fixtureDef.friction=0
box2DFactory:createEdge(levelBody, fixtureDef, 15, 0f, 20, 2f)
world:setGravity(world:getGravity():set(0,GRAVITY_Y))
bodyDef.position:set(PLAYER_SPAWN_X,PLAYER_SPAWN_Y)