--- /dev/null
+const canvas_width = 600;
+const canvas_height = 400;
+
+const tile_size = 48;
+
+const camera_init = () => {
+ return {
+ x: 0,
+ y: 0,
+ };
+};
+
+let context;
+
+let camera = camera_init();
+let images = new Map();
+let entities = [];
+
+const image_load = (images, path) => {
+ let image = new Image();
+ image.src = path;
+
+ images.set(path, image);
+};
+
+const entity_init = () => {
+ return {
+ x: 0,
+ y: 0,
+ sheet_x: 0,
+ sheet_y: 0,
+ image: undefined,
+ };
+};
+
+const entity_draw = () => {
+
+};
+
+const catto_init = () => {
+ let entity = entity_init();
+ entity = images.get("cattoland/catto.png");
+
+ return entity;
+};
+
+const main = () => {
+ image_load(images, "cattoland/catto.png");
+
+ entities.push(catto_init());
+
+ let canvas = document.createElement("canvas")
+
+ { // Add canvas to DOM.
+ canvas.width = canvas_width;
+ canvas.height = canvas_height;
+
+ let script = document.getElementsByTagName("script")[0];
+ script.insertAdjacentElement("afterend", canvas);
+ }
+
+ context = canvas.getContext("2d");
+
+ context.webkitImageSmoothingEnabled = false;
+ context.mozImageSmoothingEnabled = false;
+ context.imageSmoothingEnabled = false;
+
+ window.requestAnimationFrame(loop);
+};
+
+const loop = (delta) => {
+ context.fillStyle = "#FFFFFF";
+ context.fillRect(0, 0, 600, 400);
+
+ for (let entity of entities) {
+ { // Draw shadow.
+ let anchor_x = tile_size / 2;
+ let anchor_y = tile_size - 3;
+
+ let x = entity.x + canvas_width / 2 + camera.x - anchor_x;
+ let y = entity.y + canvas_height / 2 + camera.y - anchor_y;
+
+ let sheet_x = 0 * sheet_tile_size;
+ let sheet_y = 0 * sheet_tile_size;
+
+ context.drawImage(
+ catto_image,
+ sheet_x, sheet_y, sheet_tile_size, sheet_tile_size,
+ x, y, tile_size, tile_size,
+ );
+ }
+
+ { // Draw catto.
+ let anchor_x = tile_size / 2;
+ let anchor_y = tile_size;
+
+ let x = catto.x + canvas_width / 2 + camera.x - anchor_x;
+ let y = catto.y + canvas_height / 2 + camera.y - anchor_y;
+
+ let sheet_x = catto.sheet_x * sheet_tile_size;
+ let sheet_y = catto.sheet_y * sheet_tile_size;
+
+ context.drawImage(
+ catto_image,
+ sheet_x, sheet_y, sheet_tile_size, sheet_tile_size,
+ x, y, tile_size, tile_size,
+ );
+ }
+ }
+
+ window.requestAnimationFrame(loop);
+};
+
+window.onload = main;