Difference between revisions of "Programming levelgens"
From Bitfighter
Watusimoto (Talk | contribs) |
|||
(One intermediate revision by the same user not shown) | |||
Line 1: | Line 1: | ||
Creating levelgen scripts is very straightforward. The methodology basically follows that used in the level definition files. If you are familiar with that format, you will find understanding the levelgen methods very easy. The easiest way to learn how level files are structured is to create a sample level in the editor, and examine it in a text editor. Don't worry, it's not complicated! | Creating levelgen scripts is very straightforward. The methodology basically follows that used in the level definition files. If you are familiar with that format, you will find understanding the levelgen methods very easy. The easiest way to learn how level files are structured is to create a sample level in the editor, and examine it in a text editor. Don't worry, it's not complicated! | ||
+ | |||
+ | You might want to read about the [[Script structure|general structure of Bitfighter scripts]] before reading further. | ||
{{funcdoc|void|addItem|args}} - Adds an item to the game<br> | {{funcdoc|void|addItem|args}} - Adds an item to the game<br> |
Latest revision as of 09:11, 15 December 2011
Creating levelgen scripts is very straightforward. The methodology basically follows that used in the level definition files. If you are familiar with that format, you will find understanding the levelgen methods very easy. The easiest way to learn how level files are structured is to create a sample level in the editor, and examine it in a text editor. Don't worry, it's not complicated!
You might want to read about the general structure of Bitfighter scripts before reading further.
- void addItem(args)
Takes a variable number of arguments, and follows the same argument order as that used in level files.
For example:
-- Create a 10 x 10 block of RepairItems for i = 0, 10 do for j = 0, 10 do levelgen:addItem("RepairItem", 1 + i * .2, 1 + j * .2) end end
- void addWall(wallsize, issolid, points)
For example:
-- Create a U-shaped segment of wall. To create a closed loop, -- repeat the first point at the end of the list. levelgen:addWall(50, false, { Point(1,1), Point(1,5), Point(5,5), Point(5,1) } )
- void addLevelLine(line)
-- Some raw lines levelgen:addLevelLine("LoadoutZone 0 4.8 4.2 7.1 3.9 7.2 4.8 4.8 4.5") levelgen:addLevelLine("BarrierMaker 50 5.5 3 5.5 3.5")
- void getGridSize()
-- Create a 1x1 square of wall that is as thick as it is long -- Use + 1 to make adjacent blocks overlap a tiny bit and thus appear -- to merge. Note that defining one long wall is MUCH better than creating -- a series of many sorter segments. levelgen:addWall(levelgen:getGridSize() + 1, false, { Point(0,0), Point(1,0) } )
- void getPlayerCount()
-- Add an asteroid for each player at (10,10), (11, 11), etc. local players = levelgen:getPlayerCount() -- Replace with numbers for testing for i = 1, players do levelgen:addItem("Asteroid", 10 + i, 10 + i) end
- void pointCanSeePoint(point1, point2)
- void setGameTime(time_in_minutes)
levelgen:setGameTime(8.5) -- 8 1/2 minute game