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