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

Commit

Permalink
Merge pull request #5 from ericoporto/betterText
Browse files Browse the repository at this point in the history
font switched to gnu unifont.
  • Loading branch information
ericoporto authored Oct 29, 2016
2 parents 2c57f55 + 2a76c8a commit beda7da
Show file tree
Hide file tree
Showing 16 changed files with 556 additions and 324 deletions.
3 changes: 1 addition & 2 deletions make.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ parse_dom () {
else
echo "$FULLCONTENT"
fi


elif [[ $TAG_NAME != "" ]] ; then
echo "$FULLCONTENT"
Expand All @@ -64,5 +64,4 @@ mv "$minindexhtml" "$indexhtml"
cp -r "$gamefolder/img" .
cp -r "$gamefolder/descriptors" .
cp -r "$gamefolder/audio" .
cp -r "$gamefolder/font" .
cp "$gamefolder/icon.png" .
10 changes: 0 additions & 10 deletions src/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,16 +121,6 @@ actions.showText = function(param, position) {
var params = param.split(';')
var text = actions.helpers.preText(params[0]);
engine.atomStack.push([printer.showText, text]);
var linesTotal = printer.textLines(text);
var lineNumber;
for (lineNumber = 0; lineNumber < linesTotal; lineNumber += 2) {
engine.atomStack.push([engine.waitForKey, true]);
engine.atomStack.push(["block", null]);
engine.atomStack.push([function() {
printer.nextLine();
engine.waitTime(400);
}, '']);
}
};

actions.teleport = function(param, position) {
Expand Down
43 changes: 24 additions & 19 deletions src/bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,26 +34,31 @@ bootstrap.onLoadDOM = function(){
document.getElementsByTagName('canvas')[0].getContext('2d').fillStyle = '#FFFFFF';
document.getElementsByTagName('canvas')[0].getContext('2d').fillText("LOADING...", 64, 64)
resources.harvest(function(){
screen.init();
player.setup();
engine.setup();
screen.setEngine(engine);
HID.setup(screen)
engine.currentLevel = resources['levels'][resources.init['World']['initLevel']];
resources.tileset = resources.tile[engine.currentLevel.Level.tileImage]
screen.printBox.setup(resources.printerset);
feedbackEng.setup();
title.setup();
battle.setup();
menus.setAllDrawables();
engine.loop();
screen.requestAnimationFrame.call(window,function(){screen.loop()})
debug.FPS.loop();
chars = new charalist();
chars.push(player)
fullscreen.setup()
png_font.setup(
screen.ctx,
"img/unifont.png",
function(){
screen.init();
player.setup();
engine.setup();
screen.setEngine(engine);
HID.setup(screen)
engine.currentLevel = resources['levels'][resources.init['World']['initLevel']];
resources.tileset = resources.tile[engine.currentLevel.Level.tileImage]
screen.printBox.setup(resources.printerset);
feedbackEng.setup();
title.setup();
battle.setup();
menus.setAllDrawables();
engine.loop();
screen.requestAnimationFrame.call(window,function(){screen.loop()})
debug.FPS.loop();
chars = new charalist();
chars.push(player)
fullscreen.setup()
}
);
});

}catch (err){
alert("Error on bootstrap! "+err);
}
Expand Down
2 changes: 1 addition & 1 deletion src/descriptors/hms.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
{
"bunny":
{
"name":"VorpalBunny",
"name":"Vorpal Bunny",
"ExpToLevel":[2,0],
"baseStats" : {"hp":120, "st":100, "dx":120, "iq":10 },
"Pathway":{
Expand Down
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 removed src/font/INFO56_0.ttf
Binary file not shown.
Binary file removed src/font/asgard.ttf
Binary file not shown.
5 changes: 0 additions & 5 deletions src/game.css
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
@font-face {
font-family: 'INFO56';
src: url('font/INFO56_0.ttf');
}

body{
background-color: black;
padding: 0px;
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.
Binary file added src/img/unifont.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@
<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>
<script type="text/javascript" src="printer.js"></script>
<script type="text/javascript" src="title.js"></script>
<script type="text/javascript" src="dist.js"></script>
Expand Down
48 changes: 26 additions & 22 deletions src/menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,13 @@ var menus = {
if (menuToDraw.parent == null) {
menuToDraw['drawx'] = 16;
menuToDraw['drawy'] = 16;
menuToDraw['height'] = finalItem * 32 + 32;
menuToDraw['width'] = menuToDraw.maxItemStringSize() * 13 + 32;
menuToDraw['height'] = finalItem * menuToDraw.fontHeight + 32;
menuToDraw['width'] = menuToDraw.maxItemStringSize() + 32;
} else {
menuToDraw['drawx'] = menuToDraw.parent.drawx + menuToDraw.parent.width;
menuToDraw['drawy'] = menuToDraw.parent.drawy;
menuToDraw['height'] = finalItem * 32 + 32;
menuToDraw['width'] = menuToDraw.maxItemStringSize() * 13 + 32;
menuToDraw['height'] = finalItem * menuToDraw.fontHeight + 32;
menuToDraw['width'] = menuToDraw.maxItemStringSize() + 32;
}
},
setAllDrawables: function() {
Expand All @@ -62,23 +62,25 @@ 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.maxOnScreen = 5
this.parent = null
this.index = _index
this.icon = _icon
this.menuScale = _scale;
this.maxOnScreen = 5;
this.parent = null;
this.index = _index;
this.icon = _icon;
this.enabled = false;
this.selectedItem = null;
this.wait = false
this.wait = false;
this.isMenu = true;

this.updateOrder = function() {
Expand Down Expand Up @@ -118,19 +120,21 @@ function menu(_items, _index, _noexit, _icon) {

this.selectedItem.selected = true

}
};

this.updateOrder();

this.updateOrder()
this.fontHeight = png_font.getHeight(this.menuScale);

this.maxItemStringSize = function() {
var returnValue = 0

for (var i = 0; i < Object.keys(this.items).length; i++) {
var _itemKey = Object.keys(this.items)[i];
var _itemKeyLength = png_font.getTextWidth(_itemKey,this.menuScale)


if (returnValue < _itemKey.length) {
returnValue = _itemKey.length;
if (returnValue < _itemKeyLength) {
returnValue = _itemKeyLength;
}
}

Expand All @@ -147,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 @@ -176,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 @@ -188,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 @@ -214,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
Loading

0 comments on commit beda7da

Please sign in to comment.