From 503cfbaa2c1112bba4415752c688b4c1f43f21d2 Mon Sep 17 00:00:00 2001 From: sam Date: Tue, 9 Jan 2024 14:09:45 +0100 Subject: [PATCH] Added documentation --- docs/documentatie/Documentatie game.md | 44 +++++++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) diff --git a/docs/documentatie/Documentatie game.md b/docs/documentatie/Documentatie game.md index fbd2fe8..353695f 100644 --- a/docs/documentatie/Documentatie game.md +++ b/docs/documentatie/Documentatie game.md @@ -1 +1,43 @@ -### \ No newline at end of file +### Van canvas switchen +```js +//Geschreven door Sam +//Is mischien een beetje een scuffed manier maar het werkt en het geeft een beetje de richting waar je op kan gaan +let canvasSwitch = true; + +function setup(){ + createCanvas(400, 400); + } + +function draw(){ + //draw a background every frame + background(220) + //switch canvas when spacebar is pressed + if (canvasSwitch == false){ + canvas1(); + } + + if (canvasSwitch == true){ + canvas2(); + } + +} + +function keyPressed(){ + if (keyCode === 32){ // 32 is the keyCode for the space bar + //if canvasSwitch is true, set it to false, vice versa + canvasSwitch = !canvasSwitch; + } +} + +//draw a yellow circle on canvas 1 +function canvas1(){ + fill(255, 255, 0) + circle (200, 200, 50); +} + +//draw a red circle on canvas 2 +function canvas2(){ + fill(255, 0, 0) + circle (300, 200, 50); +} +``` \ No newline at end of file