Fixed the problem of malfunctioning gGlobalPos
This commit is contained in:
parent
7676ae4496
commit
9d278b430b
|
@ -6,14 +6,22 @@
|
|||
<link rel="stylesheet" type="text/css" href="style.css" />
|
||||
<script type="text/javascript" src="jquery-1.7.1.min.js"></script>
|
||||
<script type="text/javascript" src="infosoul.js"></script>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<h2>infosoul</h2>
|
||||
<p class="tagline">"Searching for yourself, drowning in information."</p>
|
||||
<p>A glorious game by Nils Norman Haukås, <a href="https://www.facebook.com/pages/Nils-Norman-Prinsen-av-Poesi/120118764730475">Prinsen av Poesi.</a> :)</p>
|
||||
<div id="gamediv">
|
||||
</div>
|
||||
<h2>debug</h2>
|
||||
<!--
|
||||
<div width="350px">
|
||||
<object height="81" width="350px"> <param name="movie" value="https://player.soundcloud.com/player.swf?url=http%3A%2F%2Fapi.soundcloud.com%2Ftracks%2F34424311&show_comments=false&auto_play=true&color=ff7700"></param> <param name="allowscriptaccess" value="always"></param> <embed allowscriptaccess="always" height="81" src="https://player.soundcloud.com/player.swf?url=http%3A%2F%2Fapi.soundcloud.com%2Ftracks%2F34424311&show_comments=false&auto_play=false&color=ff7700" type="application/x-shockwave-flash" width="100%"></embed> </object> <span><a href="http://soundcloud.com/fitn/escape-live-recording-dub-deep">Escape (Live recording - Dub & Deep techno ambient)</a> by <a href="http://soundcloud.com/fitn">Fingers In The Noise</a></span>
|
||||
</div>
|
||||
-->
|
||||
<div id="debug">
|
||||
<p>debug </p>
|
||||
<p id="keydebug">Key pressed: </p>
|
||||
<p id="standingon">Standing on: </p>
|
||||
<p id="foundme">Yay, or nay? </p>
|
||||
|
|
127
infosoul.coffee
127
infosoul.coffee
|
@ -1,21 +1,23 @@
|
|||
|
||||
globalBoard = ""
|
||||
globalMyPos = []
|
||||
globalMyPos[0] = 0
|
||||
globalMyPos[1] = 0
|
||||
globalMyPos[0] = 15
|
||||
globalMyPos[1] = 5
|
||||
|
||||
gGoalPos = []
|
||||
gGoalPos[0] = 14
|
||||
gGoalPos[0] = 0
|
||||
gGoalPos[1] = 0
|
||||
|
||||
godmode = false
|
||||
started = false
|
||||
dead = false
|
||||
|
||||
p1Texture = "me"
|
||||
goalTexture = "me"
|
||||
|
||||
createDisplayText = () ->
|
||||
tmp = "
|
||||
ButImustexpla*ntoyouhowallthismistakenideaofdenouncingpleasu" + "\n" + "
|
||||
ButImustexplaintoyouhowallthismistakenideaofdenouncingpleasu" + "\n" + "
|
||||
reandpraisingpainwasbornandIwillgiveyouacompleteaccountofthe" + "\n" + "
|
||||
system,andexpoundtheactualteachingsofthegreatexplorerofthetr" + "\n" + "
|
||||
uth,themasterbuilderofhumanhappiness.Noonerejects,dislikes,o" + "\n" + "
|
||||
|
@ -31,23 +33,23 @@ createDisplayText = () ->
|
|||
cesnoresultantplea.pleasurerationally.encounterconsequencest"
|
||||
tmp.toUpperCase()
|
||||
|
||||
createDisplayText = () ->
|
||||
createStartText = () ->
|
||||
tmp = "
|
||||
ButImustexpla*ntoyouhowallthismistakenideaofdenouncingpleasu" + "\n" + "
|
||||
ButImustexplaintoyouhowallthismistakenideaofdenouncingpleasu" + "\n" + "
|
||||
reandpraisingpainwasbornandIwillgiveyouacompleteaccountofthe" + "\n" + "
|
||||
system,andexpoundtheactualteachingsofthegreatexplorerofthetr" + "\n" + "
|
||||
uth,themasterbuilderofhumanhappiness.Noonerejects,dislikes,o" + "\n" + "
|
||||
ravoidspleasureitself,becauseitispleasure,butbecausethosewho" + "\n" + "
|
||||
donotknowhowtopursuepleasurerationallyencounterconsequencest" + "\n" + "
|
||||
hatareextremelypainful.Noragainisthereanyonewholovesorpursue" + "\n" + "
|
||||
sordesirestoobtainpainofitself,becauseitispain,butbecauseocc" + "\n" + "
|
||||
asionallycircumstancesoccurinwhichtoilandpaincanprocurehimso" + "\n" + "
|
||||
syst________________________achingsofthegreatexplorerofthetr" + "\n" + "
|
||||
uth,__use the arrowkeys_____appiness.Noonerejects,dislikes,o" + "\n" + "
|
||||
ravo________________________eitispleasure,butbecausethosewho" + "\n" + "
|
||||
dono__find yourself_________rationallyencounterconsequencest" + "\n" + "
|
||||
hata________________________ainisthereanyonewholovesorpursue" + "\n" + "
|
||||
sord__press 1 to start______lf,becauseitispain,butbecauseocc" + "\n" + "
|
||||
asio________________________nwhichtoilandpaincanprocurehimso" + "\n" + "
|
||||
megreatpleasure.Totakeatrivialexample,whichofuseverundertake" + "\n" + "
|
||||
slaboriousphysicalexercise,excepttoobtainsomeadvantagefromit" + "\n" + "
|
||||
Butwhohasanyrighttofindfaultwithamanwhochoosestoenjoyapleasu" + "\n" + "
|
||||
rethathasnoannoyingconsequences,oronewhoavoidsapainthatprodu" + "\n" + "
|
||||
cesnoresultantplea.pleasurerationally.encounterconsequencest"
|
||||
tmp.toUpperCase()
|
||||
tmp.toLowerCase()
|
||||
|
||||
createWinPicture = () ->
|
||||
tmp = "
|
||||
|
@ -70,11 +72,11 @@ createLosePicture = () ->
|
|||
tmp = "
|
||||
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" + "\n" + "
|
||||
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" + "\n" + "
|
||||
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" + "\n" + "
|
||||
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" + "\n" + "
|
||||
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" + "\n" + "
|
||||
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" + "\n" + "
|
||||
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" + "\n" + "
|
||||
XXXX________________________XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" + "\n" + "
|
||||
XXXX__Lost in interwebs x_X XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" + "\n" + "
|
||||
XXXX________________________XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" + "\n" + "
|
||||
XXXX__Press 1 to restart____XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" + "\n" + "
|
||||
XXXX________________________XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" + "\n" + "
|
||||
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" + "\n" + "
|
||||
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" + "\n" + "
|
||||
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" + "\n" + "
|
||||
|
@ -85,6 +87,7 @@ createLosePicture = () ->
|
|||
|
||||
makeWinState = () ->
|
||||
globalBoard = createWinPicture()
|
||||
godmode = true
|
||||
p1Texture = "ME"
|
||||
goalTexture = "__"
|
||||
gGoalPos[0] = 0
|
||||
|
@ -96,7 +99,9 @@ makeLoseState = () ->
|
|||
globalBoard = createLosePicture()
|
||||
p1Texture = "XX"
|
||||
goalTexture = "XX"
|
||||
drawBoard(globalBoard,389)
|
||||
dead = true
|
||||
started = false
|
||||
drawBoard(globalBoard,440)
|
||||
|
||||
checkWin = () ->
|
||||
test1x = globalMyPos[0]
|
||||
|
@ -119,57 +124,82 @@ setMyPos = (x, y) ->
|
|||
drawBoard(globalBoard,newPos)
|
||||
|
||||
|
||||
drawBoard = (gbStr, strPos) ->
|
||||
drawBoard = (InpGbBoard, strPos) ->
|
||||
#Insert player
|
||||
leftStr = gbStr[0..strPos--]
|
||||
rightStr = gbStr[strPos+4..gbStr.length]
|
||||
leftStr = InpGbBoard[0..strPos--]
|
||||
rightStr = InpGbBoard[strPos+4..InpGbBoard.length]
|
||||
newBoard = leftStr +
|
||||
p1Texture + rightStr
|
||||
|
||||
#Insert goal
|
||||
leftStr = newBoard[0..gGoalPos[0]]
|
||||
rightStr = newBoard[gGoalPos[0]+3..newBoard.length]
|
||||
#Insert goal, but first make sure the goal is placed right.
|
||||
newGoalPos = gGoalPos[0] + gGoalPos[1]*62
|
||||
leftStr = newBoard[0..newGoalPos--]
|
||||
rightStr = newBoard[newGoalPos+4..newBoard.length]
|
||||
|
||||
newBoard = "<div id=\"gamediv\">" + leftStr +
|
||||
goalTexture + rightStr + "</div>"
|
||||
|
||||
$('#gamediv').replaceWith(newBoard)
|
||||
|
||||
$(document).ready ->
|
||||
globalBoard = createDisplayText()
|
||||
setMyPos(globalMyPos[0],globalMyPos[1])
|
||||
tmpString = "<p id=\"winPos\">Where to I need to get to: " + gGoalPos[0] + ", " + gGoalPos[1] + "</p>"
|
||||
$('#winPos').replaceWith(tmpString)
|
||||
|
||||
#$('#gamediv').append(drawBoard(globalBoard, 5))
|
||||
#alert globalMyPos[0]
|
||||
init = () ->
|
||||
globalBoard = createStartText()
|
||||
godmode = false
|
||||
p1Texture = "me"
|
||||
goalTexture = "me"
|
||||
newBoard = "<div id=\"gamediv\">" + globalBoard + "</div>"
|
||||
$('#gamediv').replaceWith(newBoard)
|
||||
|
||||
|
||||
$(document).ready ->
|
||||
init()
|
||||
|
||||
|
||||
#up-right-down-left -> 38, 39, 40, 37
|
||||
document.onkeydown = (event)->
|
||||
switch event.keyCode
|
||||
when 37
|
||||
$('#keydebug').replaceWith("<p id=\"keydebug\">Key pressed: Left</p>")
|
||||
globalMyPos[0]--
|
||||
setMyPos(globalMyPos[0], globalMyPos[1])
|
||||
makeMonster()
|
||||
checkMonster()
|
||||
if started
|
||||
globalMyPos[0]--
|
||||
setMyPos(globalMyPos[0], globalMyPos[1])
|
||||
makeMonster()
|
||||
checkMonster()
|
||||
when 38
|
||||
$('#keydebug').replaceWith("<p id=\"keydebug\">Key pressed: Up</p>")
|
||||
globalMyPos[1]--
|
||||
setMyPos(globalMyPos[0], globalMyPos[1])
|
||||
makeMonster()
|
||||
checkMonster()
|
||||
if started
|
||||
globalMyPos[1]--
|
||||
setMyPos(globalMyPos[0], globalMyPos[1])
|
||||
makeMonster()
|
||||
checkMonster()
|
||||
when 39
|
||||
$('#keydebug').replaceWith("<p id=\"keydebug\">Key pressed: Right</p>")
|
||||
globalMyPos[0]++
|
||||
setMyPos(globalMyPos[0], globalMyPos[1])
|
||||
makeMonster()
|
||||
checkMonster()
|
||||
if started
|
||||
globalMyPos[0]++
|
||||
setMyPos(globalMyPos[0], globalMyPos[1])
|
||||
makeMonster()
|
||||
checkMonster()
|
||||
when 40
|
||||
$('#keydebug').replaceWith("<p id=\"keydebug\">Key pressed: Down</p>")
|
||||
globalMyPos[1]++
|
||||
setMyPos(globalMyPos[0], globalMyPos[1])
|
||||
makeMonster()
|
||||
checkMonster()
|
||||
if started
|
||||
globalMyPos[1]++
|
||||
setMyPos(globalMyPos[0], globalMyPos[1])
|
||||
makeMonster()
|
||||
checkMonster()
|
||||
when 49
|
||||
if dead
|
||||
init()
|
||||
dead = false
|
||||
started = false
|
||||
if not started
|
||||
started = true
|
||||
globalBoard = createDisplayText()
|
||||
|
||||
gGoalPos[0] = Math.floor(Math.random() * 50)
|
||||
gGoalPos[1] = Math.floor(Math.random() * 11)
|
||||
|
||||
setMyPos(globalMyPos[0], globalMyPos[1])
|
||||
|
||||
makeMonster = () ->
|
||||
#Randomly place monster on map
|
||||
|
@ -192,4 +222,5 @@ checkMonster =() ->
|
|||
monster = "*"
|
||||
if underLeftFoot is monster or underRightFoot is monster
|
||||
if not godmode
|
||||
started = false
|
||||
makeLoseState()
|
||||
|
|
117
infosoul.js
117
infosoul.js
|
@ -1,32 +1,42 @@
|
|||
(function() {
|
||||
var checkMonster, checkWin, createDisplayText, createLosePicture, createWinPicture, drawBoard, gGoalPos, globalBoard, globalMyPos, goalTexture, godmode, makeLoseState, makeMonster, makeWinState, p1Texture, setMyPos;
|
||||
var checkMonster, checkWin, createDisplayText, createLosePicture, createStartText, createWinPicture, dead, drawBoard, gGoalPos, globalBoard, globalMyPos, goalTexture, godmode, init, makeLoseState, makeMonster, makeWinState, p1Texture, setMyPos, started;
|
||||
|
||||
globalBoard = "";
|
||||
|
||||
globalMyPos = [];
|
||||
|
||||
globalMyPos[0] = 0;
|
||||
globalMyPos[0] = 15;
|
||||
|
||||
globalMyPos[1] = 0;
|
||||
globalMyPos[1] = 5;
|
||||
|
||||
gGoalPos = [];
|
||||
|
||||
gGoalPos[0] = 14;
|
||||
gGoalPos[0] = 0;
|
||||
|
||||
gGoalPos[1] = 0;
|
||||
|
||||
godmode = false;
|
||||
|
||||
started = false;
|
||||
|
||||
dead = false;
|
||||
|
||||
p1Texture = "me";
|
||||
|
||||
goalTexture = "me";
|
||||
|
||||
createDisplayText = function() {
|
||||
var tmp;
|
||||
tmp = " ButImustexpla*ntoyouhowallthismistakenideaofdenouncingpleasu" + "\n" + " reandpraisingpainwasbornandIwillgiveyouacompleteaccountofthe" + "\n" + " system,andexpoundtheactualteachingsofthegreatexplorerofthetr" + "\n" + " uth,themasterbuilderofhumanhappiness.Noonerejects,dislikes,o" + "\n" + " ravoidspleasureitself,becauseitispleasure,butbecausethosewho" + "\n" + " donotknowhowtopursuepleasurerationallyencounterconsequencest" + "\n" + " hatareextremelypainful.Noragainisthereanyonewholovesorpursue" + "\n" + " sordesirestoobtainpainofitself,becauseitispain,butbecauseocc" + "\n" + " asionallycircumstancesoccurinwhichtoilandpaincanprocurehimso" + "\n" + " megreatpleasure.Totakeatrivialexample,whichofuseverundertake" + "\n" + " slaboriousphysicalexercise,excepttoobtainsomeadvantagefromit" + "\n" + " Butwhohasanyrighttofindfaultwithamanwhochoosestoenjoyapleasu" + "\n" + " rethathasnoannoyingconsequences,oronewhoavoidsapainthatprodu" + "\n" + " cesnoresultantplea.pleasurerationally.encounterconsequencest";
|
||||
tmp = " ButImustexplaintoyouhowallthismistakenideaofdenouncingpleasu" + "\n" + " reandpraisingpainwasbornandIwillgiveyouacompleteaccountofthe" + "\n" + " system,andexpoundtheactualteachingsofthegreatexplorerofthetr" + "\n" + " uth,themasterbuilderofhumanhappiness.Noonerejects,dislikes,o" + "\n" + " ravoidspleasureitself,becauseitispleasure,butbecausethosewho" + "\n" + " donotknowhowtopursuepleasurerationallyencounterconsequencest" + "\n" + " hatareextremelypainful.Noragainisthereanyonewholovesorpursue" + "\n" + " sordesirestoobtainpainofitself,becauseitispain,butbecauseocc" + "\n" + " asionallycircumstancesoccurinwhichtoilandpaincanprocurehimso" + "\n" + " megreatpleasure.Totakeatrivialexample,whichofuseverundertake" + "\n" + " slaboriousphysicalexercise,excepttoobtainsomeadvantagefromit" + "\n" + " Butwhohasanyrighttofindfaultwithamanwhochoosestoenjoyapleasu" + "\n" + " rethathasnoannoyingconsequences,oronewhoavoidsapainthatprodu" + "\n" + " cesnoresultantplea.pleasurerationally.encounterconsequencest";
|
||||
return tmp.toUpperCase();
|
||||
};
|
||||
|
||||
createStartText = function() {
|
||||
var tmp;
|
||||
tmp = " ButImustexplaintoyouhowallthismistakenideaofdenouncingpleasu" + "\n" + " reandpraisingpainwasbornandIwillgiveyouacompleteaccountofthe" + "\n" + " syst________________________achingsofthegreatexplorerofthetr" + "\n" + " uth,__use the arrowkeys_____appiness.Noonerejects,dislikes,o" + "\n" + " ravo________________________eitispleasure,butbecausethosewho" + "\n" + " dono__find yourself_________rationallyencounterconsequencest" + "\n" + " hata________________________ainisthereanyonewholovesorpursue" + "\n" + " sord__press 1 to start______lf,becauseitispain,butbecauseocc" + "\n" + " asio________________________nwhichtoilandpaincanprocurehimso" + "\n" + " megreatpleasure.Totakeatrivialexample,whichofuseverundertake" + "\n" + " slaboriousphysicalexercise,excepttoobtainsomeadvantagefromit" + "\n" + " Butwhohasanyrighttofindfaultwithamanwhochoosestoenjoyapleasu" + "\n" + " rethathasnoannoyingconsequences,oronewhoavoidsapainthatprodu" + "\n" + " cesnoresultantplea.pleasurerationally.encounterconsequencest";
|
||||
return tmp.toLowerCase();
|
||||
};
|
||||
|
||||
createWinPicture = function() {
|
||||
var tmp;
|
||||
tmp = " ____________________________________________________________" + "\n" + " ____________________________________________________________" + "\n" + " __Congratulations___________________________________________" + "\n" + " ____________________________________________________________" + "\n" + " __You Won!__________________________________________________" + "\n" + " ____________________________________________________________" + "\n" + " __Thank you for playing,____________________________________" + "\n" + " ____________________________________________________________" + "\n" + " ____________________________________________________________" + "\n" + " ____________________________________________________________" + "\n" + " ____________________________________________________________" + "\n" + " __________________________________________nils@thunki.com___" + "\n" + " ____________________________________________________________";
|
||||
|
@ -35,12 +45,13 @@
|
|||
|
||||
createLosePicture = function() {
|
||||
var tmp;
|
||||
tmp = " XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" + "\n" + " XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" + "\n" + " XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" + "\n" + " XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" + "\n" + " XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" + "\n" + " XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" + "\n" + " XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" + "\n" + " XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" + "\n" + " XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" + "\n" + " XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" + "\n" + " XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" + "\n" + " XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" + "\n" + " XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
|
||||
tmp = " XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" + "\n" + " XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" + "\n" + " XXXX________________________XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" + "\n" + " XXXX__Lost in interwebs x_X XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" + "\n" + " XXXX________________________XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" + "\n" + " XXXX__Press 1 to restart____XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" + "\n" + " XXXX________________________XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" + "\n" + " XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" + "\n" + " XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" + "\n" + " XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" + "\n" + " XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" + "\n" + " XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" + "\n" + " XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
|
||||
return tmp;
|
||||
};
|
||||
|
||||
makeWinState = function() {
|
||||
globalBoard = createWinPicture();
|
||||
godmode = true;
|
||||
p1Texture = "ME";
|
||||
goalTexture = "__";
|
||||
gGoalPos[0] = 0;
|
||||
|
@ -52,7 +63,9 @@
|
|||
globalBoard = createLosePicture();
|
||||
p1Texture = "XX";
|
||||
goalTexture = "XX";
|
||||
return drawBoard(globalBoard, 389);
|
||||
dead = true;
|
||||
started = false;
|
||||
return drawBoard(globalBoard, 440);
|
||||
};
|
||||
|
||||
checkWin = function() {
|
||||
|
@ -75,48 +88,85 @@
|
|||
return drawBoard(globalBoard, newPos);
|
||||
};
|
||||
|
||||
drawBoard = function(gbStr, strPos) {
|
||||
var leftStr, newBoard, rightStr;
|
||||
leftStr = gbStr.slice(0, strPos-- + 1 || 9e9);
|
||||
rightStr = gbStr.slice(strPos + 4, gbStr.length + 1 || 9e9);
|
||||
drawBoard = function(InpGbBoard, strPos) {
|
||||
var leftStr, newBoard, newGoalPos, rightStr, tmpString;
|
||||
leftStr = InpGbBoard.slice(0, strPos-- + 1 || 9e9);
|
||||
rightStr = InpGbBoard.slice(strPos + 4, InpGbBoard.length + 1 || 9e9);
|
||||
newBoard = leftStr + p1Texture + rightStr;
|
||||
leftStr = newBoard.slice(0, gGoalPos[0] + 1 || 9e9);
|
||||
rightStr = newBoard.slice(gGoalPos[0] + 3, newBoard.length + 1 || 9e9);
|
||||
newGoalPos = gGoalPos[0] + gGoalPos[1] * 62;
|
||||
leftStr = newBoard.slice(0, newGoalPos-- + 1 || 9e9);
|
||||
rightStr = newBoard.slice(newGoalPos + 4, newBoard.length + 1 || 9e9);
|
||||
newBoard = "<div id=\"gamediv\">" + leftStr + goalTexture + rightStr + "</div>";
|
||||
$('#gamediv').replaceWith(newBoard);
|
||||
tmpString = "<p id=\"winPos\">Where to I need to get to: " + gGoalPos[0] + ", " + gGoalPos[1] + "</p>";
|
||||
return $('#winPos').replaceWith(tmpString);
|
||||
};
|
||||
|
||||
init = function() {
|
||||
var newBoard;
|
||||
globalBoard = createStartText();
|
||||
godmode = false;
|
||||
p1Texture = "me";
|
||||
goalTexture = "me";
|
||||
newBoard = "<div id=\"gamediv\">" + globalBoard + "</div>";
|
||||
return $('#gamediv').replaceWith(newBoard);
|
||||
};
|
||||
|
||||
$(document).ready(function() {
|
||||
globalBoard = createDisplayText();
|
||||
return setMyPos(globalMyPos[0], globalMyPos[1]);
|
||||
return init();
|
||||
});
|
||||
|
||||
document.onkeydown = function(event) {
|
||||
switch (event.keyCode) {
|
||||
case 37:
|
||||
$('#keydebug').replaceWith("<p id=\"keydebug\">Key pressed: Left</p>");
|
||||
globalMyPos[0]--;
|
||||
setMyPos(globalMyPos[0], globalMyPos[1]);
|
||||
makeMonster();
|
||||
return checkMonster();
|
||||
if (started) {
|
||||
globalMyPos[0]--;
|
||||
setMyPos(globalMyPos[0], globalMyPos[1]);
|
||||
makeMonster();
|
||||
return checkMonster();
|
||||
}
|
||||
break;
|
||||
case 38:
|
||||
$('#keydebug').replaceWith("<p id=\"keydebug\">Key pressed: Up</p>");
|
||||
globalMyPos[1]--;
|
||||
setMyPos(globalMyPos[0], globalMyPos[1]);
|
||||
makeMonster();
|
||||
return checkMonster();
|
||||
if (started) {
|
||||
globalMyPos[1]--;
|
||||
setMyPos(globalMyPos[0], globalMyPos[1]);
|
||||
makeMonster();
|
||||
return checkMonster();
|
||||
}
|
||||
break;
|
||||
case 39:
|
||||
$('#keydebug').replaceWith("<p id=\"keydebug\">Key pressed: Right</p>");
|
||||
globalMyPos[0]++;
|
||||
setMyPos(globalMyPos[0], globalMyPos[1]);
|
||||
makeMonster();
|
||||
return checkMonster();
|
||||
if (started) {
|
||||
globalMyPos[0]++;
|
||||
setMyPos(globalMyPos[0], globalMyPos[1]);
|
||||
makeMonster();
|
||||
return checkMonster();
|
||||
}
|
||||
break;
|
||||
case 40:
|
||||
$('#keydebug').replaceWith("<p id=\"keydebug\">Key pressed: Down</p>");
|
||||
globalMyPos[1]++;
|
||||
setMyPos(globalMyPos[0], globalMyPos[1]);
|
||||
makeMonster();
|
||||
return checkMonster();
|
||||
if (started) {
|
||||
globalMyPos[1]++;
|
||||
setMyPos(globalMyPos[0], globalMyPos[1]);
|
||||
makeMonster();
|
||||
return checkMonster();
|
||||
}
|
||||
break;
|
||||
case 49:
|
||||
if (dead) {
|
||||
init();
|
||||
dead = false;
|
||||
started = false;
|
||||
}
|
||||
if (!started) {
|
||||
started = true;
|
||||
globalBoard = createDisplayText();
|
||||
gGoalPos[0] = Math.floor(Math.random() * 50);
|
||||
gGoalPos[1] = Math.floor(Math.random() * 11);
|
||||
return setMyPos(globalMyPos[0], globalMyPos[1]);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -135,7 +185,10 @@
|
|||
underRightFoot = globalBoard.slice(meLoc + 2, (meLoc + 2) + 1 || 9e9);
|
||||
monster = "*";
|
||||
if (underLeftFoot === monster || underRightFoot === monster) {
|
||||
if (!godmode) return makeLoseState();
|
||||
if (!godmode) {
|
||||
started = false;
|
||||
return makeLoseState();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Binary file not shown.
|
@ -22,10 +22,12 @@ h2 {
|
|||
max-width: 610px;
|
||||
background: #949494;
|
||||
padding: 22px 15px 18px 15px;
|
||||
/*
|
||||
font: 15px/14px 'VerilySerifMonoBook', Arial, sans-serif;letter-spacing: 3px;
|
||||
*/
|
||||
font-family: 'VerilySerifMonoBook',monospace;
|
||||
font-size: 1em;
|
||||
margin-bottom: 18px;
|
||||
}
|
||||
|
||||
#debug {
|
||||
/*visibility: hidden;*/
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue