(1) Your FC account doesn't work here; (2) All new usernames must be of the form (letters)(space)(letters); (3) Contribute!
NOTE: The style guide dictates that all headings and page titles are in sentence case.

Guide:Level design with FCML

From Fantastic Wiki

Jump to: navigation, search
Image:3part.png
  1. Basics
  2. Advanced
  3. FCML

Welcome to the third and last part of the three part level design guide series. This particular guide will introduce you to the Fantastic Contraption Markup Language, and combined with the WebFCML editor, you will be able to create things you could otherwise not create with the in-game level editor. FCML is key to all those things you see in the game that make you ask "huh, what is that?"

Contents

[edit] What is FCML?

FCML is a simple computer language that lets you describe levels. Here's an example of a goal ball at coordinate (5, 3), with width and height 50, and rotated 0 degrees.

GoalBall (5, 3), (50, 50), 0
Image:Guide tip.png
If you've never taken Geometry, this concept may be harder to grasp.

Before you continue with this guide, you will will have to learn FCML. There are already tutorials written about it, so please read one of the following two or even both:

Be aware that FCML is only a language. To put it into FC, you use a program made by sk89q called WebFCML (explained in the above tutorials). Because WebFCML bypasses the in-game level editor, it allows you to do things that you couldn't do normally.

[edit] Uses of FCML

Image:Guide tip.png
Some of the following uses are written with older-aged people in mind. If you are just here to figure out what "cool" objects you can use, scroll to the bottom of this article.

Now, before we jump into some specific uses of FCML, let's think about some general things that we can do. For example, since FCML is just a bunch of text, did you know you can just use Notepad's find/replace to easily change something quickly?

[edit] Precision and accuracy

The most obvious use of FCML is alignment, precision, and accuracy. Because you now have to access to the numbers of every object, you can make your level perfectly aligned in every aspect.

Minor consideration: Fantastic Contraption natively talks in radians and not degrees. However, FCML uses degrees for ease of use reasons, but very minor calculation errors are introduced whenever you import a level into the game and export it in FCML. This is very minor though, affecting angles by at most .000001.

[edit] Swapping objects and values

Because FCML is just a text-based computer language, you can easily change the types of object in your levels by using a text editor (like Notepad) with a text replace function. You can also change values using a text editor's replace function.

[edit] Generating circles

The WebFCML editor has a very useful tool for generating circles in all four quadrants or in just one or two. Create circles by using the "Circle generator" item under the Plugins menu of WebFCML. Circles are created using regular rectangles.

To make smooth circles, adjust the change in degrees and the width until the circle looks smooth. Decreasing the change in degrees means that there will be more rectangles created per degree, which will make your circle smoother. However, you will also need to adjust the bar width because a width that is too high will have each rectangle peek outside of the circle too much.

If you do want to use static rectangles for the circle, just use a text editor to change the type of object. See the last section for more information.

[edit] Transformation

In addition to the circle generator, you can also transform your level using WebFCML. You can shift the objects in your level, scale your level, rotate your level, and flip your level.

When rotating, you can select an "about" point, which will be the point that the items will be rotated around. By default, it's (0, 0), meaning that everything will be rotated around the center of the level.

You should use the transformation tool to center your levels.

[edit] Level settling

You can setle the objects in your level by using WebFCML's Settle tool. Your level will be simulated as it would be in the game (although not exactly), so gravity pulls everything down to the ground.

[edit] Line art

While FCML itself doesn't allow you to do this, sk89q has written an "SVG" (a vector drawing format) to FCML converter, so you can use your favorite vector drawing program and convert it to line art in the game.

For information about this, please see the related thread.

[edit] Mathematics, programming, and FCML

Because FCML is such a simple language to write and generate, you can easily combine FCML with your favorite mathematical computation software package such as MATLAB or Mathematica.

While FCML did not exist back then, sk89q played with generating levels from simple mathematical functions. hewledj created Butterworth using MATLAB (when FCML had already been developed).

You can also use some programming to create levels. The spiral in variations by dbroughton was created using some ColdFusion code, although it also has been converted to Python (see it here).

[edit] Bending the rules

WebFCML is less strict on limits, and it will let you create objects of sizes that are not possible from within the in-game editor.

With WebFCML, you can create build and goal areas that are smaller than usual.

[edit] Advanced uses

[edit] Going small

Because of WebFCML's lax limits, you can create most objects down to 1 by 1 pixels. Now, unfortunately, you can't put too many objects because you will either cross the object limit or bog down the game too much, but small objects can prove to be an interesting element of level if used correctly, although no one has really found a great use for them yet.

DynamicRect (500, 200), (1, 1), 0

You can see a demo of small dynamic circles created by sk89q in September 2008. Later in December 2008, mikesbullseye re-discovered them and made Pogo Berries (although that's not a great use of them).

[edit] Water simulation

Using small [dynamic circle]s of around 4 diameter, you can somewhat simulate water. It doesn't correctly simulate pressure at all, but objects can penetrate it somewhat like water. Unfortunately, these are very CPU intensive and you would need a lot of water particles for it to work well, so you can't do too much with this.

DynamicRect (500, 200), (4, 4), 0
DynamicRect (500, 200), (4, 4), 0
DynamicRect (500, 200), (4, 4), 0
DynamicRect (500, 200), (4, 4), 0
DynamicRect (500, 200), (4, 4), 0
DynamicRect (500, 200), (4, 4), 0
DynamicRect (500, 200), (4, 4), 0
DynamicRect (500, 200), (4, 4), 0
DynamicRect (500, 200), (4, 4), 0
DynamicRect (500, 200), (4, 4), 0

[edit] Ghost objects

There is a special property of objects where if at least one dimension (width or height) is zero, the object will float because it has no mass. You may have seen ghost objects before. While there is no way to create objects of zero width or zero height in the in-game editor, you can do so with WebFCML.

DynamicRect (500, 200), (200, 0), 0

The odd thing about ghost objects is that rectangles (both dynamic and rods) pass through them but circles (also both dynamic and player-made) do not. This means that wheels cannot go through them but rods can.

With WebFCML, you can only make ghost objects out of dynamic rectangles, so that you cannot confuse players by creating ghost static rectangeles.

[edit] Monorail levels

You can use ghost objects to create monorail tracks because rods can pass through them. Wheels can be used to grab onto the track. An example of a monorail level is FC Express by sk89q.

Using that SVG to FCML converter mentioned earlier on this page, you can make smooth and continuous monorail tracks.

[edit] Requiring brown/blue designs

Because wheels cannot pass through or overlap ghost objects, if you put a grid of ghost objects spaced apart just the right distance (less than 40 units apart), you can prevent wheels from being created. Use this sparsely though, because it is quite unsightly. Another alternative would be to border the build area with ghost objects, which looks better, but wheels can still technically be created (although they cannot be put to good use).

[edit] Wheels

You can create unpowered and powered wheels in levels with WebFCML. Make sure the width and height are 40.

UnpoweredWheel (500, 200), (40, 40), 0
CWWheel (500, 250), (40, 40), 0
CCWWheel (500, 300), (40, 40), 0

Unless you do something special with them, the wheels act just like dynamic circles, except that they can be deleted by the player if you leave them within the build area. This brings us to the next point.

Note: You cannot edit a level with a powered wheel using the in-game editor. The powered wheels will disappear. This obviously presents some complications. You may want to first create your level and save it with a liberal build area, save a solution with the wheels added, export the FCML for that design, re-adjust the build area, and then save the final level.

[edit] Goal objects on wheels

Unconnected wheels are pretty boring, so you obviously want to connect them to some goal rectangles! To accomplish this, you must position the center of the wheel over the joint on the goal rectangle. Afterwards, you specify the ID number of the rectangle on when you list the wheel, meaning that the two objects will be connected to each other.

GoalRectangle#14 (0, 0), (200, 40), 0
UnpoweredWheel#16 (0, 0), (40, 40), 0, [14]

In the above example, the goal rectangle is given an ID of 14. At the end of the UnpoweredWheel line, it listed the object that the wheel was connected to. The wheel also has an ID, but that is unnecessary, and just added for an example. ID numbers should be 0 or greater.

[edit] Propeller

Exploiting the fact rectangles that can cross ghost objects but circles can not, you can create a propeller of sorts. See sk89q's level "Spin On" or Klatimer's "Inner Workings" level for an example.

Personal tools
Fantastic Contraption