Skip to content

Instantly share code, notes, and snippets.

@foldi
Last active December 18, 2015 09:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save foldi/5763708 to your computer and use it in GitHub Desktop.
Save foldi/5763708 to your computer and use it in GitHub Desktop.
FloraJS - Simple

Simple System

FloraJS has two major components, a set of classes for elements in a natural system, and a renderer called Burner to draw those elements to the DOM.

To setup a simple Flora system, reference the Burner and Flora .js files from scripts tag in the <head> of your document. Also, reference the Burner and Flora .css files from link tags.

In the body, add a <script> tag and create a new system. Pass the system a function that describes the elements in your world.

You should see a block fall and bounce off the bottom of your browser window.

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<title>FloraJS | Simulate natural systems with JavaScript</title>
<link rel="stylesheet" href="http://www.florajs.com/demos/css/burner.min.css" type="text/css" charset="utf-8" />
<link rel="stylesheet" href="http://www.florajs.com/demos/css/flora.min.css" type="text/css" charset="utf-8" />
<script src="http://www.florajs.com/demos/scripts/burner.min.js" type="text/javascript" charset="utf-8"></script>
<script src="http://www.florajs.com/demos/scripts/flora.min.js" type="text/javascript" charset="utf-8"></script>
</head>
<body>
<script type="text/javascript" charset="utf-8">
Burner.System.init(function() {
this.add('Agent');
this.add('Caption', {
text: 'Simple',
opacity: 0.4,
borderColor: 'transparent',
position: 'top center'
});
this.add('InputMenu', {
opacity: 0.4,
borderColor: 'transparent',
position: 'bottom center'
});
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment