Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
-- To do:
-- 1) tile matching
-- 2) tile animation
-- 3) friction for different floor types
-- 4) Need to move shadows and other elements into their own layer groups
-- 5) New level Buttons
-- 6) Cancel button
-- 7) Assign each tile a type based on the number.
-To allow tiles of different numbers to have the same physical ef
fects
-- 8) Adjust friction to prevent marble from getting stuck in space
------
Name Ideas
Marble Quest
Marble Madness
Moxyd
Hydroxyd
physics.setGravity(0,0)
n view so vertical and
local matches_array = {}
local matched_tiles = 0
local level = 1
local start_x
local start_y
local
local
local
local
floor_friction = 0.99
floor_friction_space = 0.0
floor_friction_ice = 0.11
floor_friction_normal = 0.99
local
local
local
local
control_force = 1.0
control_force_normal = 1.0
control_force_space = 0
control_force_ice = 0.22
= get_all_frames() },
= { 4, 6, 7, 8, 9, 10 } }, -- blue
= { 10, 9, 8, 7, 6, 4 } }, -- blue
= { 4, 11, 12, 12, 14, 15 } }, -- g
= { 15, 14, 13, 12, 11, 4 } }, -= { 4, 16, 17, 18, 19, 20 } }, -- c
= { 20, 19, 18, 17, 16, 4 } },
= { 4, 21, 22, 23, 24, 25 } },
= { 25, 24, 23, 22, 21, 4 } }, -= { 4, 26, 27, 28, 29, 30 } },
= { 30, 29, 28, 27, 26, 4 } }, -= { 4, 31, 32, 33, 34, 35 } },
-- yellow
61 to 66
{ sheet = tile_sheet, frames = { 35, 34, 33, 32, 31, 4 } }, --
67 to 72
2 } }
)
-- Animated
sprite.add(
eyes
sprite.add(
sprite.add(
sprite.add(
sprite.add(
sprite.add(
sprite.add(
eyes
sprite.add(
sprite.add(
sprite.add(
sprite.add(
sprite.add(
tile_set,
tile_set,
tile_set,
tile_set,
tile_set,
tile_set,
tile_set,
tile_set,
tile_set,
tile_set,
"color_b",
"color_c",
"color_d",
"color_e",
"color_f",
13
25
37
49
61
+
+
+
+
+
"color_b_close",
"color_c_close",
"color_d_close",
"color_e_close",
"color_f_close",
tiles_in_sheet,
tiles_in_sheet,
tiles_in_sheet,
tiles_in_sheet,
tiles_in_sheet,
19
31
43
55
67
+
+
+
+
+
6,
6,
6,
6,
6,
200,
200,
200,
200,
200,
tiles_in_sheet,
tiles_in_sheet,
tiles_in_sheet,
tiles_in_sheet,
tiles_in_sheet,
6,
6,
6,
6,
6,
1
1
1
1
1
)
)
)
)
)
200,
200,
200,
200,
200,
--------
-- --------------- level 1
-- Color
1
1
1
1
1
)
)
)
)
)
-- -------------floor_array[1] = { 2, 2, 4, 2, 2, 2, 2, 4, 2, 2,
40,37,37,37,37,37,37,37,37,37,
38,36,36,36,36,36,36,36,36,36,
38,36,36,36,36,36,36,36,36,36,
38,36,36,36,36,36,36,36,36,36,
38,36,36,36,36,36,36,36,36,36,
38,36,36,36,36,36,36,36,36,36,
38,36,36,36,36,36,36,36,36,36,
38,36,36,36,36,36,36,36,36,36,
38,36,36,36,36,36,36,36,36,36,
38,36,36,36,36,36,36,36,36,36,
2,2,4,2,2,2,2,4,2,2}
shadow_array[1] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
67,67,67,67,67,67,67,67,67,67,
0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0}
solid_array[1] = {2,2,4,2,2,2,2,4,2,2,
0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,
2,2,4,2,2,2,2,4,2,2}
-- --------------- level 2
-- -------------floor_array[2] = {2,2,4,2,2,2,2,4,2,2,
40,37,37,37,37,37,37,37,37,37,
38,36,36,36,36,36,36,36,36,36,
38,36,36,2,41,36,2,41,36,36,
38,36,36,39,42,36,39,42,36,36,
38,36,36,36,36,36,36,36,36,36,
38,36,36,36,36,36,36,36,36,36,
38,36,36,36,36,36,36,36,36,36,
38,36,36,2,41,36,2,41,36,36,
38,36,36,39,42,36,39,42,36,36,
38,36,36,36,36,36,36,36,36,36,
2,2,4,2,2,2,2,4,2,2}
shadow_array[2] = {0,0,0,0,0,0,0,0,0,0,
67,67,67,67,67,67,67,67,67,67,
0,0,0,0,0,0,0,0,0,0,
0,0,0,0,69,0,0,69,0,0,
0,0,0,66,70,0,66,70,0,0,
0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,
0,0,0,0,69,0,0,69,0,0,
0,0,0,66,70,0,66,70,0,0,
0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0}
solid_array[2] = {2,2,4,2,2,2,2,4,2,2,
0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,
0,0,0,2,0,0,2,0,0,0,
0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,
0,0,0,2,0,0,2,0,0,0,
0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,
2,2,4,2,2,2,2,4,2,2}
-- --------------- level 3
-- -------------floor_array[3] = {2,4,2,4,2,2,4,2,4,2,
44,44,44,44,44,44,44,44,44,44,
45,2,45,43,43,45,44,43,2,43,
45,46,45,43,45,43,43,43,46,44,
45,43,43,2,43,43,2,46,43,43,
45,43,43,46,44,43,43,43,44,43,
45,45,43,43,44,43,43,43,43,43,
44,43,43,2,44,43,2,45,43,43,
45,43,43,46,43,43,46,45,43,43,
45,2,43,43,44,43,43,43,2,43,
45,46,45,43,43,43,43,43,46,46,
2,4,2,4,2,2,4,2,4,2}
shadow_array[3] = {0,0,0,0,0,0,0,0,0,0,
67,67,67,67,67,67,67,67,67,67,
0, 0,69, 0, 0, 0, 0, 0, 0,69,
0,66,70, 0, 0, 0, 0, 0,66,70,
0, 0, 0, 0,69, 0, 0,69, 0, 0,
0, 0, 0,66,70, 0,66,70, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0,69, 0, 0,69, 0, 0,
0, 0, 0,66,70, 0,66,70, 0, 0,
0, 0,69, 0, 0, 0, 0, 0, 0,69,
0,66,70, 0, 0, 0, 0, 0,66,70,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
solid_array[3] = {2,4,2,4,2,2,4,2,4,2,
0,0,0,0,0,0,0,0,0,0,
0,2,0,0,0,0,0,0,2,0,
0,0,0,0,0,0,0,0,0,0,
0,0,0,2,0,0,2,0,0,0,
0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,
0,0,0,2,0,0,2,0,0,0,
0,0,0,0,0,0,0,0,0,0,
0,2,0,0,0,0,0,0,2,0,
0,0,0,0,0,0,0,0,0,0,
2,4,2,4,2,2,4,2,4,2}
-- --------------- level 4
-- -------------floor_array[4] = {2,2,2,2,2,2,2,2,2,2,
40,37,37,37,37,37,37,37,37,37,
38,52,4,41,52,36,52,4,41,52,
38,52,39,42,52,36,36,39,42,52,
38,36,52,36,52,36,52,36,36,36,
38,36,52,52,36,36,36,36,52,52,
38,52,36,36,36,36,36,36,36,52,
38,36,52,52,36,52,52,52,36,36,
38,52,52,36,36,52,52,52,52,36,
38,52, 4,41,36,52,52, 4,41,36,
38,52,39,42,52,52,52,39,42,52,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2}
shadow_array[4] = {0,0,0,0,0,0,0,0,0,0,
67,67,67,67,67,67,67,67,67,67,
0, 0, 0,69, 0, 0, 0, 0,69, 0,
0, 0,66,70, 0, 0, 0,66,70, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0,69, 0, 0, 0, 0,69, 0,
0, 0,66,70, 0, 0, 0,66,70, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
solid_array[4] = {2,2,2,2,2,2,2,2,2,2,
0,0,0,0,0,0,0,0,0,0,
0,0,4,0,0,0,0,4,0,0,
0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,
0,0,4,0,0,0,0,4,0,0,
0,0,0,0,0,0,0,0,0,0,
2,2,2,2,2,2,2,2,2,2}
-- --------------- level 5
-- --------------
floor_array[5] = {4,2,2,2,2,2,2,2,2,2,
37,2,40,37,37,37,2,40,37,37,
36,2,38,2,41,36,2,38,2,41,
36,2,38,2,38,36,2,38,2,38,
36,2,38,2,38,36,2,38,2,38,
36,2,38,2,38,36,2,38,2,38,
36,2,38,2,38,36,2,38,2,38,
36,2,38,2,38,36,2,38,2,38,
36,2,38,2,38,36,2,38,2,38,
36,2,38,2,38,36,2,38,2,38,
36,39,42,2,38,36,39,42,2,38,
2,2,2,2,2,2,2,2,2,4}
shadow_array[5] = {0,0,0,0,0,0,0,0,0,0,
67,0,71,67,67,67,0,71,67,67,
0,0,68,0,69,0,0,68,0,69,
0,0,68,0,68,0,0,68,0,68,
0,0,68,0,68,0,0,68,0,68,
0,0,68,0,68,0,0,68,0,68,
0,0,68,0,68,0,0,68,0,68,
0,0,68,0,68,0,0,68,0,68,
0,0,68,0,68,0,0,68,0,68,
0,0,68,0,68,0,0,68,0,68,
0,66,70,0,68,0,66,70,0,68,
0,0,0,0,0,0,0,0,0,0
}
solid_array[5] = {4,2,2,2,2,2,2,2,2,2,
0,2,0,0,0,0,2,0,0,0,
0,2,0,2,0,0,2,0,2,0,
0,2,0,2,0,0,2,0,2,0,
0,2,0,2,0,0,2,0,2,0,
0,2,0,2,0,0,2,0,2,0,
0,2,0,2,0,0,2,0,2,0,
0,2,0,2,0,0,2,0,2,0,
0,2,0,2,0,0,2,0,2,0,
0,2,0,2,0,0,2,0,2,0,
0,0,0,2,0,0,0,0,2,0,
2,2,2,2,2,2,2,2,2,4}
-- --------------- level 6
-- -------------floor_array[6] = {2,2,2,2,2,2,2,2,2,2,
63,63,63,63,37,37,63,63,63,63,
63,4,63,63,36,36,63,63,4,63,
63,63,63,63,36,36,63,63,63,63,
63,63,63,63,36,36,63,63,63,63,
63,63,63,63,36,36,63,63,63,63,
63,63,63,63,36,36,63,63,63,63,
63,63,63,63,36,36,63,63,63,63,
63,63,63,63,36,36,63,63,63,63,
63,4,63,63,36,36,63,63,4,63,
63,63,63,63,36,36,63,63,63,63,
2,2,2,2,2,2,2,2,2,2}
shadow_array[6] = {0,0,0,0,0,0,0,0,0,0,
0,0,0,0,67,67,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0}
solid_array[6] = {2,2,2,2,2,2,2,2,2,2,
0,0,0,0,0,0,0,0,0,0,
0,4,0,0,0,0,0,0,4,0,
0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,
0,4,0,0,0,0,0,0,4,0,
0,0,0,0,0,0,0,0,0,0,
2,2,2,2,2,2,2,2,2,2}
-- --------------- level 7
-- -------------floor_array[7] = {2,2,2,2,2,2,2,2,2,2,
64,64,64,64,64,64,64,64,64,64,
64,5,64,64,64,64,64,64,5,64,
64,64,64,64,64,64,64,64,64,64,
64,64,64,64,64,64,64,64,64,64,
64,64,64,64,64,64,64,64,64,64,
64,64,64,64,64,64,64,64,64,64,
64,64,64,64,64,64,64,64,64,64,
64,64,64,64,64,64,64,64,64,64,
64,5,64,64,64,64,64,64,5,64,
64,64,64,64,64,64,64,64,64,64,
2,2,2,2,2,2,2,2,2,2}
shadow_array[7] = {0,0,0,0,0,0,0,0,0,0,
67,67,67,67,67,67,67,67,67,67,
0,0,69,0,0,0,0,0,0,69,
0,66,70,0,0,0,0,0,66,70,
0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,
0,0,69,0,0,0,0,0,0,69,
0,66,70,0,0,0,0,0,66,70,
0,0,0,0,0,0,0,0,0,0}
solid_array[7] = {2,2,2,2,2,2,2,2,2,2,
0,0,0,0,0,0,0,0,0,0,
0,4,0,0,0,0,0,0,4,0,
0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,
0,4,0,0,0,0,0,0,4,0,
0,0,0,0,0,0,0,0,0,0,
2,2,2,2,2,2,2,2,2,2}
-- --------------- level 8
-- -------------floor_array[8] = {2,2,2,2,2,2,2,2,2,2,
37,37,37,37,65,65,37,38,37,37,
36,62,41,38,65,65,36,36,62,41,
36,39,42,36,65,65,36,37,39,42,
36,36,37,36,65,65,36,36,36,36,
65,65,36,36,36,36,36,36,65,65,
65,65,36,37,36,36,37,36,65,65,
36,36,36,36,65,65,36,36,36,36,
36,38,36,36,65,65,36,38,36,36,
36,62,41,36,65,65,36,36,62,38,
36,39,42,36,65,65,36,36,39,42,
2,2,2,2,2,2,2,2,2,2}
shadow_array[8] = {0,0,0,0,0,0,0,0,0,0,
67,67,67,67,0,0,67,67,67,67,
0,0,69,0,0,0,0,0,0,69,
0,66,70,0,0,0,0,0,66,70,
0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,
0,0,69,0,0,0,0,0,0,69,
0,66,70,0,0,0,0,0,66,70,
0,0,0,0,0,0,0,0,0,0}
solid_array[8] = {2,2,2,2,2,2,2,2,2,2,
0,0,0,0,0,0,0,0,0,0,
0,4,0,0,0,0,0,0,4,0,
0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,
0,4,0,0,0,0,0,0,4,0,
0,0,0,0,0,0,0,0,0,0,
2,2,2,2,2,2,2,2,2,2}
local c = 0
for j = 1, #solid_array[i], 1 do
if solid_array[i][j] == 4 then
c = c + 1
end
end
matches_array[i] = c
-- print( "level:", i, "matches:", c )
end
-- ----------------------------------------------------------------
do
= tile_array[i].floor
= tile_array[i].shadow
= tile_array[i].solid
if shadow_id == 0 then
shadow_tile.isVisible = false
else
shadow_tile.isVisible = true
end
if solid_id == 0 then
solid_tile.isVisible = false
else
solid_tile.isVisible = true
end
floor_group.isVisible = true
shadow_group.isVisible = true
solid_group.isVisible = true
if solid_id == 2 then
physics.addBody( solid_tile, "static", {density=1.0, fri
ction=0.0 } )
solid_tile:prepare( "all" )
solid_tile.currentFrame = solid_id
elseif solid_id == 4 then
physics.addBody( solid_tile, "static", {density=1.0, fri
ction=0.0 } )
solid_tile.color = c_array[c_index]
c_index = c_index + 1
solid_tile:prepare( solid_tile.color )
solid_tile.isLocked = false
solid_tile.isOpen = false
end
end
ball.x = tile_size * tile_cols / 2
ball.y = tile_size * tile_rows / 2
last_open_tile = nil
end
-- -------------------------------------------------------------
ball.linearDamping = 0.5
-- Create Ball Shadow
ball_shadow = display.newImage( "images/ball_shadow.png" )
shadow_group:insert( ball_shadow )
end
-- -------------------------------------------------------------
tile_array[#tile_array+1] = tile_obj
floor_tile.x = tile_x
floor_tile.y = tile_y
shadow_tile.x = tile_x
shadow_tile.y = tile_y
solid_tile.x = tile_x
solid_tile.y = tile_y
end
end
end
-- ---------------------------------------------------------------