From dfc9c55db4f0df32d916c934d52b9e0d7cb517d1 Mon Sep 17 00:00:00 2001 From: Jee Youn Kim Date: Thu, 17 Apr 2025 00:33:02 +0900 Subject: [PATCH] modify --- index.html | 14 ++++++++++++++ main.js | 39 +++++++++++++++++++++++++++++++++++++++ style.css | 3 +++ 3 files changed, 56 insertions(+) diff --git a/index.html b/index.html index e69de29..dd55f1d 100644 --- a/index.html +++ b/index.html @@ -0,0 +1,14 @@ + + + + + + Document + + + + + + + + \ No newline at end of file diff --git a/main.js b/main.js index e69de29..22eff47 100644 --- a/main.js +++ b/main.js @@ -0,0 +1,39 @@ +// alert("hello world"); +const tileSize = 16; +const babaX = 0; +const babaY = 0; + + +function setup(){ + createCanvas(800, 400); + background(51); +} + +function draw(){ + fill(255, 204, 0); + square(babaX, babaY, 16); +} + + + + +// Move ASDW +function keyPressed(){ + console.log(`key ${key} is pressed.`) + if(key=='a'||key=='A') { + babaX -= tileSize; + console.log('Left'); + } + if(key=='s'||key=='S') { + babaY -= tileSize; + console.log('Down'); + } + if(key=='d'||key=='D') { + babaX += tileSize; + console.log('Right'); + } + if(key=='w'||key=='W') { + babaY += tileSize; + console.log('Up'); + } +} \ No newline at end of file diff --git a/style.css b/style.css index e69de29..af3dac3 100644 --- a/style.css +++ b/style.css @@ -0,0 +1,3 @@ +body{ + background-color: aquamarine; +} \ No newline at end of file