From 11141a114fc9a32d71872c3d3992b5e22eda904e Mon Sep 17 00:00:00 2001 From: joowon Date: Thu, 24 Apr 2025 03:38:49 +0900 Subject: [PATCH] add background --- sketch.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/sketch.js b/sketch.js index db90eac..05273e6 100644 --- a/sketch.js +++ b/sketch.js @@ -8,6 +8,7 @@ let powerUps = []; let deathZoneY = 600; let spriteSheets = {}; +let background_sky; function preload() { // 여기에 sprite들을 preload (ex: mario = loadImage("...")) @@ -19,10 +20,23 @@ function preload() { function setup() { createCanvas(800, 600); + const bgsource = spriteSheets.backgorunds; + background_sky = createImage(400,300); + background_sky.copy(bgsource, + 514, 1565, + 512, 512, + 0, 0, + 400,300); + + } function draw() { - background(135, 206, 235); // sky blue + for (let y = 0; y < height; y += background_sky.height) { + for (let x = 0; x < width; x += background_sky.width) { + image(background_sky, x, y); + } + } // 임시 바닥 fill(100);