Skip to content

Commit 8844321

Browse files
committed
restructure
1 parent f0d38bb commit 8844321

24 files changed

+897
-16
lines changed

index.html

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<html>
2+
<head>
3+
<title> Pokemon Ash Key</title>
4+
<style>
5+
body {
6+
background-color: rgb(218, 7, 7);
7+
font-family:Verdana,Arial;
8+
}
9+
#title {
10+
width: 250px;
11+
float:left;
12+
}
13+
#title h1 {
14+
text-align:center;
15+
}
16+
#main {
17+
display:block;
18+
display:relative;
19+
margin:auto;
20+
height: 90%;
21+
}
22+
#getInvolved {
23+
background-color:beige;
24+
border-radius:2px;
25+
padding:5px;
26+
}
27+
.clearfix {
28+
clear:both;
29+
}
30+
</style>
31+
<script src="https://code.jquery.com/jquery-2.1.4.min.js"></script>
32+
<script src="js/asciiRPG.js"></script>
33+
<script src="js/sample_world.js"></script>
34+
<script>
35+
var game;
36+
var playerString;
37+
38+
$(function(){
39+
40+
game = asciiRPG.load(document.getElementById("main"), pkmnASCII);
41+
game.run();
42+
});
43+
</script>
44+
</head>
45+
<body>
46+
<canvas id="main" width=1000 height=900></canvas>
47+
</body>
48+
</html>

html/asciiRPG.js js/asciiRPG.js

+36-16
Original file line numberDiff line numberDiff line change
@@ -537,18 +537,23 @@ Actor.prototype.move = function(direction, _countdown){
537537
};
538538

539539
Actor.prototype.handleInput = function(key){
540-
//basic WASD movement
540+
// basic WASD movement
541+
541542
switch(key){
542-
case 87: //up
543+
case 38: //up arrow
544+
case 87: //up 'w'
543545
this.move(UP);
544546
break;
545-
case 83: //down
547+
case 40: //down arrow
548+
case 83: //down 's'
546549
this.move(DOWN);
547550
break;
548-
case 65: //left
551+
case 37: //left arrow
552+
case 65: //left 'a'
549553
this.move(LEFT);
550554
break;
551-
case 68: //right
555+
case 39: //right arrow
556+
case 68: //right 'd'
552557
this.move(RIGHT);
553558
break;
554559
case KeyEvent.DOM_VK_E:
@@ -763,8 +768,10 @@ var HUD = function(world, game){
763768
this.displayQueue = [];
764769
this.message = "";
765770

766-
this.addMessage("Welcome to the ASCII world of Pokemon!!");
767-
this.addMessage("Everything is drawn with letters, numbers, and symbols.");
771+
this.addMessage("Welcome to the ASCII world of Pokemon!! (Press E to Continue)");
772+
this.addMessage("Everything is drawn with letters, numbers, and symbols.");
773+
this.addMessage("Use the arrow keys or WASD to move.");
774+
768775

769776
this.isUp = false;
770777
this.menu = new HUDMenu([
@@ -1017,23 +1024,31 @@ var keyPressers = {};
10171024

10181025
$(document).keydown(function(event){
10191026
switch(event.keyCode){
1020-
case 87: //up
1021-
case 83: //down
1022-
case 65: //left
1023-
case 68: //right
1027+
case 87: //up 'w'
1028+
case 38: //up arrow
1029+
case 83: //down 's'
1030+
case 40: //down arrow
1031+
case 65: //left 'a'
1032+
case 37: //left arrow
1033+
case 68: //right 'd'
1034+
case 39: //right arrow
1035+
// if a keypresser is already pressing the key don't re-trigger
10241036
if(keyPressers[event.keyCode]){
10251037
return;
10261038
}
1039+
//send gameHandleInput movement related keycode
10271040
game.handleInput(event.keyCode);
1041+
10281042
if(game.repeatPressMovementKeys)
10291043
keyPressers[event.keyCode] = setInterval(function(){game.handleInput(event.keyCode);}, 100);
10301044
else
10311045
keyPressers[event.keyCode] = true;
10321046
break;
10331047
default:
1034-
if(keyPressers[event.keyCode]){
1048+
if(keyPressers[event.keyCode]){
10351049
return;
10361050
}
1051+
// give game handleInput anyway?
10371052
game.handleInput(event.keyCode);
10381053
keyPressers[event.keyCode] = true;
10391054
break;
@@ -1042,10 +1057,14 @@ $(document).keydown(function(event){
10421057

10431058
$(document).keyup(function(event){
10441059
switch(event.keyCode){
1045-
case 87: //up
1046-
case 83: //down
1047-
case 65: //left
1048-
case 68: //right
1060+
case 87: //up 'w'
1061+
case 38: //up arrow
1062+
case 83: //down 's'
1063+
case 40: //down arrow
1064+
case 65: //left 'a'
1065+
case 37: //left arrow
1066+
case 68: //right 'd'
1067+
case 39: //right arrow
10491068
clearInterval(keyPressers[event.keyCode]);
10501069
keyPressers[event.keyCode] = null;
10511070
break;
@@ -1087,6 +1106,7 @@ var asciiRPG = {
10871106
}
10881107

10891108

1109+
// this should be seperate file and or above everything else, since its used within functions etc
10901110
// http://stackoverflow.com/a/1465409/4187005
10911111
if (typeof KeyEvent == "undefined") {
10921112
var KeyEvent = {
File renamed without changes.

html/start.bat run/start.bat

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

html/box.txt tpls/box.txt

File renamed without changes.
File renamed without changes.

html/player.txt tpls/player.txt

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

html/title.txt tpls/title.txt

File renamed without changes.

workspace/justin/README.md

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
* goals of engine.js is to provide a map api to render terrain, prevent walking into things. basic ascii-rendering map.
2+
* creating HUD template such as bag or dialog or pause screen - make a documentated part of the api
3+
4+
* asciiRPG.js --> engine.js
5+
* sample_world.js is excellent, could perhaps split into poke_engine.js and bag functionality moved to engine.js, or when specific javascript is needed name it world.js so the we don't commit to engine.js as much and risk mixing our implementation of the engine with the engine itself.
6+
7+
8+
github we need multiple branches

workspace/justin/engine.js

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<html>
2+
<head>
3+
<title> Pokemon Ash Key</title>
4+
<style>
5+
body {
6+
background-color: rgb(218, 7, 7);
7+
font-family:Verdana,Arial;
8+
}
9+
#title {
10+
width: 250px;
11+
float:left;
12+
}
13+
#title h1 {
14+
text-align:center;
15+
}
16+
#main {
17+
display:block;
18+
display:relative;
19+
margin:auto;
20+
height: 90%;
21+
}
22+
#getInvolved {
23+
background-color:beige;
24+
border-radius:2px;
25+
padding:5px;
26+
}
27+
.clearfix {
28+
clear:both;
29+
}
30+
</style>
31+
<script src="https://code.jquery.com/jquery-2.1.4.min.js"></script>
32+
<script src="../../js/asciiRPG.js"></script>
33+
<script src="../../js/world_config.js"></script>
34+
<script>
35+
var game;
36+
var playerString;
37+
38+
$(function(){
39+
40+
game = asciiRPG.load(document.getElementById("main"), pkmnASCII);
41+
game.run();
42+
});
43+
</script>
44+
</head>
45+
<body>
46+
<canvas id="main" width=1000 height=900></canvas>
47+
</body>
48+
</html>

workspace/justin/index.html

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<html>
2+
<head>
3+
<title> Pokemon Ash Key</title>
4+
<style>
5+
body {
6+
background-color: rgb(218, 7, 7);
7+
font-family:Verdana,Arial;
8+
}
9+
#title {
10+
width: 250px;
11+
float:left;
12+
}
13+
#title h1 {
14+
text-align:center;
15+
}
16+
#main {
17+
display:block;
18+
display:relative;
19+
margin:auto;
20+
height: 90%;
21+
}
22+
#getInvolved {
23+
background-color:beige;
24+
border-radius:2px;
25+
padding:5px;
26+
}
27+
.clearfix {
28+
clear:both;
29+
}
30+
</style>
31+
<script src="https://code.jquery.com/jquery-2.1.4.min.js"></script>
32+
<script src="js/asciiRPG.js"></script>
33+
<script src="js/world_config.js"></script>
34+
<script>
35+
var game;
36+
var playerString;
37+
38+
$(function(){
39+
40+
game = asciiRPG.load(document.getElementById("main"), pkmnASCII);
41+
game.run();
42+
});
43+
</script>
44+
</head>
45+
<body>
46+
<canvas id="main" width=1000 height=900></canvas>
47+
</body>
48+
</html>

0 commit comments

Comments
 (0)