Skip to content

Commit 7538c56

Browse files
committed
Merge pull request DragonDeltaSquad#2 from Karma-Tech-Consulting/master
Merge new Architecture and setup for demo
2 parents f0d38bb + 6b2e981 commit 7538c56

29 files changed

+4271
-17
lines changed

README.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@
1818
/___/ |_| |____/ |_| |_| `._,,' |_| \_||____| |_|
1919
2020
21-
# pokemon-ash-key-2
21+
# pokemon-ash-key
2222
ASCII rendered, Pokemon inspired MMORPG
2323

24+
## [play now](http://karma-tech-consulting.github.io/pokemon-ash-key/)
25+
2426
Explore territory, catch pokemon battle trainers... in a land of ASCII characters.

index.html

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
<html>
2+
<head>
3+
<title> Pokemon Ash Key</title>
4+
<style>
5+
body {
6+
background-color: #000040;
7+
font-family:Verdana,Arial;
8+
}
9+
h1, h2 {
10+
color: #FFFF99;
11+
}
12+
13+
h1 > b, h2 > b {
14+
color: #ffd700;
15+
}
16+
#title {
17+
width: 250px;
18+
float:left;
19+
}
20+
#title h1 {
21+
text-align:center;
22+
}
23+
#main {
24+
display:block;
25+
display:relative;
26+
margin:auto;
27+
height: 90%;
28+
}
29+
#getInvolved {
30+
background-color:beige;
31+
border-radius:2px;
32+
padding:5px;
33+
}
34+
.clearfix {
35+
clear:both;
36+
}
37+
</style>
38+
<script src="https://code.jquery.com/jquery-2.1.4.min.js"></script>
39+
<script src="js/asciiRPG.js"></script>
40+
<script src="js/sample_world.js"></script>
41+
<script>
42+
var game;
43+
var playerString;
44+
45+
$(function(){
46+
47+
game = asciiRPG.load(document.getElementById("main"), pkmnASCII);
48+
game.run();
49+
});
50+
</script>
51+
</head>
52+
<body>
53+
<canvas id="main" width=1000 height=900></canvas>
54+
<div style="text-align: center">
55+
<h1><b>Controls</b></h1>
56+
<h1><b>'E'</b> to inspect tiles/advance dialog</h1>
57+
<h1><b>'Q'</b> to open menu</h1>
58+
<h1><b>'W'</b>, <b>'A'</b>, <b>'S'</b>, <b>'D'</b> to move</h1>
59+
<h2>Check out the code on github to get involved! <iframe src="https://ghbtns.com/github-btn.html?user=DragonDeltaSquad&repo=pokemon-ash-key&type=star&count=true&size=large" frameborder="0" scrolling="0" width="160px" height="30px"></iframe></h2>
60+
</div>
61+
</body>
62+
</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 = {

0 commit comments

Comments
 (0)