define(function (require) { 'use strict'; var utils = require('utils'); var Point = require('Point'); var GameObject = require('GameObject'); function MovingObject(image, position, color, direction) { GameObject.apply(this, arguments); this.direction = direction; } utils.inherit(MovingObject, GameObject); MovingObject.prototype.update = function () { this.position = Point.add(this.position, this.direction); }; MovingObject.prototype.respondToCollision = function (data) { if (data.force.row * this.direction.row < 0) { this.direction = new Point(-1 * this.direction.row, this.direction.col); } if (data.force.col * this.direction.col < 0) { this.direction = new Point(this.direction.row, -1 * this.direction.col); } }; return MovingObject; })
'use strict'; var Node = require( '../node' ), utils = require( 'utils' ); function ImageNode() { Node.apply( this, arguments ); } utils.inherit( ImageNode, Node ); ImageNode.name = 'image'; ImageNode.matchTags = [ 'img' ]; ImageNode.isEmpty = true; utils.extend( ImageNode.prototype, { toData: function( dom ) { return { insert: 1, attributes: { type: ImageNode.name, src: dom.src } }; }, toDom: function( data, doc ) { var dom = doc.createElement( 'img' ); dom.src = data.attributes.src;
'use strict'; var Branch = require( '../branch' ), utils = require( 'utils' ); function ListNode() { Branch.apply( this, arguments ); } utils.inherit( ListNode, Branch ); ListNode.name = 'list'; ListNode.matchTags = [ 'ul', 'ol' ]; utils.extend( ListNode.prototype, { toData: function( dom ) { return { insert: 1, attributes: { type: ListNode.name, style: dom.nodeName.toLowerCase() == 'ol' ? 'number' : 'bullet' } }; }, toDom: function( data, doc ) { return doc.createElement( data.attributes.style === 'number' ? 'ol' : 'ul' ); } } ); module.exports = ListNode;