kaka.farm

Unnamed repository; edit this file 'description' to name the repository.
git clone https://kaka.farm/~git/kaka.farm
Log | Files | Refs | README

commit 8478ffab660f171362b48efe0f5080fcde34f3d0
parent d099470f63a976d3933bfb494c38003c7a8ee687
Author: Yuval Langer <yuvallangerontheroad@gmail.com>
Date:   Fri,  3 Jul 2020 12:09:46 +0300

Walk.

Diffstat:
Mhtml/sokoban.html | 25++++++++++++++++++++++++-
1 file changed, 24 insertions(+), 1 deletion(-)

diff --git a/html/sokoban.html b/html/sokoban.html @@ -2,10 +2,33 @@ <html> <head> <meta charset="utf-8"> - <title>Kaka Farm Sokoban clone: no bells no whistles no glory.</title> + <title>Kaka Farm's Sokoban clone: no bells no whistles no glory.</title> <script type="text/javascript" src="sokoban.js"></script> <script type="text/javascript"> 'use strict'; + +(function() { + function main() { + let state = sokoban.read_level_text(sokoban.level1); + let text_element = document.querySelector('#text'); + text_element.innerText = sokoban.state_to_text(state); + + [ + ['#up', [0, -1]], + ['#down', [0, 1]], + ['#left', [-1, 0]], + ['#right', [1, 0]], + ].forEach(([id, direction])=>{ + let button = document.querySelector(id); + button.addEventListener('click', function() { + sokoban.step(state, direction); + text_element.innerText = sokoban.state_to_text(state); + }); + }); + }; + + window.addEventListener('load', main); +})(); </script> </head> <body>