Skip to content

Latest commit

 

History

History
109 lines (73 loc) · 2.96 KB

readme.md

File metadata and controls

109 lines (73 loc) · 2.96 KB

JavaScriptKara

allstyles

JavaScriptKara aims to teach students fundamental ideas of programming.

Kara is like Sokoban. It is very popular in German speaking countries to teach students how to program. JavaScriptKara reimplements JavaScriptKara from swisseduc.ch.

In contrast to the original JavaScriptKara itself is written in JavaScript and is under Mozilla Public License 2.0.

Real world use: ada7.de

Download

Just grab js/sokoban.js and img and you are ready to go.

Live

Demo

Editor

How to use

For full example see: demo/demo.html

w = 32; //cellsize in px
margin = 2; //margin inside cell in px
wait = 800; //wait between each move and turn of kara in ms
style = "flaticon"; // use: classic, flaticon, icon8_color, icon8_ios or icon8_office

/*
	#: Tree
	@: Kara
	.: Leaf
	$: Mushroom
	*: Mushroom on a Leaf
	+: Kara on a Leaf

*/

// Be aware that space in front of line are interpretated as empty fields.
karasworld = `world:
#####
# .. #
# @$ #
# *  #
######`

//All settings above are optional. You only have to run this:
setup();

/*
kara
	senor: onLeaf(), treeFront(), treeLeft(), treeRight(), mushroomFront()
	actor: move(), turnLeft(), turnRight(), putLeaf(), removeLeaf()
*/

function run() {
	kara.move();
	kara.turnLeft();
	kara.move();
	if (kara.onLeaf()) {
		kara.removeLeaf();
	}
	if (kara.treeFront()) {
		kara.turnRight();
		kara.move();
	}
	if (kara.treeLeft()) {
		kara.putLeaf();
		kara.turnRight();
		kara.move();
	}
  
  function turnaround() {
    kara.turnRight();
    kara.turnRight();
  }
  
  turnaround();
}

Syntax for creating a world is compatibel to GreenfootKara.

Contributing

I would love to see JavaScriptKara in action! Please release your excesices with JavaScriptKara to help other teachers to make there lessons also greate. 😄

Thank you for considering contributing to the JavaScriptKara! Create a pull request or contact me.

Licence

JavaScript is licenced under Mozilla Public License 2.0. Just name me on the same page and link to this page or wi-wissen.de. On printed works you have to name me with my realname like other authors or contributors. If you made changes to JavaScriptKara you have to provide the source code.

All icons are designed by very talented people. Please respect there copyright: