aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--README.md5
-rw-r--r--desktop/core/library.js2
-rw-r--r--desktop/core/library/_door.js28
-rw-r--r--desktop/core/library/x.js4
-rw-r--r--desktop/core/orca.js21
-rw-r--r--desktop/main.js2
-rw-r--r--desktop/sources/index.html10
-rw-r--r--desktop/sources/scripts/cursor.js33
-rw-r--r--desktop/sources/scripts/history.js12
-rw-r--r--desktop/sources/scripts/keyboard.js2
-rw-r--r--desktop/sources/scripts/source.js64
-rw-r--r--desktop/sources/scripts/terminal.js118
-rw-r--r--examples/projects/room.orca37
-rw-r--r--server.js2
14 files changed, 234 insertions, 106 deletions
diff --git a/README.md b/README.md
index c84c40a..3437fa8 100644
--- a/README.md
+++ b/README.md
@@ -52,7 +52,6 @@ You can follow the [guide](GUIDE.md) to get started and play your first sounds.
- `*` **bang**: Bangs neighboring operators.
- `;` **udp**('len): Sends a string via UDP to localhost.
- `:` **midi**('velocity, 'length, channel, octave, note): Sends Midi a midi note.
-- `!` **keys**(key): Bangs on keyboard input.
- `#` **comment**: Comments a line, or characters until the next hash.
## Controls
@@ -111,10 +110,6 @@ Note length is a value from `1`(1/16) to `g`(16/16), which is a ratio of a full
The [UDP](https://nodejs.org/api/dgram.html#dgram_socket_send_msg_offset_length_port_address_callback) operator `;`, takes one haste input that is a string length and locks the eastwardly ports. It sends the message on bang to the port `49160`. You can use the [listener.js](https://github.com/hundredrabbits/Orca/blob/master/listener.js) to test UDP messages. See it in action with [udp.orca](https://github.com/hundredrabbits/Orca/blob/master/examples/_udp.orca).
-### Keyboard Input
-
-The keys operator `!` will bang on a corresponding keyboard keypress when the cursor is in **keyboard mode**(toggle with `/`). For instance, `!a`, will output a bang when pressing the `a` key in **keyboard mode**. See it in action with the [keys.orca](https://github.com/hundredrabbits/Orca/blob/master/examples/_keys.orca).
-
<img src='https://raw.githubusercontent.com/hundredrabbits/Orca/master/resources/preview.hardware.jpg' width="600"/>
## Base36 Table
diff --git a/desktop/core/library.js b/desktop/core/library.js
index 7ff7670..fd8d9d3 100644
--- a/desktop/core/library.js
+++ b/desktop/core/library.js
@@ -41,5 +41,5 @@ module.exports = {
'#': require('./library/_comment'),
';': require('./library/_udp'),
':': require('./library/_midi'),
- '!': require('./library/_keys')
+ '/': require('./library/_door')
}
diff --git a/desktop/core/library/_door.js b/desktop/core/library/_door.js
new file mode 100644
index 0000000..108acc2
--- /dev/null
+++ b/desktop/core/library/_door.js
@@ -0,0 +1,28 @@
+'use strict'
+
+const Operator = require('../operator')
+
+function OperatorDoor (orca, x, y, passive) {
+ Operator.call(this, orca, x, y, '/', true)
+
+ this.name = 'door'
+ this.info = 'Hosts a nested Orca grid.'
+
+ this.ports.input.val = { x: 1, y: 0 }
+ this.ports.haste.id = { x: -1, y: 0 }
+ this.ports.output = { x: 0, y: 1 }
+
+ this.run = function () {
+ const id = this.listen(this.ports.haste.id)
+ if (!orca.terminal.rooms[id]) { return }
+
+ const val = this.listen(this.ports.input.val)
+ const room = orca.terminal.rooms[id]
+ room.input(val)
+ room.run()
+ const res = room.output()
+ this.output(`${res}`)
+ }
+}
+
+module.exports = OperatorDoor
diff --git a/desktop/core/library/x.js b/desktop/core/library/x.js
index 9449461..85d0171 100644
--- a/desktop/core/library/x.js
+++ b/desktop/core/library/x.js
@@ -14,8 +14,8 @@ function OperatorX (orca, x, y, passive) {
this.ports.output = { x: 0, y: 1, unlock: true }
this.haste = function () {
- const x = clamp(this.listen(this.ports.haste.x, true), 0, 24)
- const y = clamp(this.listen(this.ports.haste.y, true), 1, 24)
+ const x = clamp(this.listen(this.ports.haste.x, true), 0, 32)
+ const y = clamp(this.listen(this.ports.haste.y, true), 1, 32)
this.ports.output = { x: x, y: y, unlock: true }
}
diff --git a/desktop/core/orca.js b/desktop/core/orca.js
index f55cdd3..e2076e6 100644
--- a/desktop/core/orca.js
+++ b/desktop/core/orca.js
@@ -1,12 +1,14 @@
'use strict'
-function Orca (library = {}) {
+const library = require('./library')
+
+function Orca (terminal) {
this.w = 65 // Default Width
this.h = 25 // Default Height
this.s = '' // String
this.f = 0 // Frame
- this.terminal = null
+ this.terminal = terminal
this.keys = Object.keys(library)
this.locks = []
this.ports = {}
@@ -18,7 +20,9 @@ function Orca (library = {}) {
this.f += 1
}
- this.reset = function () {
+ this.reset = function (w = this.w, h = this.h) {
+ this.w = w
+ this.h = h
this.s = new Array((this.h * this.w) + 1).join('.')
}
@@ -27,6 +31,7 @@ function Orca (library = {}) {
this.h = h
this.f = f
this.s = this.clean(s)
+ return this
}
this.write = function (x, y, g) {
@@ -103,6 +108,16 @@ function Orca (library = {}) {
this.locks.push(`${x}:${y}`)
}
+ // IO
+
+ this.input = function (g) {
+ this.write(0, 0, g)
+ }
+
+ this.output = function () {
+ return this.s.charAt(this.s.length - 1)
+ }
+
// Helpers
this.inBounds = function (x, y) {
diff --git a/desktop/main.js b/desktop/main.js
index f9d234b..28c6d8d 100644
--- a/desktop/main.js
+++ b/desktop/main.js
@@ -22,7 +22,7 @@ app.on('ready', () => {
})
app.win.loadURL(`file://${__dirname}/sources/index.html`)
- // app.inspect()
+ app.inspect()
app.win.on('closed', () => {
win = null
diff --git a/desktop/sources/index.html b/desktop/sources/index.html
index 9f33053..6e6f7fa 100644
--- a/desktop/sources/index.html
+++ b/desktop/sources/index.html
@@ -13,13 +13,8 @@
</head>
<body>
<script>
- const Orca = require('../core/orca')
- const library = require('../core/library')
const Terminal = require('./scripts/terminal')
-
- const orca = new Orca(library)
- const terminal = new Terminal(orca)
-
+ const terminal = new Terminal()
const { app } = require('electron').remote
terminal.install(document.body)
@@ -36,7 +31,6 @@
terminal.controller.add("default","File","Save As",() => { terminal.source.save(true); },"CmdOrCtrl+Shift+S")
terminal.controller.add("default","File","Open",() => { terminal.source.open(); },"CmdOrCtrl+O")
terminal.controller.add("default","File","Revert",() => { terminal.source.revert(); },"CmdOrCtrl+Shift+R")
- terminal.controller.add("default","File","Close",() => { terminal.source.close(); },"CmdOrCtrl+W")
terminal.controller.add("default","Edit","Select All",() => { terminal.cursor.selectAll(); },"CmdOrCtrl+A")
terminal.controller.add("default","Edit","Erase Selection",() => { terminal.cursor.erase(); },"Backspace")
@@ -63,8 +57,6 @@
terminal.controller.add("default","View","Zoom Out",() => { terminal.modZoom(-0.25); },"CmdOrCtrl+-")
terminal.controller.add("default","View","Zoom Reset",() => { terminal.modZoom(1,true); },"CmdOrCtrl+0")
- terminal.controller.add("default","Keyboard","Toggle Play Mode",() => { terminal.cursor.toggleMode(2); },"/")
-
terminal.controller.add("default","Theme","Open Theme",() => { terminal.theme.open(); },"CmdOrCtrl+Shift+o")
terminal.controller.add("default","Theme","Reset Theme",() => { terminal.theme.reset(); },"CmdOrCtrl+Shift+Backspace")
terminal.controller.add("default","Theme","Download Themes..",() => { require('electron').shell.openExternal('https://github.com/hundredrabbits/Themes'); })
diff --git a/desktop/sources/scripts/cursor.js b/desktop/sources/scripts/cursor.js
index cb11a4c..30a0416 100644
--- a/desktop/sources/scripts/cursor.js
+++ b/desktop/sources/scripts/cursor.js
@@ -1,6 +1,6 @@
'use strict'
-function Cursor (orca, terminal) {
+function Cursor (terminal) {
this.x = 0
this.y = 0
this.w = 1
@@ -9,28 +9,30 @@ function Cursor (orca, terminal) {
this.block = []
this.move = function (x, y) {
- this.x = clamp(this.x + x, 0, orca.w - 1)
- this.y = clamp(this.y - y, 0, orca.h - 1)
+ this.x = clamp(this.x + x, 0, terminal.room.w - 1)
+ this.y = clamp(this.y - y, 0, terminal.room.h - 1)
terminal.update()
}
this.scale = function (x, y) {
- this.w = clamp(this.w + x, 1, orca.w - this.x)
- this.h = clamp(this.h - y, 1, orca.h - this.y)
+ this.w = clamp(this.w + x, 1, terminal.room.w - this.x)
+ this.h = clamp(this.h - y, 1, terminal.room.h - this.y)
terminal.update()
}
this.reset = function () {
+ this.move(0, 0)
this.w = 1
this.h = 1
this.mode = 0
+ terminal.enter()
}
this.selectAll = function () {
this.x = 0
this.y = 0
- this.w = orca.w
- this.h = orca.h
+ this.w = terminal.room.w
+ this.h = terminal.room.h
this.mode = 0
terminal.update()
}
@@ -53,7 +55,7 @@ function Cursor (orca, terminal) {
terminal.io.sendKey(event.key)
return
}
- orca.write(this.x, this.y, g)
+ terminal.room.write(this.x, this.y, g)
if (this.mode === 1) {
this.move(1, 0)
}
@@ -61,13 +63,16 @@ function Cursor (orca, terminal) {
}
this.erase = function () {
- if (this.w === 1 && this.h === 1 && orca.glyphAt(this.x, this.y) === '.') { this.move(-1, 0); return } // Backspace Effect
+ if (this.w === 1 && this.h === 1 && terminal.room.glyphAt(this.x, this.y) === '.') { this.move(-1, 0); return } // Backspace Effect
this.eraseBlock(this.x, this.y, this.w, this.h)
- this.reset()
terminal.history.record()
}
this.toggleMode = function (val) {
+ if (terminal.room.glyphAt(this.x, this.y) === '/') {
+ terminal.enter(terminal.room.s.charAt(terminal.room.indexAt(this.x, this.y) - 1))
+ return
+ }
this.mode = this.mode === 0 ? val : 0
}
@@ -75,7 +80,7 @@ function Cursor (orca, terminal) {
if (this.w > 1 || this.h > 1) { return 'multi' }
const port = terminal.portAt(this.x, this.y)
if (port) { return `${port.name}` }
- if (orca.lockAt(this.x, this.y)) { return 'locked' }
+ if (terminal.room.lockAt(this.x, this.y)) { return 'locked' }
return 'empty'
}
@@ -86,7 +91,7 @@ function Cursor (orca, terminal) {
for (let _y = rect.y; _y < rect.y + rect.h; _y++) {
const line = []
for (let _x = rect.x; _x < rect.x + rect.w; _x++) {
- line.push(orca.glyphAt(_x, _y))
+ line.push(terminal.room.glyphAt(_x, _y))
}
block.push(line)
}
@@ -99,7 +104,7 @@ function Cursor (orca, terminal) {
for (const lineId in block) {
let _x = rect.x
for (const glyphId in block[lineId]) {
- orca.write(_x, _y, block[lineId][glyphId])
+ terminal.room.write(_x, _y, block[lineId][glyphId])
_x++
}
_y++
@@ -110,7 +115,7 @@ function Cursor (orca, terminal) {
this.eraseBlock = function (x, y, w, h) {
for (let _y = y; _y < y + h; _y++) {
for (let _x = x; _x < x + w; _x++) {
- orca.write(_x, _y, '.')
+ terminal.room.write(_x, _y, '.')
}
}
terminal.history.record()
diff --git a/desktop/sources/scripts/history.js b/desktop/sources/scripts/history.js
index d88cfb6..f591cf8 100644
--- a/desktop/sources/scripts/history.js
+++ b/desktop/sources/scripts/history.js
@@ -1,6 +1,6 @@
'use strict'
-function History (orca, terminal) {
+function History (terminal, orca = terminal.room) {
this.index = 0
this.frames = []
@@ -16,13 +16,13 @@ function History (orca, terminal) {
this.undo = function () {
if (this.index === 0) { console.warn('History', 'Reached beginning'); return }
this.index = clamp(this.index - 1, 0, this.frames.lengt - 1)
- terminal.load(this.frames[this.index], orca.f)
+ terminal.load(this.frames[this.index], terminal.rooms.hall.f)
}
this.redo = function () {
if (this.index > this.frames.length - 1) { console.warn('History', 'Reached end'); return }
this.index = clamp(this.index + 1, 0, this.frames.lengt - 1)
- terminal.load(this.frames[this.index], orca.f)
+ terminal.load(this.frames[this.index], terminal.rooms.hall.f)
}
this.reset = function () {
@@ -31,12 +31,12 @@ function History (orca, terminal) {
}
this.append = function () {
- this.frames.push(`${orca}`)
+ // this.frames.push(`${orca}`)
}
this.fork = function () {
- this.frames = this.frames.slice(0, this.index + 1)
- this.frames.push(`${orca}`)
+ // this.frames = this.frames.slice(0, this.index + 1)
+ // this.frames.push(`${orca}`)
}
function clamp (v, min, max) { return v < min ? min : v > max ? max : v }
diff --git a/desktop/sources/scripts/keyboard.js b/desktop/sources/scripts/keyboard.js
index 9edae4e..94a84eb 100644
--- a/desktop/sources/scripts/keyboard.js
+++ b/desktop/sources/scripts/keyboard.js
@@ -1,6 +1,6 @@
'use strict'
-function Keyboard (orca, terminal) {
+function Keyboard (terminal) {
this.locks = []
this.history = ''
diff --git a/desktop/sources/scripts/source.js b/desktop/sources/scripts/source.js
index 9486b83..77a5ab1 100644
--- a/desktop/sources/scripts/source.js
+++ b/desktop/sources/scripts/source.js
@@ -1,6 +1,7 @@
'use strict'
-function Source (orca, terminal) {
+function Source (terminal) {
+ const Orca = require('../../core/orca')
const fs = require('fs')
const { dialog, app } = require('electron').remote
@@ -8,10 +9,12 @@ function Source (orca, terminal) {
this.new = function () {
console.log('New')
- orca.w = 65
- orca.h = 25
- orca.reset()
+
this.path = null
+
+ terminal.rooms = { hall: new Orca(terminal) }
+ terminal.room = terminal.rooms.hall
+ terminal.enter()
terminal.resize()
terminal.history.reset()
}
@@ -43,28 +46,63 @@ function Source (orca, terminal) {
this.read(this.path)
}
- this.close = function () {
- console.log('Close')
- orca.reset()
- this.path = null
- }
-
// I/O
this.write = function (path) {
- fs.writeFile(path, `${orca}`, (err) => {
+ fs.writeFile(path, this.generate(), (err) => {
if (err) { alert('An error ocurred updating the file' + err.message); console.log(err) }
})
}
this.read = function (path) {
- fs.readFile(path, 'utf8', function (err, data) {
+ fs.readFile(path, 'utf8', (err, data) => {
if (err) throw err
- terminal.load(data.trim())
+ const rooms = this.parse(data)
+ terminal.load(rooms)
terminal.history.record()
})
}
+ // Converters
+
+ this.generate = function (rooms = terminal.rooms) {
+ let html = `${rooms.hall}\n\n`
+ for (const id in rooms) {
+ if (id !== 'hall') {
+ const room = rooms[id]
+ html += `${id}\n\n${room}\n\n`
+ }
+ }
+ return html.trim()
+ }
+
+ this.parse = function (text) {
+ const lines = text.split('\n')
+ const blocks = { hall: [] }
+ const rooms = { hall: [] }
+ const room = []
+ let key = 'hall'
+ // Blocks
+ for (const id in lines) {
+ const line = lines[id].trim()
+ if (line.length === 0) { continue }
+ if (line.length === 1) { key = line; continue }
+ if (!blocks[key]) { blocks[key] = [] }
+ blocks[key].push(line)
+ }
+ // Rooms
+ for (const id in blocks) {
+ const block = blocks[id]
+ const w = block[0].length
+ const h = block.length
+ const s = block.join('\n').trim()
+ rooms[id] = new Orca(terminal).load(w, h, s)
+ }
+ return rooms
+ }
+
+ // Etc
+
this.name = function () {
const parts = this.path.split('/')
return parts[parts.length - 1].replace('.orca', '').trim()
diff --git a/desktop/sources/scripts/terminal.js b/desktop/sources/scripts/terminal.js
index 810708a..9f9c089 100644
--- a/desktop/sources/scripts/terminal.js
+++ b/desktop/sources/scripts/terminal.js
@@ -1,17 +1,20 @@
'use strict'
-function Terminal (orca, tile = { w: 20, h: 30 }) {
+function Terminal (tile = { w: 20, h: 30 }) {
+ const Orca = require('../../core/orca')
const Cursor = require('./cursor')
const Source = require('./source')
const History = require('./history')
const Keyboard = require('./keyboard')
const IO = require('./io')
+ this.library = require('../../core/library')
+
this.io = new IO(this)
- this.cursor = new Cursor(orca, this)
- this.source = new Source(orca, this)
- this.history = new History(orca, this)
- this.keyboard = new Keyboard(orca, this)
+ this.cursor = new Cursor(this)
+ this.source = new Source(this)
+ this.history = new History(this)
+ this.keyboard = new Keyboard(this)
this.controller = new Controller()
// Themes
@@ -22,23 +25,23 @@ function Terminal (orca, tile = { w: 20, h: 30 }) {
this.el = document.createElement('canvas')
this.context = this.el.getContext('2d')
- this.size = { width: tile.w * orca.w, height: tile.h * orca.h + (tile.h * 3), ratio: 0.5, grid: { w: 8, h: 8 } }
+ this.size = { width: 0, height: 0, ratio: 0.5, grid: { w: 8, h: 8 } }
this.isPaused = false
this.timer = null
this.bpm = 120
this.install = function (host) {
- this.resize()
host.appendChild(this.el)
this.theme.install(host)
- orca.terminal = this
}
this.start = function () {
this.theme.start()
this.io.start()
+ this.source.new()
this.history.record()
this.setSpeed(120)
+ this.resize()
this.update()
this.el.className = 'ready'
}
@@ -46,7 +49,7 @@ function Terminal (orca, tile = { w: 20, h: 30 }) {
this.run = function () {
if (this.isPaused) { return }
this.io.clear()
- orca.run()
+ this.rooms.hall.run()
this.io.run()
this.update()
}
@@ -57,16 +60,10 @@ function Terminal (orca, tile = { w: 20, h: 30 }) {
this.update()
}
- this.load = function (data, frame = 0) {
- if (!data) { return }
- const w = data.split('\n')[0].length
- const h = data.split('\n').length
- if (w < 10 || h < 10) { console.warn('Too small'); return }
- if (w > 121 || h > 49) { console.warn('Too large'); return }
- console.log(`Loading ${w}x${h}`)
- orca.load(w, h, data, frame)
- this.resize()
- this.update()
+ this.load = function (rooms, frame = 0) {
+ console.log(rooms)
+ this.rooms = rooms
+ this.enter()
}
this.crop = function () {
@@ -87,6 +84,25 @@ function Terminal (orca, tile = { w: 20, h: 30 }) {
this.theme.reset()
}
+ this.create = function (id) {
+ console.log(`Creating Room:${id}`)
+ this.rooms[id] = new Orca(this)
+ this.rooms[id].reset(33, 17)
+ }
+
+ this.enter = function (id = 'hall') {
+ if (!this.rooms[id]) {
+ this.create(id)
+ }
+
+ console.log(`Enterting Room:${id}`)
+
+ this.room = this.rooms[id]
+ this.room.id = id
+ this.resize(false)
+ this.update()
+ }
+
//
this.setSpeed = function (bpm) {
@@ -105,18 +121,18 @@ function Terminal (orca, tile = { w: 20, h: 30 }) {
this.setSize = function (w, h) {
let block = `${orca}`
- if (h > orca.h) {
- block = `${block}${`\n${'.'.repeat(orca.w)}`.repeat((h - orca.h))}`
- } else if (h < orca.h) {
- block = `${block}`.split('\n').slice(0, (h - orca.h)).join('\n').trim()
+ if (h > this.room.h) {
+ block = `${block}${`\n${'.'.repeat(this.room.w)}`.repeat((h - this.room.h))}`
+ } else if (h < this.room.h) {
+ block = `${block}`.split('\n').slice(0, (h - this.room.h)).join('\n').trim()
}
- if (w > orca.w) {
- block = `${block}`.split('\n').map((val) => { return val + ('.').repeat((w - orca.w)) }).join('\n').trim()
- } else if (w < orca.w) {
- block = `${block}`.split('\n').map((val) => { return val.substr(0, val.length + (w - orca.w)) }).join('\n').trim()
+ if (w > this.room.w) {
+ block = `${block}`.split('\n').map((val) => { return val + ('.').repeat((w - this.room.w)) }).join('\n').trim()
+ } else if (w < this.room.w) {
+ block = `${block}`.split('\n').map((val) => { return val.substr(0, val.length + (w - this.room.w)) }).join('\n').trim()
}
- this.load(block, orca.f)
+ this.load(block, this.room.f)
}
this.modSpeed = function (mod = 0) {
@@ -130,8 +146,8 @@ function Terminal (orca, tile = { w: 20, h: 30 }) {
}
this.modSize = function (x = 0, y = 0) {
- const w = ((parseInt(orca.w / this.size.grid.w) + x) * this.size.grid.w) + 1
- const h = ((parseInt(orca.h / this.size.grid.h) + y) * this.size.grid.h) + 1
+ const w = ((parseInt(this.room.w / this.size.grid.w) + x) * this.size.grid.w) + 1
+ const h = ((parseInt(this.room.h / this.size.grid.h) + y) * this.size.grid.h) + 1
this.setSize(w, h)
}
@@ -157,9 +173,9 @@ function Terminal (orca, tile = { w: 20, h: 30 }) {
this.findPorts = function () {
const h = {}
- for (const id in orca.runtime) {
- const g = orca.runtime[id]
- if (orca.lockAt(g.x, g.y)) { continue }
+ for (const id in this.room.runtime) {
+ const g = this.room.runtime[id]
+ if (this.room.lockAt(g.x, g.y)) { continue }
// Default/Passive
if (!h[`${g.x}:${g.y}`]) {
h[`${g.x}:${g.y}`] = { type: g.passive && g.draw ? 'passive' : 'none', name: `${g.name}` }
@@ -187,17 +203,17 @@ function Terminal (orca, tile = { w: 20, h: 30 }) {
}
this.guide = function (x, y) {
- const g = orca.glyphAt(x, y)
+ const g = this.room.glyphAt(x, y)
if (g !== '.') { return g }
if (x % this.size.grid.w === 0 && y % this.size.grid.h === 0) { return '+' }
return g
}
this.drawProgram = function () {
- for (let y = 0; y < orca.h; y++) {
- for (let x = 0; x < orca.w; x++) {
+ for (let y = 0; y < this.room.h; y++) {
+ for (let x = 0; x < this.room.w; x++) {
const port = this.ports[`${x}:${y}`]
- const styles = { isSelection: this.isSelection(x, y), isCursor: this.isCursor(x, y), isPort: port ? port.type : false, isLocked: orca.lockAt(x, y) }
+ const styles = { isSelection: this.isSelection(x, y), isCursor: this.isCursor(x, y), isPort: port ? port.type : false, isLocked: this.room.lockAt(x, y) }
this.drawSprite(x, y, this.guide(x, y), styles)
}
}
@@ -209,12 +225,12 @@ function Terminal (orca, tile = { w: 20, h: 30 }) {
this.write(`${this.cursor.x},${this.cursor.y}`, col * 0, 1, this.size.grid.w)
this.write(`${this.cursor.w}:${this.cursor.h}`, col * 1, 1, this.size.grid.w)
this.write(`${this.cursor.inspect()}`, col * 2, 1, this.size.grid.w)
- this.write(`${this.source}${this.cursor.mode === 2 ? '^' : this.cursor.mode === 1 ? '+' : ''}`, col * 3, 1, this.size.grid.w)
+ this.write(`${this.source}${this.cursor.mode === 2 ? '^' : this.cursor.mode === 1 ? '+' : ''}${this.room.id && this.room.id !== 'hall' ? '/' + this.room.id : ''}`, col * 3, 1, this.size.grid.w)
// Grid
- this.write(`${orca.w}x${orca.h}`, col * 0, 0, this.size.grid.w)
+ this.write(`${this.room.w}x${this.room.h}`, col * 0, 0, this.size.grid.w)
this.write(`${this.size.grid.w}/${this.size.grid.h}`, col * 1, 0, this.size.grid.w)
- this.write(`${orca.f}f${this.isPaused ? '*' : ''}`, col * 2, 0, this.size.grid.w)
- this.write(`${this.bpm}${orca.f % 4 === 0 ? '*' : ''}`, col * 3, 0, this.size.grid.w)
+ this.write(`${this.room.f}f${this.isPaused ? '*' : ''}`, col * 2, 0, this.size.grid.w)
+ this.write(`${this.bpm}${this.room.f % 4 === 0 ? '*' : ''}`, col * 3, 0, this.size.grid.w)
this.write(`${this.io}`, col * 4, 0, this.size.grid.w)
}
@@ -261,7 +277,7 @@ function Terminal (orca, tile = { w: 20, h: 30 }) {
let x = 0
while (x < text.length && x < limit - 1) {
const c = text.substr(x, 1)
- this.drawSprite(offsetX + x, orca.h + offsetY, c, { f: 'f_high', b: 'background' })
+ this.drawSprite(offsetX + x, this.room.h + offsetY, c, { f: 'f_high', b: 'background' })
x += 1
}
}
@@ -270,21 +286,23 @@ function Terminal (orca, tile = { w: 20, h: 30 }) {
this.el.style.marginTop = (((window.innerHeight - (terminal.size.height * terminal.size.ratio)) / 2) - 20) + 'px'
}
- this.resize = function () {
- this.size.width = tile.w * orca.w
- this.size.height = tile.h * orca.h + (tile.h * 3)
+ this.resize = function (resizeWindow = true) {
+ this.size.width = tile.w * this.room.w
+ this.size.height = tile.h * this.room.h + (tile.h * 3)
this.el.width = this.size.width
this.el.height = this.size.height + tile.h
this.el.style.width = (this.size.width * this.size.ratio) + 'px'
this.el.style.height = (this.size.height * this.size.ratio) + 'px'
this.align()
- const { remote } = require('electron')
- const win = remote.getCurrentWindow()
- const width = parseInt((this.size.width * this.size.ratio) + 60)
- const height = parseInt((this.size.height * this.size.ratio) + 30)
- win.setSize(width, height, true)
+ if (resizeWindow === true) {
+ const { remote } = require('electron')
+ const win = remote.getCurrentWindow()
+ const width = parseInt((this.size.width * this.size.ratio) + 60)
+ const height = parseInt((this.size.height * this.size.ratio) + 30)
+ win.setSize(width, height, true)
+ }
}
function clamp (v, min, max) { return v < min ? min : v > max ? max : v }
diff --git a/examples/projects/room.orca b/examples/projects/room.orca
new file mode 100644
index 0000000..cfb7156
--- /dev/null
+++ b/examples/projects/room.orca
@@ -0,0 +1,37 @@
+.........................................
+.#.MAIN.#................................
+.........................................
+..1/.....................................
+.........................................
+..2/.....................................
+.........................................
+.........................................
+.........................................
+.........................................
+.........................................
+.........................................
+.........................................
+
+1
+
+....................
+.#.HALLWAY.#........
+....................
+....................
+....................
+....................
+....................
+....................
+....................
+
+2
+
+....................
+.#.CAVE.#...........
+....................
+....................
+....................
+....................
+....................
+....................
+....................
diff --git a/server.js b/server.js
index ff94290..5b42261 100644
--- a/server.js
+++ b/server.js
@@ -9,7 +9,7 @@ function run (data,frames) {
const Orca = require('./desktop/core/orca')
const library = require('./desktop/core/library')
- const orca = new Orca(library)
+ const orca = new Orca(terminal)
const w = data.split('\n')[0].length
const h = data.split('\n').length