From 64f16c7f1574af3950f3e972ef8a99c8b3e20786 Mon Sep 17 00:00:00 2001 From: gauthiier Date: Sun, 15 Jan 2023 11:13:49 +0100 Subject: [PATCH] 2.Ghost --- 2.Ghost-Writing.md | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 2.Ghost-Writing.md diff --git a/2.Ghost-Writing.md b/2.Ghost-Writing.md new file mode 100644 index 0000000..b561a55 --- /dev/null +++ b/2.Ghost-Writing.md @@ -0,0 +1,31 @@ +# Ghost Writing: Text, Arrays, Randomness + + +```javascript +// Array + Index! + +var NAMES = ["David", "Karin", "Sigrid", "Nanna", "Laura", "Maaike"]; +var INDEX = 0; + +function setup() { + createCanvas(400, 400); +} + +function draw() { + background(220); +} + +function keyTyped() { + if(key == 'x') { + print("Hi " + NAMES[0] + "!"); + } +} + +// Reference: https://p5js.org/reference/ +``` + +```javascript + ["David", "Karin", "Sigrid", "Nanna", "Laura", "Maaikke"] <--- Array (var NAMES) + | | | | | | + 0 1 2 3 4 5 <--- indices (var INDEX) +``` \ No newline at end of file