Giter VIP home page Giter VIP logo

conway.js's Introduction

Conway.js

What?

A implementation of Conways Game Of Life in javascript with a html5 canvas renderer and hopefully a pure css renderer soon.

Why?

I wrote it in C ages ago and decided to spend a few hours porting, might make a cool background for my website.

Demo

demo

Usage

<html>
<head>
	<link rel="stylesheet" type="text/css" href="style.css"/>
	<script type="text/javascript" src="jquery.js"></script>
	<script type="text/javascript" src="conway.js"></script>
	<script type="text/javascript" src="conwayui.js"></script>
	<script type="text/javascript">
	$(document).ready(function() {
		/* Create and init pool. */
		var pool = new Pool(250, 150);
		pool.locked = true;
		pool.init_pool_rand();

		/* Bind some event buttons to interact with it. */
		$('#startbutton').click(function() {
			if(pool.locked) {
				pool.locked = false;
				$('#startbutton').html('stop');
			} else {
				pool.locked = true;
				$('#startbutton').html('start');
			}
		});
		$('#clearbutton').click(function() {
			pool.init_pool_clear();
		});
		$('#randbutton').click(function() {
			pool.init_pool_rand();
		});

		/* Update text box every pool comp cycle. */
		pool.CompDone = function() {
			$('#genbox').html('Generation: ' + pool.generations);
		};

		/* Call the jquery plugin to render it. */
		$('#display').conway(pool, 50, "rgb(255,180,0)");
	});
	</script>
</head>
<body>
	<div id="header"><img src="logo.png" alt="conway.JS"/></div>
	<canvas id="display" width="1000" height="600"></canvas>
	<div>
		<div id="genbox">Generation: 0</div>
		<button id="startbutton" type="button">start</button>
		<button id="randbutton" type="button">rand</button>
		<button id="clearbutton" type="button">clear</button>
	</div>
</body>
</html>

conway.js's People

Contributors

dmateos avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.