Skip to content

load1n9/caviar

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation


caviar stars caviar releases caviar License


game engine built on top of deno_sdl2

Usage

image

import { World, Image, } from 'https://deno.land/x/caviar/mod.ts';


class Game extends World {
    public test = new Image(this, "https://deno.land/x/caviar/assets/caviar.png", 200, 100, 414, 197);
    
    public setup() {
        this.addChild(this.test);
    }
    public draw() {
        
    }
}

const test = new Game({
    title: "test",
    width: 800,
    height: 600,
    centered: true,
    fullscreen: false,
    hidden: false,
    resizable: true,
    minimized: false,
    maximized: false,
    flags: null,
});

await test.start();

pixel texture

import { Keys, PICO8, TextureSprite, World } from 'https://deno.land/x/caviar/mod.ts';
import type { KeyEvent, MouseDownEvent } from 'https://deno.land/x/caviar/mod.ts';

class Game extends World {
  public test = new TextureSprite(this, 10, 10, {
    data: [
      "..9..9..",
      "..9999..",
      ".AAAAAA.",
      ".A1F1FA.",
      ".AFFFFA.",
      ".FEEEEAA",
      ".EEEEEEA",
      "..E..E..",
    ],
    pixelWidth: 32,
    pixelHeight: 32,
    palette: PICO8,
  });

  public setup() {
    this.addChild(this.test);
  }
  public draw() {
    
  }
  public keyDown(key: KeyEvent) {
    switch (key.keycode) {
      case Keys.ARROWUP: {
        this.test.setY(this.test.y - 10);
        break;
      }
      case Keys.ARROWDOWN: {
        this.test.setY(this.test.y + 10);
        break;
      }
      case Keys.ARROWLEFT: {
        this.test.setX(this.test.x - 10);
        break;
      }
      case Keys.ARROWRIGHT: {
        this.test.setX(this.test.x + 10);
        break;
      }
    }
  }
}

const test = new Game({
  title: "test",
  width: 800,
  height: 600,
  centered: true,
  fullscreen: false,
  hidden: false,
  resizable: true,
  minimized: false,
  maximized: false,
  flags: null,
});

await test.start();

License

MIT