From 140f38bb3e85cd701aaf68b7f0dce846912e2260 Mon Sep 17 00:00:00 2001 From: Lev Date: Wed, 9 Jun 2021 00:39:13 -0500 Subject: [PATCH] Update changed puph pop to vertex shape --- .../Topic 4/4.2.1/sketch.js | 27 ++++++++++--------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/CM2030 Graphics Programming/Topic 4/4.2.1/sketch.js b/CM2030 Graphics Programming/Topic 4/4.2.1/sketch.js index 91cf119..ad45a55 100644 --- a/CM2030 Graphics Programming/Topic 4/4.2.1/sketch.js +++ b/CM2030 Graphics Programming/Topic 4/4.2.1/sketch.js @@ -22,18 +22,19 @@ function setup() { function draw() { background(0); Engine.update(engine); - rectMode(CENTER); - push(); - let pos = box1.position; - translate(pos.x, pos.y); - rotate(box1.angle); - rect(0, 0, 80, 80); - pop(); + + fill(255); + drawVertices(box1.vertices); - push(); - pos = ground.position; - translate(pos.x, pos.y); - rotate(ground.angle); - rect(0, 0, 810, 10); - pop(); + fill(150, 50, 50); + drawVertices(ground.vertices); } + +function drawVertices(vertices) +{ + beginShape(); + for (let i = 0; i < vertices.length; i++) { + vertex(vertices[i].x, vertices[i].y); + } + endShape(); +} \ No newline at end of file