Wild West Contest RESULTS
Thanks to everyone for participating.
Bar Fight - Bitmatch - Quartz
Bebop - Rabbit (levelgen) - kaen
Desperados - Nexus - Little_Apple
Honky Tonk Massacre - Bitmatch - Little_Apple
Ricochet - CTF (levelgen) - kaen
Snakes vs. Boots - Bitmatch - footloose
Space Cowboys - Rabbit - bobdaduck
This Ain't No Wild West! - Bitmatch - sky_lark
The Wild retrieve - Retrieve - Santiago ZAP
Viva la muerte - Retrieve - Little_Apple
Wildest West of all the Wests - Bitmatch - sky_lark
Below a zip file of the levels, and here is the minefield levelgen that should be saved as "minefield.lua"
- Code:
- -- minefield.lua [interval] [min_mines] [max_mines] [mine_zones]
-- interval - time in milliseconds between mine spawns
-- min/max_mines - inclusive bounds for the number of mines to spawn
-- mine_zones - a table (array) of ids of zones which are minefields
--
-- interval and min/max mines are processed using 'evaluate' below for each
-- invocation of mineEvent. This allows you to express these values in terms of
-- 't', which is the number of milliseconds since the level was loaded. For
-- instance, "minefield.lua 1000 1 1+t/1000" will spawn upto as many mines as
-- the number of full seconds since the level was loaded
START_TIME = getMachineTime()
-- find the value of the string at time t
function evaluate(str)
return loadstring("t = " .. (getMachineTime() - START_TIME) .. " ; return " .. str)()
end
-- pick a random point within extents
function randomPoint(extents)
return point.new(math.random(extents.minX, extents.maxX), math.random(extents.minY, extents.maxY))
end
-- return a well-labeled table of extents
function getExtents(zone)
minX, minY, maxX, maxY = math.huge, math.huge, -math.huge, -math.huge
for index, p in pairs(zone:getGeom()) do
minX = math.min(minX, p.x)
minY = math.min(minY, p.y)
maxX = math.max(maxX, p.x)
maxY = math.max(maxY, p.y)
end
extents = {}
extents.minX = minX
extents.maxX = maxX
extents.minY = minY
extents.maxY = maxY
return extents
end
-- lay some mines in the minefields
function layMines()
-- for each minefield
for index, id in pairs(MINE_FIELDS) do
-- lay between min and max mines
for i = 1, math.random(MINE_MIN, evaluate(MINE_MAX)) do
mineField = levelgen:findObjectById(id)
-- only if the minefield exists
if mineField ~= nil then
p = randomPoint(getExtents(mineField))
mine = Mine.new(p)
levelgen:addItem(mine)
end
end
end
end
function mineEvent()
layMines()
Timer:scheduleOnce(mineEvent, math.max(100, evaluate(MINE_INTERVAL)))
end
MINE_INTERVAL = 10000
MINE_MIN = 1
MINE_MAX = 3
MINE_FIELDS = {1, 2, 3}
function main()
MINE_INTERVAL = arg[1] or MINE_INTERVAL
MINE_MIN = arg[2] or MINE_MIN
MINE_MAX = arg[3] or MINE_MAX
MINE_FIELDS = loadstring("return " .. (arg[4] or "false"))() or MINE_FIELDS
mineEvent()
end
† 19-year-old Quartz mad about lawn removal †
raptor wrote:sometimes I think getting Quartz to use plugins is like getting my mom to use a computer