No Cap, Just Code

I participated in ACTEM’s (https://www.actem.org) ISTE-ASCD Book Study on “AI with Intention” by Tony Frontier. It was a thought-provoking series. One idea discussed was vibe-coding. I gave it a try!

It was easy-peasy and rigorous at the same time. So, I reached out to all the middle schoolers in our building, about 150, and invited them to learn to vibe code and to present with me at the Maine Learning Technology Initiative Student Conference. Over 1,000 middle schoolers will attend!

I set up a dedicated Space in SchoolAI. (Here’s a version for all of you to try. https://student.schoolai.com/dot/spaces/join?code=9S72-QPGN) I gave it specific instructions about developmentally and school appropriate projects, language, etc. as well as the end product goal.

I emailed my student volunteers this set of directions:

Start chatting with the AI. This platform, SchoolAI, is one that RSU 26 has paid for and is safe for students. That Space should chat with you and after you describe the app you want to build, will generate code that should power it. When you get the code, go to https://p5js.org/ . Do NOT make an account. You will see this. (image attached)

Your first job is to delete the code that is in the box with the words "let screen =" You can just select all and delete or click in the box and use command A to select all and then hit delete. 

Copy the block of code from School AI and paste it in that box.

(image attached)

Find the pencil and the unusual name to the left of it. Click on the Pencil and name your app. That will make it easier to find after you download it.

Now click File and then Save.

Now click the pink triangle.

That should run the app in the preview block on the right.

The other way to see how the app works and looks is to click on File and then Share. A pop-up will look like this: (image attached)

Click on the middle choice labeled Share Sketch as View-Only. It should open in a new tab. Try out your app. 

Expect it to look or behave differently than what you expected. Maybe it is stuck on the 1st screen. Maybe an icon is in the wrong place or too big. Go back to School AI. Tell it what the issues (bugs/glitches) are or what the error code is saying. (You'll find that in pink underneath the box labeled Console.) Then copy the new code and try again. 

Once you have a version you like or you have to stop working on it for awhile download it. You should make a new folder to store them in. I called mine App Codes.

Later, you can open the Sketch item in the folder. It will open as a tab in Chrome. Then you can run it and or continue to use the School AI space to tweak the final product!

Have fun!

Send me what you create!

Mrs. White

Here's a code I did for Weather Words. It still needs some work but, it'll give you an idea of how things work.

let screen = 'start'; // 'start' | 'game' | 'end'
let words = ['sunny', 'cloudy', 'rainy', 'snowy'];
let correctFor = { sunny: 'sun', cloudy: 'cloud', rainy: 'rain', snowy: 'snow' };

let statusByWord;
let buttons;
let score;

// Simple beep (safe to skip if p5.sound isn’t present)
let beepOsc, beepEnv;

function setup() {
createCanvas(760, 560);
textFont('Arial');
initGame();

if (typeof p5 !== 'undefined' && p5.Oscillator) {
beepOsc = new p5.Oscillator('sine');
beepEnv = new p5.Envelope();
beepEnv.setADSR(0.01, 0.06, 0.0, 0.1);
beepEnv.setRange(0.25, 0);
beepOsc.start();
beepOsc.amp(0);
}
}

function initGame() {
statusByWord = {};
for (let w of words) statusByWord[w] = 'unanswered';
buttons = [];
score = 0;

let startY = 130;
let rowGap = 90;
let gridLeft = 220;
let cellW = 68, cellH = 60, gap = 14;
let icons = ['sun', 'cloud', 'rain', 'snow'];

for (let i = 0; i < words.length; i++) {
let yTop = startY + i * rowGap;
for (let j = 0; j < icons.length; j++) {
let x = gridLeft + j * (cellW + gap);
buttons.push({ word: words[i], icon: icons[j], x: x, y: yTop, w: cellW, h: cellH });
}
}
}

function draw() {
background(245);
if (screen === 'start') drawStart();
else if (screen === 'game') drawGame();
else if (screen === 'end') drawEnd();
}

function drawStart() {
fill(30);
textAlign(CENTER, CENTER);
textSize(38);
text('Weather Words', width/2, 130);
textSize(16);
text('Click the right icon for each word. Get all 4!', width/2, 168);
drawButton(width/2 - 120, 230, 240, 56, 'Start');
}

function drawGame() {
fill(30);
textAlign(CENTER, CENTER);
textSize(20);
text('Score: ' + score + '/4', width/2, 40);

textAlign(LEFT, CENTER);
textSize(22);
let labelX = 40;
let startY = 130;
let rowGap = 90;

for (let i = 0; i < words.length; i++) {
let y = startY + i * rowGap + 30;
fill(20);
text(words[i], labelX, y);
let st = statusByWord[words[i]];
if (st === 'correct') {
fill(22, 140, 60);
text('Correct! ', labelX + 130, y);
} else if (st === 'tryagain') {
fill(200, 50, 50);
text('Try again', labelX + 130, y);
}
}

for (let b of buttons) {
let locked = statusByWord[b.word] === 'correct';
drawIconButton(b.x, b.y, b.w, b.h, b.icon, locked);
}

drawButton(width/2 - 110, height - 70, 220, 52, 'Finish');

if (words.every(w => statusByWord[w] === 'correct')) {
screen = 'end';
}
}

function drawEnd() {
fill(30);
textAlign(CENTER, CENTER);
textSize(32);
text('Results', width/2, 130);
textSize(18);
let percent = Math.round((score / 4) * 100);
text('You got ' + score + ' out of 4 (' + percent + '%)', width/2, 172);
drawButton(width/2 - 130, 220, 260, 56, 'Play Again');

textSize(14);
fill(80);
text('Deborah White & School AI', width/2, height - 30);
}

function drawButton(x, y, w, h, label) {
let hover = mouseX > x && mouseX < x + w && mouseY > y && mouseY < y + h;
noStroke();
fill(hover ? 60 : 40);
rect(x, y, w, h, 12);
fill(255);
textAlign(CENTER, CENTER);
textSize(18);
text(label, x + w/2, y + h/2);
}

function drawIconButton(x, y, w, h, icon, locked) {
push();
let hover = mouseX > x && mouseX < x + w && mouseY > y && mouseY < y + h;
noStroke();
if (locked) fill(204, 232, 210);
else fill(hover ? 235 : 255);
rect(x, y, w, h, 12);

translate(x + w/2, y + h/2);
if (icon === 'sun') {
fill(255, 200, 0);
circle(0, 0, 26);
stroke(255, 180, 0);
strokeWeight(2);
for (let a = 0; a < 8; a++) {
let ang = (TWO_PI / 8) * a;
line(cos(ang) * 18, sin(ang) * 18, cos(ang) * 30, sin(ang) * 30);
}
noStroke();
} else if (icon === 'cloud') {
fill(200);
ellipse(-12, 6, 30, 22);
ellipse(12, 6, 34, 24);
ellipse(0, -2, 32, 20);
} else if (icon === 'rain') {
fill(120, 170, 255);
noStroke();
ellipse(0, -3, 12, 18);
triangle(0, 12, -7, 0, 7, 0);
} else if (icon === 'snow') {
stroke(170);
strokeWeight(2);
for (let a = 0; a < 6; a++) {
line(0, -12, 0, 12);
rotate(PI / 3);
}
noStroke();
}
pop();
}

function mousePressed() {
if (screen === 'start') {
if (hit(width/2 - 120, 230, 240, 56)) screen = 'game';
return;
}

if (screen === 'game') {
for (let b of buttons) {
if (statusByWord[b.word] === 'correct') continue;
if (hit(b.x, b.y, b.w, b.h)) {
if (b.icon === correctFor[b.word]) {
statusByWord[b.word] = 'correct';
score++;
playBeep();
} else {
statusByWord[b.word] = 'tryagain';
}
break;
}
}
if (hit(width/2 - 110, height - 70, 220, 52)) screen = 'end';
return;
}

if (screen === 'end') {
if (hit(width/2 - 130, 220, 260, 56)) {
initGame();
screen = 'start';
}
}
}

function hit(x, y, w, h) {
return mouseX > x && mouseX < x + w && mouseY > y && mouseY < y + h;
}

function playBeep() {
if (beepOsc && beepEnv) {
beepOsc.freq(660);
beepEnv.play(beepOsc);
}
}

The students who volunteered range from those in the Life Skills Room to those in the Advanced Academic tracks. Each of them has been able to start the process independently with these directions and the support of the SchoolAI space.

Give it a try! Create your own SchoolAI space to help yourself vibe code to create apps that students can use without needing to worry about student privacy/age limits and for students to learn the process of vibe coding, revising, iterating, and learning the language of coding!