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 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525
|
-- -----------------------------------------------------------------
-- Init
-- -----------------------------------------------------------------
local function prog_init()
initModels()
sound_playMusic("music/rybky04.ogg")
local pokus = getRestartCount()
-- -------------------------------------------------------------
local function prog_init_room()
local pom1, pom2, pomb1, pomb2 = 0, 0, false, false
room.uvod = 10 + random(10)
room.poslvykrik = -1
room.pocetvykriku = 0
room.venku = 1
room.obaloncich = random(20) + 40
room.omeste = random(2)
room.okrabech = 0
room.osose = random(4000) + 3000
if pokus > 1 and random(100) < 50 then
room.opocitech = random(1500) + 1000
else
room.opocitech = -1
end
return function()
if no_dialog() and isReady(small) and isReady(big) then
if room.uvod > 0 then
if cihla.X == cihla.XStart and cihla.Y == cihla.YStart then
room.uvod = room.uvod - 1
else
room.uvod = -1
room.venku = 0
end
end
if room.osose > 0 then
room.osose = room.osose - 1
end
if room.opocitech > 0 then
room.opocitech = room.opocitech - 1
end
if room.obaloncich > 0 then
if balon1.dir ~= dir_no or balon2.dir ~= dir_no or balon3.dir ~= dir_no or lbalon.dir ~= dir_no or rbalon.dir ~= dir_no then
room.obaloncich = room.obaloncich - 1
end
end
if room.uvod == 0 then
room.uvod = 100 + random(200)
room.pocetvykriku = room.pocetvykriku + 1
pom1 = random(2)
if pom1 == room.poslvykrik then
pom1 = 2
end
if isIn(room.pocetvykriku, {5, 11, 16}) then
pom1 = 3
end
room.poslvykrik = pom1
switch(pom1){
[3] = function()
addv(3, "sec-v-zavreny")
addm(10, "sec-m-kamen")
end,
default = function()
if 0 <= pom1 and pom1 <= 2 then
addv(3, "sec-v-ven"..pom1)
end
end,
}
elseif room.venku == 0 then
room.venku = 1
addm(random(10) + 10, "sec-m-ven"..random(2))
elseif room.obaloncich == 0 then
room.obaloncich = -1
addm(5, "sec-m-balonky")
elseif room.omeste == 0 and random(3000) == 0 then
room.omeste = 1
addv(10, "sec-v-mesto")
elseif room.okrabech == 0 and random(2000) == 0 then
room.okrabech = 1
addm(20, "sec-m-krab")
addv(10, "sec-v-ktery")
addm(5, "sec-m-dole"..random(2))
addv(5 + random(20), "sec-v-normalni"..random(2))
elseif room.osose == 0 then
room.osose = -1
addv(40, "sec-v-socha")
addm(random(10) + 4, "sec-m-situace")
adddel(random(15) + 5)
planSet(drzka, "cinnost", 1)
elseif room.opocitech == 0 then
room.opocitech = -1
addv(20, "sec-v-pocit")
addm(5, "sec-m-pocity")
addv(0, "sec-v-pockej")
addv(random(30) + 40, "sec-v-oci")
addm(4, "sec-m-program")
end
end
end
end
-- -------------------------------------------------------------
local function prog_init_drzka()
local pom1, pom2, pomb1, pomb2 = 0, 0, false, false
drzka.cinnost = 0
drzka.afaze = 0
return function()
switch(drzka.cinnost){
[1] = function()
setanim(drzka, "a5d2a10d11a11d4a10d4a11d4a10d4a11d4a10d?20-40a9")
drzka.cinnost = drzka.cinnost + 1
end,
[2] = function()
goanim(drzka)
end,
}
drzka:updateAnim()
end
end
-- -------------------------------------------------------------
local function prog_init_lbalon()
return function()
if lbalon.dir == dir_left then
if lbalon.afaze == 0 then
lbalon.afaze = 3
else
lbalon.afaze = lbalon.afaze - 1
end
elseif lbalon.dir == dir_right then
if lbalon.afaze == 3 then
lbalon.afaze = 0
else
lbalon.afaze = lbalon.afaze + 1
end
elseif lbalon.X == krab.X and lbalon.Y - 3 == krab.Y then
if lbalon.afaze == 3 then
lbalon.afaze = 0
else
lbalon.afaze = lbalon.afaze + 1
end
krab.beh = 1
end
lbalon:updateAnim()
end
end
-- -------------------------------------------------------------
local function prog_init_rbalon()
return function()
if rbalon.dir == dir_left then
if rbalon.afaze == 0 then
rbalon.afaze = 3
else
rbalon.afaze = rbalon.afaze - 1
end
elseif rbalon.dir == dir_right then
if rbalon.afaze == 3 then
rbalon.afaze = 0
else
rbalon.afaze = rbalon.afaze + 1
end
elseif rbalon.X - 5 == krab.X and rbalon.Y - 3 == krab.Y then
if rbalon.afaze == 0 then
rbalon.afaze = 3
else
rbalon.afaze = rbalon.afaze - 1
end
krab.beh = 1
end
rbalon:updateAnim()
end
end
-- -------------------------------------------------------------
local function prog_init_balon1()
local pom1, pom2, pomb1, pomb2 = 0, 0, false, false
balon1.pauza = random(200)
return function()
if balon1.dir == dir_left then
if balon1.afaze == 0 then
balon1.afaze = 3
else
balon1.afaze = balon1.afaze - 1
end
elseif balon1.dir == dir_right then
if balon1.afaze == 3 then
balon1.afaze = 0
else
balon1.afaze = balon1.afaze + 1
end
elseif balon1.pauza == 0 then
balon1.pauza = random(320) - 60
end
if balon1.pauza < 0 then
if balon1.afaze == 3 then
balon1.afaze = 0
else
balon1.afaze = balon1.afaze + 1
end
balon1.pauza = balon1.pauza + 1
else
balon1.pauza = balon1.pauza - 1
end
balon1:updateAnim()
end
end
-- -------------------------------------------------------------
local function prog_init_balon2()
return function()
if balon2.dir == dir_left then
if balon2.afaze == 0 then
balon2.afaze = 3
else
balon2.afaze = balon2.afaze - 1
end
elseif balon2.dir == dir_right then
if balon2.afaze == 3 then
balon2.afaze = 0
else
balon2.afaze = balon2.afaze + 1
end
end
balon2:updateAnim()
end
end
-- -------------------------------------------------------------
local function prog_init_balon3()
return function()
if balon3.dir == dir_left then
if balon3.afaze == 0 then
balon3.afaze = 3
else
balon3.afaze = balon3.afaze - 1
end
elseif balon3.dir == dir_right then
if balon3.afaze == 3 then
balon3.afaze = 0
else
balon3.afaze = balon3.afaze + 1
end
end
balon3:updateAnim()
end
end
-- -------------------------------------------------------------
local function prog_init_hlava1()
return function()
end
end
-- -------------------------------------------------------------
local function prog_init_hlava2()
return function()
end
end
-- -------------------------------------------------------------
local function prog_init_hlava3()
return function()
end
end
-- -------------------------------------------------------------
local function prog_init_krab()
local pom1, pom2, pomb1, pomb2 = 0, 0, false, false
krab.beh = 0
krab.oci = 1
krab.voci = 1
krab.mrac = 1
krab.nohy = 1
krab.afaze = 10
return function()
if krab.beh == 1 then
if krab.nohy == 2 then
krab.nohy = 0
else
krab.nohy = krab.nohy + 1
end
krab.beh = 0
else
krab.nohy = 1
end
if random(20) == 1 then
krab.mrac = 1 - krab.mrac
end
if xdist(small, krab) == 0 and ydist(small, krab) <= 0 then
if small.X < krab.X then
krab.oci = 0
elseif small.X > krab.X + 3 then
krab.oci = 2
else
krab.oci = 1
end
elseif xdist(big, krab) == 0 and ydist(big, krab) <= 0 then
if big.X < krab.X - 1 then
krab.oci = 0
elseif big.X > krab.X + 3 then
krab.oci = 2
else
krab.oci = 1
end
elseif odd(game_getCycles()) then
local rand11 = random(11)
switch(rand11){
[6] = function()
if krab.voci == 0 then
krab.voci = 3
else
krab.voci = krab.voci - 1
end
end,
[9] = function()
krab.voci = random(4)
end,
default = function()
if 0 <= rand11 and rand11 <= 5 then
if krab.voci == 3 then
krab.voci = 0
else
krab.voci = krab.voci + 1
end
end
end,
}
if krab.voci == 3 then
krab.oci = 1
else
krab.oci = krab.voci
end
end
krab.afaze = krab.oci + krab.mrac * 3 + krab.nohy * 6
krab:updateAnim()
end
end
-- -------------------------------------------------------------
local function prog_init_shrimp()
local pom1, pom2, pomb1, pomb2 = 0, 0, false, false
shrimp.afaze = 4
return function()
if odd(game_getCycles()) then
switch(krab.oci){
[0] = function()
shrimp.afaze = 2
end,
[2] = function()
shrimp.afaze = 0
end,
[1] = function()
switch(krab.voci){
[1] = function()
local rand10 = random(10)
switch(rand10){
[0] = function()
shrimp.afaze = 3
end,
default = function()
if 1 <= rand10 and rand10 <= 6 then
shrimp.afaze = 4
else
shrimp.afaze = 1
end
end,
}
end,
[3] = function()
local rand10 = random(10)
if 0 <= rand10 and rand10 <= 3 then
shrimp.afaze = 3
elseif 4 <= rand10 and rand10 <= 9 then
shrimp.afaze = 4
else
shrimp.afaze = 1
end
end,
default = function()
switch(math.mod(game_getCycles(), 8)){
[0] = function()
shrimp.afaze = 1
end,
[1] = function()
shrimp.afaze = 1
end,
[4] = function()
shrimp.afaze = 3
end,
[5] = function()
shrimp.afaze = 3
end,
default = function()
shrimp.afaze = 4
end,
}
end,
}
end,
}
end
shrimp:updateAnim()
end
end
-- -------------------------------------------------------------
local function prog_init_krabik()
local pom1, pom2, pomb1, pomb2 = 0, 0, false, false
krabik.spi = 0
krabik.afaze = 0
return function()
if odd(game_getCycles()) then
if krabik.spi > 0 then
krabik.afaze = 1
krabik.spi = krabik.spi - 1
else
switch(shrimp.afaze){
[0] = function()
krabik.afaze = 5
end,
[1] = function()
krabik.afaze = 2
end,
[2] = function()
krabik.afaze = 4
end,
[3] = function()
krabik.afaze = 3
end,
[4] = function()
krabik.afaze = 0
end,
}
if random(100) == 14 then
krabik.spi = random(30)
end
end
end
krabik:updateAnim()
end
end
-- --------------------
local update_table = {}
local subinit
subinit = prog_init_room()
if subinit then
table.insert(update_table, subinit)
end
subinit = prog_init_drzka()
if subinit then
table.insert(update_table, subinit)
end
subinit = prog_init_lbalon()
if subinit then
table.insert(update_table, subinit)
end
subinit = prog_init_rbalon()
if subinit then
table.insert(update_table, subinit)
end
subinit = prog_init_balon1()
if subinit then
table.insert(update_table, subinit)
end
subinit = prog_init_balon2()
if subinit then
table.insert(update_table, subinit)
end
subinit = prog_init_balon3()
if subinit then
table.insert(update_table, subinit)
end
subinit = prog_init_hlava1()
if subinit then
table.insert(update_table, subinit)
end
subinit = prog_init_hlava2()
if subinit then
table.insert(update_table, subinit)
end
subinit = prog_init_hlava3()
if subinit then
table.insert(update_table, subinit)
end
subinit = prog_init_krab()
if subinit then
table.insert(update_table, subinit)
end
subinit = prog_init_shrimp()
if subinit then
table.insert(update_table, subinit)
end
subinit = prog_init_krabik()
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
|