diff --git a/src/assets/kaboom-logo.png b/src/assets/kaboom-logo.png new file mode 100644 index 0000000..4384ab7 Binary files /dev/null and b/src/assets/kaboom-logo.png differ diff --git a/src/libraryList.js b/src/libraryList.js index 804953d..8f59781 100644 --- a/src/libraryList.js +++ b/src/libraryList.js @@ -98,6 +98,11 @@ export const jsLibs = [ url: 'https://cdn.tailwindcss.com/3.4.3', label: 'Tailwind 3', type: 'js' + }, + { + url: 'https://unpkg.com/kaboom@3000/dist/kaboom.js', + label: 'Kaboom', + type: 'js' } ]; export const cssLibs = [ diff --git a/src/templateList.js b/src/templateList.js index 2575f73..64de838 100644 --- a/src/templateList.js +++ b/src/templateList.js @@ -30,5 +30,10 @@ export default [ title: 'Kontra Game Engine', img: 'assets/html5-logo.svg', isFileModeSupported: true + }, + { + id: 'kaboom', + title: 'Kaboom', + img: 'assets/kaboom-logo.png' } ]; diff --git a/src/templates/template-kaboom.json b/src/templates/template-kaboom.json new file mode 100644 index 0000000..40ffa95 --- /dev/null +++ b/src/templates/template-kaboom.json @@ -0,0 +1,18 @@ +{ + "title": "Kaboom game engine template", + "content": "", + "html": "", + "css": "", + "js": "// Responding to gravity & jumping\n\n// Start kaboom\nkaboom()\n\n// Load assets\nloadSprite(\"bean\", \"https://kaboomjs.com/sprites/bean.png\")\n\n// Set the gravity acceleration (pixels per second)\nsetGravity(1600)\n\n// Add player game object\nconst player = add([\n\tsprite(\"bean\"),\n\tpos(center()),\n\tarea(),\n\t// body() component gives the ability to respond to gravity\n\tbody(),\n])\n\nonKeyPress(\"space\", () => {\n\t// .isGrounded() is provided by body()\n\tif (player.isGrounded()) {\n\t\t// .jump() is provided by body()\n\t\tplayer.jump()\n\t}\n})\n\n// .onGround() is provided by body(). It registers an event that runs whenever player hits the ground.\nplayer.onGround(() => {\n\tdebug.log(\"ouch\")\n})\n\n// Accelerate falling when player holding down arrow key\nonKeyDown(\"down\", () => {\n\tif (!player.isGrounded()) {\n\t\tplayer.vel.y += dt() * 1200\n\t}\n})\n\n// Jump higher if space is held\nonKeyDown(\"space\", () => {\n\tif (!player.isGrounded() && player.vel.y < 0) {\n\t\tplayer.vel.y -= dt() * 600\n\t}\n})\n\n// Add a platform to hold the player\nadd([\n\trect(width(), 48),\n\toutline(4),\n\tarea(),\n\tpos(0, height() - 48),\n\t// Give objects a body() component if you don't want other solid objects pass through\n\tbody({ isStatic: true }),\n])\n\nadd([\n\ttext(\"Press space key\", { width: width() / 2 }),\n\tpos(12, 12),\n])\n\n// Check out https://kaboomjs.com#BodyComp for everything body() provides\n", + "externalLibs": { + "js": "\nhttps://unpkg.com/kaboom@3000/dist/kaboom.js", + "css": "" + }, + "layoutMode": 1, + "htmlMode": "html", + "cssMode": "css", + "jsMode": "js", + + "mainSizes": [50, 50], + "sizes": ["33px", "33px", 100] +}