• Stars
    star
    106
  • Rank 315,508 (Top 7 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created almost 4 years ago
  • Updated over 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Lightweight, Fast, Easy-to-use HTML5 2D game framework!

Pancake


Lightweight, Fast, Easy-to-use HTML5 2D game framework!



Pancake is successor of Cake game engine, Which can be found here, But no longer maintained!

Pancake inspired by LOVE, Pygame, And even AppGameKit and it shares some of their concepts...

Features

  • Shares concepts of most lovable frameworks like LOVE, Pygame, And AppGameKit!
  • Easy and simple to setup!
  • Free, Moddable, Open-Source, Cross-Platform!
  • Fast, Very lightweight, And very thin in one file!
  • Every part needed is written without dependencies! From OS detection to gamepad support...
  • You can use CanvasRenderingContext2D or WebGLRenderingContext as graphics renderer!
  • Collision detection physics!
  • Audio based on HTMLAudio API!
  • Video rendering support!
  • Replay rewind support!
  • Spritefonts and Sprites support!
  • Have plugins can be used like WASM, FBInstant, And more...
  • Written in plain JavaScript (Vanilla JavaScript) to support browsers that can't run modern JavaScript! (Internet Explorer for example)
  • Supports Haxe via Pancake.hx
  • Using indexes (Slots), Which can be good for ordering sometimes, And gives easy control of game content!
  • Optimized for js13kGames game jam!

Want to know a lot? See the documentation

Also check out our Discord server here

Examples

  • Creating a game canvas
// Create canvas with both width and height of 600, And set it's index to 0
pancake.canvas.create(600, 600, 0);

// Create context with index 0 and set to use canvas that has index 0
// And set graphics to use context with index 0
pancake.context.create(0, 0);
pancake.graphics.useContext(0);
  • Drawing text
// Create canvas with both width and height of 600, And set it's index to 0
pancake.canvas.create(600, 600, 0);

// Create context with index 0 and set to use canvas that has index 0
// And set graphics to use context with index 0
pancake.context.create(0, 0);
pancake.graphics.useContext(0);

// We can set font and it's size in pixels
pancake.graphics.setFont("Arial", 22);

// Draw text
pancake.graphics.text("Hello Pancake", 10, 10);
  • Drawing shapes
// Create canvas with both width and height of 600, And set it's index to 0
pancake.canvas.create(800, 800, 0);

// Create context with index 0 and set to use canvas that has index 0
// And set graphics to use context with index 0
pancake.context.create(0, 0);
pancake.graphics.useContext(0);

// Draw rectangle with red color
pancake.graphics.color(pancake.graphics.RGB(255, 0, 0));
pancake.graphics.rect(100, 100, 50, 50);

// Draw circle with radius of 50 and orange color
pancake.graphics.color(pancake.graphics.RGB(255, 165, 0));
pancake.graphics.circle(200, 200, 50);

// Draw line with width of 5 and yellow color
pancake.graphics.color(pancake.graphics.RGB(255, 255, 0));
pancake.graphics.line(100, 100, 200, 200, 5);

// Set drawing mode to stroke
pancake.graphics.mode = pancake.graphics.STROKE;

// Draw triangle with green color
pancake.graphics.color(pancake.graphics.RGB(0, 255, 0));
pancake.graphics.triangle(500, 50, 600, 50, 500, 150);

// Draw polygon with 6 sides and blue color
pancake.graphics.color(pancake.graphics.RGB(0, 0, 255));

pancake.graphics.polygon(100, 300, 50, 6);
  • Playing Audio
// When audio loaded, Play it directly
pancake.audio.play("game.mp3");

// Load audio file to index 0
pancake.audio.load("loaded.mp3", 0);

// Plays loaded.mp3
pancake.audio.playFromIndex(0);

// Pauses loaded.mp3
pancake.audio.pause(0);

// Resumes loaded.mp3
pancake.audio.playFromIndex(0);
  • Saving variables
// Save score to localStorage variable "score"
pancake.storage.save("score", Number(0));

// Load it,It gives score value which is 0
var score = Number(pancake.storage.load("score"));
  • Physics + Game Loop
var playercolor = pancake.graphics.RGB(0, 0, 255);

// Use a HTML <canvas> tags that has ID "canvas"
// And set index of the context that will use it to 0
pancake.context.use(document.getElementById("canvas"), 0);

// Create 2 rectangles objects
var rect1 = { x: 100, y: 100, w: 50, h: 50 };
var rect2 = { x: 125, y: 125, w: 50, h: 50 };

function game() {
    // Clear canvas
    pancake.graphics.clear();

    // Draw first rectangle
    pancake.graphics.color(playercolor);
    pancake.graphics.rect(rect1.x, rect1.y, rect1.w, rect1.h);
    
    // Draw second rectangle
    pancake.graphics.color(pancake.graphics.RGB(0, 255, 0));
    pancake.graphics.rect(rect2.x, rect2.y, rect2.w, rect2.h);

    // Check collision between both 2 rectangles
    // If true then change color of first rectangle
    // Else then reset it's color to the default color
    if (pancake.physics.checkCollisionRecs(rect1.x, rect1.y, rect1.w, rect1.h, rect2.x, rect2.y, rect2.w, rect2.h)) {
        playercolor = pancake.graphics.RGB(255, 0, 0);
    } else {
        playercolor = pancake.graphics.RGB(0, 0, 255);
    }   
}

var gameloop = pancake.timers.timer(game, 60); // Set frames per second to 60
  • Keyboard + Game Loop
function game() {
    // If key down
    if (pancake.input.keydown(pancake.input.key.X)) alert("Key down/press");

    // If key up
    if (pancake.input.keyup(pancake.input.key.C)) alert("Key up");

    // Needed to prevent input loop
    pancake.input.preventLoop();
}

var gameloop = pancake.timers.timer(game, 60); // Set frames per second to 60

NOTE: More examples can be found in the Examples folder

Build

Build using Python:

mkdir pancake
cd pancake
git clone https://github.com/Rabios/Pancake.git
python build.py

A folder named build will created (if not exist) in the repository folders, Containing pancake.js, Which is the full build.

For more info about building Pancake see here.

License

MIT License

Copyright (c) 2020 - 2022 Rabia Alhaffar

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

More Repositories

1

awesome-raylib

Curated list of awesome stuff for raylib.
494
star
2

ice_libs

Collection of cross-platform single-header C libraries for doing a lot of stuff! (Still WIP)
C
127
star
3

raylua

Cross-Platform, Modern, And updated LuaJIT bindings for raylib library.
Lua
75
star
4

rayutils

Single-Header library that extends raylib with some functionality!
C
32
star
5

c99-game-template

C99 Template for writing games, Made with love and passion!
C
27
star
6

dragonblocks

Blockly for DragonRuby!
JavaScript
21
star
7

raylib-v7

JavaScript 5.1 bindings for raylib powered by cesanta's v7 JavaScript engine!
C
21
star
8

rayport

Awesome C99, Header-Only, rayfork wrapper for raylib!
C
21
star
9

Pancake.hx

Haxe port of awesome HTML5 game framework Pancake!
Haxe
16
star
10

cherry

Super LuaJIT package manager for everyone!
Lua
16
star
11

nelua-fun

Things i made for Nelua on my own!
Lua
15
star
12

Rabios

All about me
14
star
13

sigil-bindings

Bindings of SIGIL library for Boo, Lua, Nim, FreePascal, and FreeBASIC!
Nim
11
star
14

Tyrius

My experiment of creating 3D FPS game in C with raylib,Still prototype but playable
C
10
star
15

BLACKVOID

Roguelike shooter tower-defense-like game with hardcore gameplay mechanics!
Ruby
9
star
16

rabios.github.io

My official website!
HTML
9
star
17

lovr-joystick

Joystick and Gamepad input module for LÖVR
Lua
9
star
18

drtouch

Touch input library written in Ruby for DragonRuby GTK!
Ruby
8
star
19

CLua

Most of Lua functions implementation via C code using LuaJIT's FFI and pure Lua code.
Lua
8
star
20

LINES

Very hard game about avoiding a lot of moving lines,Written in C using raylib library
C
8
star
21

OpenSenet

Open-Source Senet board game written in Ruby via DragonRuby GTK!
Ruby
8
star
22

Lancelot

Open-Source Game Launcher written in Ruby via DragonRuby GTK
Ruby
7
star
23

blockly-nelua

Blockly that generates Nelua!
JavaScript
7
star
24

bouncing-dvd-logo-raylib

Port of "Bouncing DVD Logo" from a DragonRuby GTK gist, Using raylib with C99!
Makefile
6
star
25

rayfork-games

Full port of raylib sample games to rayfork!
C
6
star
26

cakestack

Simple cake stacking game done in Ruby via DragonRuby GTK!
Ruby
6
star
27

polyfill.lua

Polyfills for Lua and LuaJIT in one file!
Lua
6
star
28

raylib-boo

Single-file Boo bindings for raylib!
Boo
6
star
29

luckpaint

Hybrid 8x8 pixel art painting game made for Juicy Jam #1
Ruby
5
star
30

drkbd

On-Screen Keyboard for DragonRuby!
Ruby
5
star
31

lovr-clipboard

Clipboard module for LÖVR
Lua
5
star
32

nelua-samples

Collection of samples written in Nelua on my own...
Lua
5
star
33

drext

C Extensions i made for DragonRuby!
C
5
star
34

sigil_loader

Loader for SIGIL library to use with C for no compilation hassle!
C
5
star
35

nelua-pi

Formulas/Algorithms for calculating "Digits of Pi" implemented in Nelua!
Lua
5
star
36

TARGET

Space shooter (Shump) game i tried to make in 4 days with raylib in Lua using my bindings raylua, With simple concepts like shooting and boss fights!
Lua
5
star
37

squids-docs

documentation for squids game engine!
4
star
38

webscreenconsole

My attempt to do a custom web console with JavaScript :)
JavaScript
4
star
39

polygl.js

Tiny 2D graphics rendering library!
JavaScript
4
star
40

cololinks-docs

Docs for my game COLOLINKS!
4
star
41

teenytiny-dragonruby-minigamejam-2021

Source code of Spikefall, My submission for TeenyTiny Game Jam 2021!
Ruby
4
star
42

AnasBraim.github.io

SCSS
3
star
43

CARRIER

Redistribution of LuaJIT libraries
Lua
3
star
44

6wrni-students-jam-1

Source code of 08-ROOMS game
Ruby
2
star
45

chailove-examples-collection

Awesome collection of ChaiLove examples, For everyone!
2
star
46

cherry-test

Test for the LuaJIT package manager cherry.
Lua
2
star
47

LINES-PORTS

Linux,Web and Mobile ports of LINES game.
2
star