Spaces:
Sleeping
Sleeping
File size: 1,750 Bytes
2a6d2b0 42ab4a9 2a6d2b0 c8e039e 42ab4a9 2a6d2b0 42ab4a9 2a6d2b0 42ab4a9 2a6d2b0 42ab4a9 2a6d2b0 42ab4a9 2a6d2b0 42ab4a9 2a6d2b0 42ab4a9 c8e039e 42ab4a9 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
const CELL_SIZE = 50;
let GRID_COLS = 0;
let GRID_ROWS = 0;
let grid = [];
let gameState;
let baseMapImg;
let girlfriendImg;
let clownImg;
let isSoundOn =
localStorage.getItem("isSoundOn") === null
? true
: localStorage.getItem("isSoundOn") !== "false";
const soundIcon = document.getElementById("soundIcon");
const bgMusic = document.getElementById("bgMusic");
const mistralAPI = new MistralAPI();
let chatMessages = [];
let furnitureSprites = {};
function setup() {
baseMapImg = loadImage("/assets/img/appartment/basemap.png");
girlfriendImg = loadImage("/assets/img/gf.png");
clownImg = loadImage("/assets/img/clown.png");
gameState = new GameState({
...getApt(),
grid: getGrid(),
furniture: getFurniture(),
});
furnitureSprites = loadFurnitureSprites(gameState.map_data.furniture);
GRID_COLS = gameState.map_data.gridCols;
GRID_ROWS = gameState.map_data.gridRows;
girlfriend = new Girlfriend(gameState, girlfriendImg);
clown = new Clown(gameState, clownImg);
// Once loaded, initialize the P5 canvas with correct dims
let canvas = createCanvas(GRID_COLS * CELL_SIZE, GRID_ROWS * CELL_SIZE);
canvas.parent("mapWrapper");
adjustScale();
}
function draw() {
clear();
if (baseMapImg) {
image(baseMapImg, 0, 0, GRID_COLS * CELL_SIZE, GRID_ROWS * CELL_SIZE);
}
if (furnitureSprites) {
drawFurniture(gameState.map_data.furniture, furnitureSprites);
}
//drawGrid();
// drawWallsAndDoors();
drawLabels(gameState.map_data.rooms);
drawStorage()
if (girlfriend) {
girlfriend.drawPath(CELL_SIZE);
girlfriend.draw(CELL_SIZE);
}
if (clown) {
clown.checkForGirlfriend(girlfriend);
clown.drawPath(CELL_SIZE);
clown.draw(CELL_SIZE);
}
}
|