Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

merged readme

  • Loading branch information...
commit 834f56ac6dae7b53e47b5f60f13d1375ba0094a5 2 parents 8a3b86c + c23043b
@monteslu monteslu authored
Showing with 78 additions and 13 deletions.
  1. +50 −1 README
  2. +21 −1 src/mwe/GameAction.js
  3. +7 −11 src/mwe/InputManager.js
View
51 README
@@ -14,4 +14,53 @@ https://chrome.google.com/webstore/detail/acjijhekaonkmkedfdabbageicfhhlgo
More documentation coming. Promise :)
--Luis
+-Luis
+=======
+
+Firstly:
+Since this is a dojo extension it requires dojo. I'm going to assume you already use dojo, and your site has a directory named "dojo". Your site should have a directory structure that looks roughly like:
+
+/js
+ /dojo
+ /cldr
+ /data
+ /date
+ /dnd
+ /fx
+ /io
+ /nls
+ /rsources
+ /rpc
+ /selector
+ /store
+ - dojo.js
+ - other js files...
+
+To install:
+put the /src/mwe from the src/ folder into your dojo directory
+
+To use:
+here's a skeleton HTML file
+
+<html>
+<head>
+<title></title>
+<script
+ src="js/dojo/dojo.js"
+ djConfig="baseUrl: 'js/dojo/', modulePaths: {mwe: 'mwe'}">
+</script>
+</head>
+<body>
+<script>
+ dojo.require('mwe.GameCore');
+ dojo.require('mwe.Sprite');
+ dojo.require('mwe.ResourceManager');
+ dojo.require('mwe.GameAction');
+</script>
+</body>
+</html>
+
+This pulls in monwarp.
+
+extra doc credit:
+@davidsiaw
View
22 src/mwe/GameAction.js
@@ -25,6 +25,8 @@ dojo.declare("mwe.GameAction",null,{
behavior: 0,
amount : 0,
state : 0,
+ x : -1,
+ y : -1,
statics: {
/**
@@ -42,7 +44,8 @@ dojo.declare("mwe.GameAction",null,{
STATE_RELEASED : 0,
STATE_PRESSED : 1,
- STATE_WAITING_FOR_RELEASE : 2
+ STATE_WAITING_FOR_RELEASE : 2,
+ STATE_MOVED : 3
},
/**
@@ -112,6 +115,14 @@ dojo.declare("mwe.GameAction",null,{
this.state = this.statics.STATE_RELEASED;
},
+ /**
+ Signals that a movement has occurred
+ */
+ move: function(x, y) {
+ this.x = x;
+ this.y = y;
+ },
+
/**
Returns whether the key was pressed or not since last
@@ -128,6 +139,15 @@ dojo.declare("mwe.GameAction",null,{
/**
+ Gets the current position of the mouse/touch if its registered
+ as a mouse/touch action
+ */
+ getPosition : function() {
+ var self = this;
+ return {x:self.x, y:self.y};
+ },
+
+ /**
For keys, this is the number of times the key was
pressed since it was last checked.
For mouse movement, this is the distance moved.
View
18 src/mwe/InputManager.js
@@ -71,32 +71,28 @@ dojo.declare("mwe.InputManager",null,{
},
- mouseUp: function(e){
-
-
+ mouseUp: function(e) {
+ this.mouseAction.release();
},
mouseDown: function(e){
-
-
+ this.mouseAction.press();
},
mouseMove: function(e){
-
+ this.mouseAction.move(e.clientX, e.clientY);
},
touchStart: function(e){
-
-
+ this.touchAction.press();
},
touchEnd: function(e){
-
-
+ this.touchAction.release();
},
touchMove: function(e){
-
+ this.touchAction.move(e.clientX, e.clientY);
},
Please sign in to comment.
Something went wrong with that request. Please try again.