Skip to content
This repository has been archived by the owner on Mar 3, 2024. It is now read-only.

Commit

Permalink
adding a textbuffer, this makes drawing text to the screen way faster
Browse files Browse the repository at this point in the history
  • Loading branch information
ericoporto committed Oct 29, 2016
1 parent 2a65cc9 commit d03e867
Show file tree
Hide file tree
Showing 7 changed files with 125 additions and 143 deletions.
6 changes: 3 additions & 3 deletions src/engine.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ engine.menuSetup = function() {
action: 'exit',
index: 3
}
});
},null, false, null, 2);
menus.setParent(engine.mapMenu);
}

Expand Down Expand Up @@ -871,7 +871,7 @@ player.setup = function() {
if (charFacing) {
if (eventInChar(charFacing, [1, 0], [py - 1, px])) {
HID.inputs["accept"].active = false
engine.waitTime(400);
engine.waitTime(300);
} else {
player.waits = 16
}
Expand All @@ -880,7 +880,7 @@ player.setup = function() {
var fpos = player.facingPosition()
if (eventInMap(engine.currentLevel["Level"], [1, 0], fpos)) {
HID.inputs["accept"].active = false
engine.waitTime(400);
engine.waitTime(300);
}
}

Expand Down
Binary file modified src/img/printer.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
<script type="text/javascript" src="feedback.js"></script>
<script type="text/javascript" src="engine.js"></script>
<script type="text/javascript" src="actions.js"></script>
<script type="text/javascript" src="textbuffer.js"></script>
<script type="text/javascript" src="screen.js"></script>
<script type="text/javascript" src="hid.js"></script>
<script type="text/javascript" src="pngfont.js"></script>
Expand Down
19 changes: 10 additions & 9 deletions src/menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,17 +62,18 @@ var menus = {
}
};

function menu(_items, _index, _noexit, _icon) {
function menu(_items, _index, _noexit, _icon, _scale) {

var tempArray = [];

_index = (typeof _index === "undefined") ? null : _index;
_icon = (typeof _icon === "undefined") ? null : _icon;
_noexit = (typeof _noexit === "undefined") ? false : _noexit;
_icon = (typeof _icon === "undefined") ? null : _icon;
_scale = (typeof _scale === "undefined") ? 2 : _scale;
this.items = _items;
this.noexit = _noexit;

this.menuScale = 1;
this.menuScale = _scale;
this.maxOnScreen = 5;
this.parent = null;
this.index = _index;
Expand Down Expand Up @@ -150,7 +151,7 @@ function menu(_items, _index, _noexit, _icon) {

if (this.parent != null) {
this.parent.wait = false;
this.parent.menuKeyWasPressed = 32
this.parent.menuKeyWasPressed = 16
} else {
engine.atomStack.push(engine.atomStack.push([function() {
engine.atomStack = menus.holdAtomStack
Expand Down Expand Up @@ -179,7 +180,7 @@ function menu(_items, _index, _noexit, _icon) {
this.selectedItem = this.items[this.selectedItem.previous]
this.selectedItem.selected = true
HID.inputs["up"].active = false
this.menuKeyWasPressed = 32
this.menuKeyWasPressed = 16
} else if (HID.inputs["left"].active) {


Expand All @@ -191,7 +192,7 @@ function menu(_items, _index, _noexit, _icon) {
this.selectedItem = this.items[this.selectedItem.next]
this.selectedItem.selected = true
HID.inputs["down"].active = false
this.menuKeyWasPressed = 32
this.menuKeyWasPressed = 16
} else if (HID.inputs["accept"].active) {

HID.inputs["accept"].active = false
Expand All @@ -217,17 +218,17 @@ function menu(_items, _index, _noexit, _icon) {
if (typeof this.selectedItem.isMenu === "undefined") {
this.selectedItem.action();
} else {
this.selectedItem.menuKeyWasPressed = 32
this.selectedItem.menuKeyWasPressed = 16
this.selectedItem.action();
}
}
this.menuKeyWasPressed = 32
this.menuKeyWasPressed = 16
} else if (HID.inputs["cancel"].active) {
if (this._counter >= 20 && this.noexit == false) {
HID.inputs["cancel"].active = false
this.exit()
engine.waitTime(200)
this.menuKeyWasPressed = 32
this.menuKeyWasPressed = 16
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/printer.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ printer.showText = function(_text) {
for (var nboxes = 0; nboxes < total_boxes; nboxes++) {
engine.atomStack.unshift([function() {
printer.nextBox();
engine.waitTime(400);
engine.waitTime(300);
}, '']);
engine.atomStack.unshift(["block", null]);
engine.atomStack.unshift([engine.waitForKey, true]);
Expand Down
Loading

0 comments on commit d03e867

Please sign in to comment.