 			sortedPointTuple = pointSort( (@points[name] for name in tuple) )
 			nameTuple = (p.toString() for p in sortedPointTuple)
 			@tuples.push(sortedPointTuple)
-			@unfound_tuples.push(JSON.stringify(nameTuple)) # Note different data type from @tuples
+			@unfound_tuples.push(JSON.stringify(nameTuple))
+			# Note different data type from @tuples
 		@source = json_array["source"]
 		@filename = json_array["filename"]
 		@mistakes = 0
+		@active_points = []
+
+class Game
+	constructor: (@diagram_names) ->
+		CANVAS = $("<canvas></canvas>")
+		CANVAS.attr "height", CANVAS_HEIGHT
+		CANVAS.attr "width",  CANVAS_WIDTH
+		CANVAS.click onDiagramClick
+
+		CONTEXT = CANVAS.get(0).getContext("2d")
+		$("#site").empty()
+		$("#site").append(CANVAS)
+		$("#check_button").click onCheckButtonClick
+		$("#done_button").click onDoneButtonClick
+
 
 dist = (p, q) ->
 	Math.pow(Math.pow(p.x-q.x, 2) + Math.pow(p.y-q.y, 2), 0.5)

# High-level things
markAllActive = (c = "blue") ->
	clearAll()
	# Mark all selected points
	for p in active_points
		fillCircle(p, color=c, r=5)
		drawCircle(p, color=c, r=30)
	$("span#active_points").html(active_points.toString())

	# Decide whether "Check", Done button enabled
	enableButtonIf("#check_button", active_points.length > 0)
	enableButtonIf("#done_button", (active_points.length == 0) &&
		(diagram.unfound_tuples.length != diagram.tuples.length))

# }}}
# Click handler {{{
toggle = (p) ->
	if not (p in active_points)
		active_points.push(p)
	else
		del(active_points, p)
	markAllActive()

onDiagramClick = (e) ->

# Start Game {{{

startGame = () ->
	game = new Game()
	loadDiagram "demo1"
	markAllActive
# }}}

# Main function {{{
