• Stars
    star
    310
  • Rank 134,379 (Top 3 %)
  • Language
    TypeScript
  • License
    MIT License
  • Created almost 5 years ago
  • Updated over 1 year ago

Reviews

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

Repository Details

Minimal JavaScript library for creating classic arcade-like mini-games running in the browser

crisp-game-lib

English | ๆ—ฅๆœฌ่ชž

crisp-game-lib is a JavaScript library for creating browser games quickly and easily.

Sample games and sample codes

Sample games are listed on my browser games page. Click Play to play the game in your browser (PC or mobile).

Sample code for each game is main.js in each directory in the crisp-game-lib-games/docs directory.

Getting started

  1. Download docs/getting_started/index.html.

  2. Open index.html in a text editor and write the code of your game in the <script> element.

  3. Open index.html in a browser and play the game.

  4. You can publish the game by putting index.html on your web server.

Write your own game (with the help of IntelliSense and Live Reload)

  1. Clone or download this repository.

  2. npm install

  3. Copy the docs/_template directory and rename it to docs/[your own game name].

  4. Open docs/[your own game name]/main.js with the editor (VSCode is recommended) and write your own game code.

  5. npm run watch_games

  6. Open the URL http://localhost:4000?[your own game name] with a browser to play the game. The page is live-reloaded when the code is rewritten.

Publish your own game

  1. Place main.js, docs/bundle.js, and docs/index.html on the webserver in the following directory structure.

    โ” [games root directory (any name)]
       โ” [your own game name]
       โ”‚  โ”” main.js
       โ” bundle.js
       โ”” index.html
    
  2. Open the URL [Address of games root directory]/index.html?[your own game name] with a browser.

Use with a bundler

If you want to build a game using a bundler (e.g. Vite), do the following.

  1. npm install crisp-game-lib at your project directory.

  2. Copy docs/_template_bundler/index.html and docs/_template_bundler/main.js to your project directory.

  3. Write game code in main.js.

  4. Build with the bundler.

If you want to describe the game using TypeScript, rename main.js to main.ts.

Function introduction demo

ref_drawing screenshot

ref_collision screenshot

Related articles

Tips

  • By drawing with color("transparent"), you can get the result of collision detection without drawing any shape on the screen.
  • The collision detection is based on the drawing history of the shape. Therefore, even if a drawn shape is overwritten with a background-colored shape, the collision detection in that area will not disappear.
  • The base value for the random seed for sound generation is generated from the title and description strings. If you want to use seed in options to adjust the generated sound, it is better to do so after the title and description are fixed.
  • To improve the performance of the game, do the following (mainly for mobile devices):
    • Use simple or dark theme. Do not specify a theme that uses pixi.js (pixel, shape, shapeDark, crt) in options. WebGL post-effects may worsen performance.
    • Minimize drawing bars, lines, or arcs. They are drawn as a combination of many rectangles and are highly detrimental to the collision detection process.
  • If you want to create a game that can be played comfortably on a mobile device, I recommend that you adopt one of the following three control methods.
    • One-button
    • Slide operation left or right direction only
    • Tapping on a specific place on the screen
  • For more information on how to create a one-button game, please refer to the following article I wrote: How to realize various actions in a one-button game
  • The sounds-some-sounds library can be used to play music. To play music written in MML, use the sss.playMml() function.
  • If you want to run crisp-game-lib games on small devices such as M5Stack or Adafruit PyBadge, you can use the C implementation version crisp-game-lib-portable.

More Repositories

1

mgl

Mgl is a mini game programming library written in Haxe + OpenFL.
Haxe
96
star
2

PixelArtGen

A pixel art generator on a Unity custom inspector
C#
75
star
3

pongpector

Play a pong on a Unity custom inspector
C#
69
star
4

rrootage

Defeat autocreated huge battleships
C++
54
star
5

stgldemo

STGL (ShooTing Game Language) demo
Haxe
52
star
6

sarad

write a program only by a simple click
JavaScript
49
star
7

mgl.coffee

MGL.COFFEE is a mini game programming library written in CoffeeScript.
JavaScript
46
star
8

folmura

Randomly generated visual with randomly generated formula
TypeScript
43
star
9

111-one-button-games-in-2021

I have created 111 one-button games in 2021
JavaScript
38
star
10

sort-war

Quick sort VS Insertion sort
TypeScript
35
star
11

wasm-game-by-hand

Write a WebAseembly game by hand
WebAssembly
28
star
12

z80-repl

Z80 CPU REPL environment
TypeScript
28
star
13

crisp-game-lib-portable

Minimal C-lang library for creating classic arcade-like mini-games running on devices and browsers
C
26
star
14

literate-diff-viewer

Show source code description with literate diff way
TypeScript
25
star
15

consomaton

cellular automaton based programming puzzle game
TypeScript
24
star
16

sounds-some-sounds

Add sounds to your game in a minute
TypeScript
22
star
17

gif-capture-canvas

Capture a canvas with an animated gif
JavaScript
19
star
18

various-actions-in-a-one-button-game

19
star
19

pixel-art-gen

Generete a pixel art from a simple pattern string
TypeScript
19
star
20

LocatePrint

display a console of an old home computer
TypeScript
18
star
21

kackac

Kac-kac games
TypeScript
16
star
22

lark-matter

Pixel art style matter.js renderer plugin
TypeScript
15
star
23

rj-10

Text tilemap based game development environment
TypeScript
15
star
24

bytebeatbank

sound generator by just dragging and dropping bytebeat cards
JavaScript
15
star
25

snake-shift

Lightning fast snake game
TypeScript
13
star
26

svg-path-collider

Test collision between svg paths
TypeScript
13
star
27

good-old-game-sound-generator

Generate sound effects and background music for good old-fashioned mini-games
TypeScript
12
star
28

petit-game-lib

Game development library for petit games
TypeScript
11
star
29

game-combinator

Combine games and generate a new one
TypeScript
10
star
30

moonrit

16 x 16 LED matrix games
TypeScript
8
star
31

games-2019

Games created by me in 2019
8
star
32

short-vgm-generator

Generate short video game music, automatically, endlessly.
TypeScript
8
star
33

crisp-game-lib-games

Games made with crisp-game-lib
6
star
34

jsgame256

Write a JavaScript game in 256 letters
TypeScript
6
star
35

pixel-perfect-collider

Pixel perfect collision detector
TypeScript
6
star
36

slickslack

Flick crates and slip them to a target
TypeScript
6
star
37

url-basic

Interpret the basic program in the url
JavaScript
5
star
38

games-web-pages

JavaScript
5
star
39

phaser_p2_threejs

sample code to use three.js with Phaser P2 physics
JavaScript
5
star
40

not-interactive

Generate a gamelike animated gif
TypeScript
5
star
41

GameMechRandomizer

Toward an infinite random awful action games generator
JavaScript
5
star
42

mgla3

Mgla3 is a mini game programming library written in Haxe, OpenFL and Away3D.
Haxe
4
star
43

tobitaro

Jump taro
TypeScript
4
star
44

rewinders

Rewind the game time
TypeScript
3
star
45

totsubefu

The test program of a Haxe macro of building types with the Befunge interpreter.
Haxe
3
star
46

particle-pattern-emitter

Emit particles with a generated pattern
TypeScript
3
star
47

instant-replay

Record and replay a gameplay
TypeScript
3
star
48

diffi-tween

Difficulty curve viewer
TypeScript
2
star
49

dqn-cross-road

Test program to make the DQN cross the road.
TypeScript
2
star
50

hakosan

Lead the three boxes to their destination
TypeScript
2
star
51

soniper

Sonic warehouse keeper
TypeScript
2
star
52

consomaton-game-lib

cellular automaton based game development library
JavaScript
2
star
53

one-button-for-all

One button games
TypeScript
2
star
54

BLCK4777_organized

Organized source code of the JavaScript demo BLCK4777
JavaScript
2
star
55

blockly-number-slider-field

Custom number field with 2d slider for Blockly
TypeScript
2
star
56

protospawn

game prototyping library powerd by the es2015 proxy and generator
JavaScript
2
star
57

crisp-game-lib-11-games

Games made with crisp-game-lib v1.1
2
star
58

pixel_sprite_generator_demo

demo code of pixel_sprite_generator
JavaScript
1
star
59

backto-scripttag

back to the good old script tag to write a JavaScript
JavaScript
1
star
60

zyoukuu

Fly over and under obstacles and get bonus items.
Haxe
1
star
61

mini-game-idea-generator

A simple tool to generate random ideas for mini-games
TypeScript
1
star
62

neurobo

DQN agent robots playground
TypeScript
1
star
63

rowcov

Experimental cross-platform game between Flash and HTML5 written in Haxe+NME, Away3D and three.js
JavaScript
1
star
64

sf-flying-curve

Generate flying curves of small enemies in a shoot'em up
TypeScript
1
star
65

chatgpt-p5-generative-art

Abstract and geometric animation pieces, utilizing the p5.js framework, generated with ChatGPT
JavaScript
1
star