-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathmain.require.js
More file actions
90 lines (81 loc) · 3.4 KB
/
main.require.js
File metadata and controls
90 lines (81 loc) · 3.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
const PartCamera = require('./src/Camera')
const PartDestroy = require('./src/Destroy')
const PartDraw = require('./src/Draw')
const PartFps = require('./src/Fps')
const PartFullscreen = require('./src/Fullscreen')
const PartInputKeyboard = require('./src/InputKeyboard')
const PartInputMouse = require('./src/InputMouse')
const PartInputTouch = require('./src/InputTouch')
const PartLoader = require('./src/Loader')
const PartLoop = require('./src/Loop')
const PartMath = require('./src/Math')
const PartNetwork = require('./src/Network')
const PartObject = require('./src/Object')
const PartRoom = require('./src/Room')
const PartScripts = require('./src/Scripts')
const PartSetup = require('./src/Setup')
const PartSound = require('./src/Sound')
const PartSprite = require('./src/Sprite')
const PartSurface = require('./src/Surface')
const PartStorage = require('./src/Storage')
const PartTimer = require('./src/Timer')
const PartVector = require('./src/Vector')
module.exports = class cs {
constructor(options) {
this.options = options
// handy
this.clone = (object) => { return JSON.parse(JSON.stringify(object)) }
this.default = (want, ifnot) => { return want === undefined ? ifnot : want }
// 1. setup
this.cs = this
this.canvas = options.canvas
this.ctx = this.canvas.getContext('2d')
this.path = options.path
this.maxSize = options.maxSize || 2000
this.start = options.start
this.userStep = options.step
this.userDraw = options.draw
this.userEndDraw = options.endDraw
this.progress = options.progress || function () {}
this.focus = options.focus || function () {}
this.version = options.version || Math.random()
this.global = options.global || {}
this.progress = options.progress || function () {}
this.focus = options.focus || function () {}
this.objects = options.objects || {}
this.script = options.scripts || {}
this.sprites = options.sprites || []
this.storages = options.storages || []
this.sounds = options.sounds || []
this.assets = {
scripts: options.assets && options.assets.scripts ? options.assets.scripts : [],
sprites: options.assets && options.assets.sprites ? options.assets.sprites : [],
storages: options.assets && options.assets.storages ? options.assets.storages : [],
sounds: options.assets && options.assets.sounds ? options.assets.sounds : [],
}
this.camera = new PartCamera(this)
this.destroy = PartDestroy
this.draw = new PartDraw(this)
this.fps = new PartFps(this)
this.fullscreen = new PartFullscreen(this)
this.inputKeyboard = new PartInputKeyboard(this)
this.inputMouse = new PartInputMouse(this)
this.inputTouch = new PartInputTouch(this)
this.loader = new PartLoader(this)
this.loop = new PartLoop(this)
this.math = new PartMath(this)
this.network = new PartNetwork(this)
this.object = new PartObject(this)
this.room = new PartRoom(this)
this.scripts = new PartScripts(this)
this.setup = new PartSetup(this)
this.sound = new PartSound(this)
this.sprite = new PartSprite(this)
this.storage = new PartStorage(this)
this.surface = new PartSurface(this)
this.timer = new PartTimer(this)
this.vector = new PartVector(this)
// load
this.loader.load() // loader will call cs.start()
}
}