diff --git a/assets/Text_IS_0.webp b/assets/Text_IS_0.webp
new file mode 100644
index 0000000..d310516
Binary files /dev/null and b/assets/Text_IS_0.webp differ
diff --git a/index.html b/index.html
index 0428ebc..458abea 100644
--- a/index.html
+++ b/index.html
@@ -5,9 +5,12 @@
Document
+
+
+
+
+
-
-
diff --git a/main.js b/main.js
index 13e66c2..2730399 100644
--- a/main.js
+++ b/main.js
@@ -2,18 +2,27 @@
const tileSize = 16;
// Sprites
-const baba = 2;
+let baba;
+let tile, wall, rock, water, lava, flag;
+let win, you, move, stop;
// CaracterMove
-const babaX = 0;
-const babaY = 0;
+let babaX = 0;
+let babaY = 0;
// Sounds
let bgm, winSound;
let isPlaying = false;
function preload(){
- bgm = loadSound("/assets/Baba Is You OST - Baba Is You Theme.mp3")
+ bgm = loadSound("/assets/Baba Is You OST - Baba Is You Theme.mp3");
+ baba = loadImage("/assets/Baba.webp");
+ tile = loadImage("/assets/Tile.webp");
+ wall = loadImage("/assets/Wall.webp");
+ rock = loadImage("/assets/Rock.webp");
+ water = loadImage("/assets/Water.webp");
+ lava = loadImage("/assets/Lava.webp");
+ flag = loadImage("/assets/Flag.webp");
}
function setup(){
@@ -23,8 +32,10 @@ function setup(){
function draw(){
// backgroundMusic();
+ background(51);
fill(255, 204, 0);
- square(babaX, babaY, 16);
+ image(baba, babaX, babaY, tileSize, tileSize);
+ // squasre(babaX, babaY, tileSize);
}
@@ -46,38 +57,40 @@ function mousePressed(){
// Move ASDW
function keyPressed(){
console.log(`key ${key} is pressed.`)
- if(keyCode == 32){
- if(isPlaying){
- isPlaying = false;
- }else{
- isPlaying = true;
- }
- console.log(isPlaying);
- }
+ // if(keyCode == 32){
+ // if(isPlaying){
+ // isPlaying = false;
+ // }else{
+ // isPlaying = true;
+ // }
+ // console.log(isPlaying);
+ // }
+
+ const maxX = width - tileSize;
+ const maxY = height - tileSize;
+
if(key=='a'||key=='A') {
- babaX -= tileSize;
- console.log('Left');
+ if (babaX - tileSize >= 0) {
+ babaX -= tileSize;
+ console.log('Left');
+ }
}
if(key=='s'||key=='S') {
- babaY -= tileSize;
- console.log('Down');
+ if (babaY + tileSize <= maxY) {
+ babaY += tileSize;
+ console.log('Down');
+ }
}
if(key=='d'||key=='D') {
- babaX += tileSize;
- console.log('Right');
+ if (babaX + tileSize <= maxX) {
+ babaX += tileSize;
+ console.log('Right');
+ }
}
if(key=='w'||key=='W') {
- babaY += tileSize;
- console.log('Up');
+ if(babaY - tileSize >= 0){
+ babaY -= tileSize;
+ console.log('Up');
+ }
}
-
- //limit BABA's movements
-// if(ghost.position.x < 0)
-// ghost.position.x = 0;
-// if(ghost.position.y < 0)
-// ghost.position.y = 0;
-// if(ghost.position.x > SCENE_W)
-// ghost.position.x = SCENE_W;
-// if(ghost.position.y > SCENE_H)
-// ghost.position.y = SCENE_H;
}
\ No newline at end of file