LogInfo("-----", "Scene: Classic", "Created by Neil Carter", "Converted to Lua by Charles McGarvey", "-----") -- Scene API: -- -- Functions: -- SetBounds(point1, point2) -- ResetTransform() -- Translate(x, y, z) -- Scale(x, y, z) or Scale(xyz) -- Rotate(axis, degree) or Rotate(x, y, z) -- SetTexture(name) -- DrawTilemap({width = $num, [surface = TOP | LEFT | RIGHT], tiles}) -- DrawTile(tile, [u_scale]) -- -- Globals: -- detail - level of detail of the scene (HIGH, MEDIUM, or LOW) --SetBounds({-5, 0, -6}, {45, 15, 4}) --geometry = yoink.mesh("classic.ac") --geometry:draw() --geometry = yoink.mesh.fromstring([[ --AC3Db --OBJECT poly --name "Hello World" --... --]] -- Functions: -- DisplayText(text, seconds) -- Yield(seconds) -- SpawnItem(what, coords, timeout) -- SpawnRandomItem(coords, timeout) -- SpawnCharacter(what, coords, ai level) -- SpawnHeroine(coords) -- PlaySound(name) -- PlayMusic(name) -- BeginNewWave() -- Events: -- Think() is called periodically -- BadGuyDied(enemy) -- HeroineDied(player) -- Globals: -- numberOfBadGuys --do --SpawnHeroine({5, 5}) --local waveNum = BeginNewWave() --PopulateScene(waveNum) --end -- Events --------- Event = {} do local mysound = yoink.sound("Explosion") mysound = yoink.sound() mysound:sample("Pop") local count = 0 function Event.Think() if count % 300 == 0 then mysound:play() LogDebug("Hello world!") end count = count + 1 end end classic_mesh = yoink.mesh("classic") --drawme = {} --world = classic_mesh:object(1) --for i = 1, 19 do --local object = world:kid(i) --if object then table.insert(drawme, object) end --end --lawn = classic_mesh:object(1):kid("M-Lawn") --Event.Draw = function() tower:draw(false) end Event.Draw = function() --for i,object in ipairs(drawme) do --object:draw() --end --lawn:draw() classic_mesh:draw() end function Event:BadGuyDied(enemy) if numberOfBadGuys == 0 then local waveNum = BeginNewWave() PopulateScene(waveNum) end if math.random() <= 0.2 then SpawnRandomItem(enemy.position) end end -- Helper functions ------------------- function PopulateScene(waveNum) -- spawn some robot troopers local numBadGuys = math.random(3, 2 * waveNum) for i = 0, numBadGuys do SpawnCharacter("RobotTrooper", RandomSpawnPlace(), RandomSkillLevel()) end -- spawn some alien warriors if waveNum >= 10 then numBadGuys = math.random(3, 2 * waveNum) for i = 0, numBadGuys do SpawnCharacter("AlienWarrior", RandomSpawnPlace(), RandomSkillLevel()) end end -- spawn some jetbots if waveNum >= 20 then numBadGuys = math.random(3, 2 * waveNum) for i = 0, numBadGuys do SpawnCharacter("Jetbot", RandomSpawnPlace(), RandomSkillLevel()) end end end function RandomSpawnPlace() return {5, 5} end function RandomSkillLevel() return "dumb" end -- vim: ts=4 sw=4 tw=80