This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { VerletModel } from '../../engine'; | |
export default class RockModel extends VerletModel { | |
constructor(minRadius=30, maxRadius=40, granularity=25) { | |
super(); | |
let tau = Math.PI*2; | |
let increment = tau / granularity; | |
let points = []; | |
let xMin; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Game, Scene, AssetsLoader } from '../engine'; | |
import Player from './objects/Player'; | |
import StarField from './objects/StarField'; | |
import Map from './objects/Map'; | |
import PlayerModel from './models/PlayerModel'; | |
require('../../scss/styles.scss'); | |
let assetsLoader = new AssetsLoader(); | |
let scene = new Scene(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import DisplayObject from './DisplayObject'; | |
export default class Particle extends DisplayObject { | |
constructor(radius=10, color='#fff') { | |
super(); | |
this.size = radius; | |
this.color = color; | |
this.width = this.height = radius*2; | |
} | |
render() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Scene, Particle, DisplayObject } from '../../engine'; | |
export default class StarField extends DisplayObject { | |
constructor(model, amount=90) { | |
super(); | |
this.model = model; | |
this.amount = amount; | |
this.starSize = 3; | |
this.stars = []; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { DisplayObject } from '../../engine'; | |
export default class Map extends DisplayObject { | |
constructor(markerSize=4, mapScaleFactor=0.2) { | |
super(); | |
this.markerSize = markerSize; | |
this.mapScaleFactor = mapScaleFactor; | |
} | |
update() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { VerletModel } from '../../engine'; | |
export default class PlayerModel extends VerletModel { | |
constructor() { | |
super(); | |
this.temporaryX = 0; | |
this.temporaryY = 0; | |
this.friction = 0; | |
this.frictionX = 0; | |
this.frictionY = 0; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Scene, DisplayObject, AssetsLoader, KeyboardEvents } from '../../engine'; | |
export default class Player extends DisplayObject { | |
constructor(model) { | |
super(); | |
let assets = new AssetsLoader().assets; | |
this.model = model; | |
this.assets = assets; | |
let onKeyUp = (e) => { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Scene from './Scene'; | |
const allowedActions = ['moveTo', 'lineTo']; | |
export default class DisplayObject extends Scene { | |
constructor(x=0, y=0) { /* */ } | |
add(elem) { /* */ } | |
draw(actions, coordinates) { | |
for(let a of actions.keys()) { | |
if(allowedActions[actions[a]]) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Game, Scene, SpriteSheet, AnimatedSprite, AssetsLoader } from '../engine'; | |
require('../../scss/styles.scss'); | |
let assetsLoader = new AssetsLoader(); | |
let scene = new Scene(); | |
let game = new Game(scene); | |
let sheets = {}; | |
let initGame = () => { | |
// create an AnimatedSprite using the Ryu sprite sheet |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import DisplayObject from './DisplayObject'; | |
export default class AnimatedSprite extends DisplayObject { | |
constructor(x, y, sheet, startFrame=0, endFrame=startFrame+1, loop=true, fps=30) { | |
super(x, y); | |
this.sheet = sheet; | |
this.sprites = sheet.sprites.slice(startFrame, endFrame); | |
this.loop = loop; | |
this.frameIdx = 0; | |
this.period = 1000 / fps; |