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 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313
|
-- -----------------------------------------------------------------
-- Init
-- -----------------------------------------------------------------
local function prog_init()
initModels()
sound_playMusic("music/rybky10.ogg")
local pokus = getRestartCount()
-- -------------------------------------------------------------
local function prog_init_room()
local pom1, pom2, pomb1, pomb2 = 0, 0, false, false
room.uvod = 1
room.tahy = random(500) + 500
room.opldovi = 0
return function()
if no_dialog() and isReady(small) and isReady(big) then
if room.uvod == 1 then
room.uvod = 0
switch(pokus){
[1] = function()
pom1 = random(2) + 1
end,
[2] = function()
pom1 = random(2) + 1
end,
default = function()
pom1 = random(3)
end,
}
adddel(10 + random(20))
switch(pom1){
[1] = function()
if random(2) == 0 then
addm(0, "puc-m-koukej")
else
addv(0, "puc-v-podivej")
end
end,
[2] = function()
addv(0, "puc-v-videl")
addm(10, "puc-m-oblicej")
end,
}
elseif room.opldovi == 0 and dist(small, pld) < 4 and look_at(small, pld) and random(100) < 1 then
room.opldovi = 1
switch(random(3)){
[0] = function()
addm(10, "puc-m-pld0")
end,
[1] = function()
addm(10, "puc-m-pld1")
end,
[2] = function()
addm(10, "puc-m-hele")
end,
}
addm(random(30) + 5, "puc-m-slizka")
planSet(pld, "smutny", 60 + random(60))
pld:planDialog(3, "puc-x-pldik")
elseif room.tahy == 1 and big.dir ~= dir_no then
addv(10, "puc-v-fuska"..random(2))
room.tahy = random(500) + 500
elseif prvni.hotovo == 1 then
addv(5, "puc-v-fuska2")
addm(random(10) + 3, "puc-m-stalo")
addm(random(20) + 5, "puc-m-obraz")
adddel(5)
planSet(prvni, "faze", 1)
addv(20, "puc-v-nesmysl")
prvni.hotovo = 2
end
end
end
end
-- -------------------------------------------------------------
local function prog_init_prvni()
local pom1, pom2, pomb1, pomb2 = 0, 0, false, false
prvni.hotovo = 0
prvni.faze = 0
local Items = {}
Items[00] = prvni
Items[01] = puzz02
Items[02] = puzz03
Items[03] = puzz04
Items[04] = puzz05
Items[05] = puzz06
Items[06] = puzz07
Items[07] = puzz08
Items[08] = puzz09
Items[09] = puzz10
Items[10] = puzz11
Items[11] = puzz12
Items[12] = puzz13
Items[13] = puzz14
Items[14] = puzz15
Items[15] = puzz16
Items[16] = puzz17
Items[17] = puzz18
Items[18] = puzz19
Items[19] = puzz20
return function()
pomb1 = true
for pom1 = 0, 3 do
for pom2 = 0, 4 do
local x_real, x_ideal, y_real, y_ideal
-- Ideal X position is (xposition in puzzle) * (width of one piece)
x_ideal = prvni.X + pom1 * 4
-- Index is pom1 + pom2 * (number of pieces in one row)
x_real = (Items[pom1 + pom2 * 4]).X
y_ideal = prvni.Y - pom2 * 4
y_real = (Items[pom1 + pom2 * 4]).Y
pomb1 = pomb1 and (x_ideal == x_real) and (y_ideal == y_real)
end
end
if prvni.hotovo == 0 and pomb1 then
prvni.hotovo = 1
end
for pom1 = 0, 19 do
local puzz_item = Items[pom1]
puzz_item.afaze = prvni.faze
puzz_item:updateAnim()
end
if prvni.faze > 0 and prvni.faze < 4 then
prvni.faze = prvni.faze + 1
end
end
end
-- -------------------------------------------------------------
local function prog_init_pld()
local pom1, pom2, pomb1, pomb2 = 0, 0, false, false
pld.vlnit = 0
pld.del = 0
pld.ocko = 0
pld.smer = 0
pld.faze = 0
pld.smutny = 0
return function()
switch(pld.dir){
[dir_no] = function()
if pld.vlnit == -1 then
pld.vlnit = 8
end
end,
[dir_down] = function()
pld.vlnit = -1
end,
default = function()
pld.vlnit = 8
end,
}
if pld.vlnit > 0 then
pld.smutny = 0
end
if pld.vlnit > 0 then
if pld.del == 0 then
if (pld.vlnit >= 6) and (pld.vlnit <= 8) then
pld.del = 1
elseif (pld.vlnit >= 3) and (pld.vlnit <= 5) then
pld.del = 2
else
pld.del = 3
end
if random(2) == 0 then
pld.afaze = math.mod(pld.afaze + 1, 4)
else
pld.afaze = math.mod(pld.afaze + 3, 4)
end
pld.vlnit = pld.vlnit - 1
if pld.vlnit == 0 then
pld.del = 0
end
if pld.vlnit == 0 then
pld.afaze = 0
elseif pld.vlnit == 1 then
pld.afaze = 3
end
else
pld.del = pld.del - 1
end
elseif pld.smutny > 0 then
if pld.ocko == 0 then
if random(100) < 10 then
pld.ocko = 3
end
end
if pld.ocko > 0 then
pld.ocko = pld.ocko - 1
end
if pld.ocko > 0 then
pld.afaze = 15
else
pld.afaze = 14
end
pld.smutny = pld.smutny - 1
else
if random(100) < 10 then
pld.smer = 1 - pld.smer
end
if (pld.faze == 0) then
pld.afaze = 0
if random(100) < 10 then
pld.faze = 1
end
elseif (pld.faze == 1) or (pld.faze == 4) then
pld.faze = pld.faze + 1
pld.afaze = 4
elseif (pld.faze == 2) or (pld.faze == 3) then
pld.faze = pld.faze + 1
pld.afaze = 5
elseif (pld.faze == 5) then
pld.afaze = 0
pld.faze = 0
end
switch(pld.afaze){
[0] = function()
if pld.smer == 1 then
pld.afaze = 6
end
end,
[4] = function()
if pld.smer == 1 then
pld.afaze = 7
end
end,
}
if pld.ocko == 0 then
if random(100) < 10 then
pld.ocko = 3
end
end
if pld.ocko > 0 then
pld.ocko = pld.ocko - 1
end
if pld.ocko > 0 then
if pld.afaze == 0 then
pld.afaze = 9
else
pld.afaze = pld.afaze + 6
end
end
end
pld:updateAnim()
end
end
-- -------------------------------------------------------------
local function prog_init_small()
return function()
if room.tahy > 1 and small.dir ~= dir_no and level_isNewRound() then
room.tahy = room.tahy - 1
end
end
end
-- -------------------------------------------------------------
local function prog_init_big()
return function()
if room.tahy > 1 and big.dir ~= dir_no and level_isNewRound() then
room.tahy = room.tahy - 1
end
end
end
-- --------------------
local update_table = {}
local subinit
subinit = prog_init_room()
if subinit then
table.insert(update_table, subinit)
end
subinit = prog_init_prvni()
if subinit then
table.insert(update_table, subinit)
end
subinit = prog_init_pld()
if subinit then
table.insert(update_table, subinit)
end
subinit = prog_init_small()
if subinit then
table.insert(update_table, subinit)
end
subinit = prog_init_big()
if subinit then
table.insert(update_table, subinit)
end
return update_table
end
local update_table = prog_init()
-- -----------------------------------------------------------------
-- Update
-- -----------------------------------------------------------------
function prog_update()
for key, subupdate in pairs(update_table) do
subupdate()
end
end
|