Skip to content

abagames/consomaton-game-lib

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

consomaton-game-lib

Write a game with rules for a cellular automaton.

Rules are the same as rules of the programming puzzle game consomaton but slightly changed.

screenshot

Write your own game

  1. Open this jsbin.

  2. Write rules in the JavaScript window.

  3. If you want to publish the game, clone your own copy (File -> Clone) and Share.

How to write rules

See the sample source code.

play FALL V

source code

Without comment

rules: `
===
v
   v

===r10-s1
.  .
   v
===p>
@   @
---p<
 @ @
===n@-o
`,

With comments

rules: `
===       // each rule starts (is separated) with '==='
/// rules change a pattern (3 x 3 characters) in a console
v         // pattern: 'v  ' -> changes into '   '
   v      //          '   '                 'v  '
          //          '   '                 '   '
/// the rule can have commands that are classified in 3 types
///  condition: condition to fire a rule
///   (r)andom, (i)nterval, (p)ad, (e)xists, (n)ot exists, (c)ount
///  event: event occurs when a rule is fired
///   (s)core, game (o)ver, sound e(f)fect
///  rule: generate additional rules
///   (d)irection, (k)eep
///
/// commands are separated with '-'
/// the command can have multiple arguments separated with ','
===r10-s1 // with a probability of 1/10 (r10), add 1 score (s1) and
.  .      // '.' spawns 'v'
   v
===p>     // if a right button of a pad is pressed (p>)
@   @     // '@' moves right 
/// '---' rule separator means that below rules are not fired
/// when any above rule fires already
---p<     // if a left button of a pad is pressed (p<)
 @ @      // '@' moves left
===n@-o   // if there is no '@' (n@) on the console, game is over (o) 
`,

Rules with sound effects

Sound effects are generated with sounds-some-sounds

play FALL V with effects

source code

/// 'f'(sound effect) command's params are equal to 
/// the play function of 'sounds-some-sounds'
/// https://github.com/abagames/sounds-some-sounds
===
v
   v
===r10-s1-fl1 // play a 'l1' sound effect (fl1) when the rule is fired
.  .
   v
===p>-fs1     // play a 's1' sound effect (fs1)
@   @
---p<-fs1     // play the sound effect same as above
 @ @
===n@-fu1,5-o // play 5 'u1' sound effects at the same time
`,

Pixel arts

Pixel arts are generated with pixel-art-gen.

// pixel arts are generated with 'pixel-art-gen'
// https://github.com/abagames/pixel-art-gen

// default options for the generate function
pixel_art_options: { scale: 2, isMirrorX: true },

// generate pixel arts for a each character
pixel_art: {
// pixel art for '@'
'@': `
 x
xx
 x
x
`,
// pixel art for 'v'
'v': `
x
x
 x
 x
`,
// pixel art for '.'
'.': `
 x
 x
x
`,
},

// random seed for generating sound effects and pixel arts
seed: 0,

// 'dev: true' enables the development mode that
// shows the button to change the seed randomly.
// find the proper seed, fill it to the above and erase 'dev: true'
dev: true,

Other commands

play REF ARROW

source code

/// 'd'(direction) command creates the rotating patterns
/// (d[rotating count],[rotating characters],[pad inputs condition])
///  [rotating count] rotate '4' directions (90 degrees) or 
///                   '2' directions (180 degrees) (default: 4)
///  [rotating characters] these characters in a pattern are rotated
///  [pad inputs condition] add 'p' command to each rule
===d,>v<^-fh1
>. <.
/// the above rule are expanded in below 4 rules
/// ===
/// >. <.
/// ---
/// v  ^
/// .  .
/// ---
/// .< .>
/// ---
/// .  .
/// ^  v
===d,>v<^
>   >
/// each expanded rule has 'p' command, p>, pv, p< and p^
===d,>v<^,>v<^-s-fl1
@   @>
===n@-fu1,5-o

play PROPAG

source code

===d-s-fc1
@B @
===d-s-fc1
@b @
/// 'k'(keep) command means the characters in the first arg are
/// not affected by the rules until the next '===' separators
===d2,Bb-k@ 
B   B
===i2
*
   *
/// the rule with the 'i'(interval) command is fired at
/// a specific frame (first arg) intervals
===i2-k@
B
   B
===i2-k@
b
   b
===d,>v<^-r40-k.
*  **
===r30-d2,Bb-fl1
*  *B
===r50-fs1
.  .
   *
===d,>v<^,>v<^-k*
@   @
===n@-fu1,5-o

play GGLIFE

source code

===d,,>v<^-s-fs1
@  .@
/// 'c'(count) command represents a condition that is fired when
/// a specific number (first arg) of a specific character (second arg)
/// exists on a before pattern 
===c3,o

 @  o
...c3,o // '...' separator means these rules are applied simultaneously

 .  o
...c2,o

 o  o
...c3,o

 o  o
...
o  .
===no-r500-k@-fh1
   ooo
===d-r1000-k@-fh2
   o
===n@-fu1,5-o

Other examples

play CROSSMAN ( source code )

play BARR ( source code )

play FALL V JUMP ( source code )

License

MIT

About

cellular automaton based game development library

Resources

Stars

Watchers

Forks

Packages

No packages published