Skip to content

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also .

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also .
...
  • 2 commits
  • 8 files changed
  • 0 commit comments
  • 1 contributor
View
16 README.md
@@ -4,8 +4,18 @@ HTML5 Jump & Run framework.
Features:
- Compatible with all HTML5 browsers,
- tested with: Firefox 15, Chrome
+ tested with: Firefox 15+, Chrome
- No dependencies
-- Easy level creation
+- Easy level creation with textfiles
- Supports different themes
-- Touchscreen controls
+- Soundeffects
+
+
+- Tablet + Mobile support:
+ - Touchscreen controls
+ - responds to changing screen dimensions (rotate)
+ - Supports different screen dimensions (Tablet, phone ...)
+
+
+Have Fun!
+Tom (tom@digitalflow.de)
View
1 TODO
@@ -3,7 +3,6 @@
- sounds + preload
- theme initializer
- avoid double jumps
-- License
- vertical scroll?
- different background colors (image)
- startscreen image
View
1 index.html
@@ -67,6 +67,7 @@
<!-- don't forget the charset here, else the levels will be parsed incorrectly -->
<script type="text/javascript" src="js/menu.js" charset="utf-8"></script>
<script type="text/javascript" src="js/levels.js" charset="utf-8"></script>
+<script type="text/javascript" src="js/level_methods.js" charset="utf-8"></script>
<script type="text/javascript" src="js/game.js" charset="utf-8"></script>
<script type="text/javascript" src="js/controls.js" charset="utf-8"></script>
<script type="text/javascript" src="js/sounds.js" charset="utf-8"></script>
View
1 index_all.html
@@ -75,6 +75,7 @@
<!-- don't forget the charset here, else the levels will be parsed incorrectly -->
<script type="text/javascript" src="js/menu.js" charset="utf-8"></script>
<script type="text/javascript" src="js/levels.js" charset="utf-8"></script>
+<script type="text/javascript" src="js/level_methods.js" charset="utf-8"></script>
<script type="text/javascript" src="js/game.js" charset="utf-8"></script>
<script type="text/javascript" src="js/controls.js" charset="utf-8"></script>
<script type="text/javascript" src="js/sounds.js" charset="utf-8"></script>
View
245 js/game.js
@@ -72,23 +72,6 @@ Number.prototype.inRange = function (a, b) {
return ( n >= a && n <= b );
};
-function replaceLevelSpriteXY(x, y, item) {
- line_nr = y / size.tile.target.h - line_offset_y
- replaceLevelSprite(x / size.tile.target.w, line_nr, item)
-}
-
-function replaceLevelSprite(pos, line, item) {
- current_level.level[line] = current_level.level[line].replaceAt(pos, item);
-}
-
-function getLevelSpriteXY(x, y) {
- line_nr = y / size.tile.target.h - line_offset_y;
- return getLevelSprite(x / size.tile.target.w, line_nr);
-}
-
-function getLevelSprite(pos, line) {
- return current_level.level[line].charAt(pos);
-}
function drawLevel() {
@@ -112,242 +95,22 @@ function drawLevel() {
index_y += line_offset_y;
- // context.drawImage(img,x,y,width,height);
- // context.drawImage(img,sx,sy,swidth,sheight,dx,dy,dwidth,dheight);
-
// first tile to display:
var index_x_start = scroll_x / size.tile.target.w
var offset_x = scroll_x % size.tile.target.w
// last tile to show
var index_x_max = index_x_start + size.tiles.target.w + 1
for (var index_x = index_x_start; index_x < index_x_max; index_x++) {
-
- var object = { sx:null, sy:null, x:((index_x) * tw) - offset_x, y:index_y * th, deadly:false, solid:true };
-
- /* used characters: # x H k h / ^ ü g ` { = } @ 1 2 3 4 5 6 ?
- * ß q w a s b p \ ° R | * W U B O X l j ( ) [ ]]
- * z 8 */
- switch (linecontent.charAt(index_x)) {
- case '#':
- object.sx = 5;
- object.sy = 0;
- collisionMap.push(object);
- break;
- case 'x':
- object.sx = 0;
- object.sy = 0;
- collisionMap.push(object);
- break;
- case 'H':
- object.sx = 2;
- object.sy = 2;
- collisionMap.push(object);
- break;
- case 'k':
- object.sx = 6;
- object.sy = 0;
- collisionMap.push(object);
- break;
- case 'h':
- object.sx = 12;
- object.sy = 6;
- object.deadly = true;
- collisionMap.push(object);
- break;
- case '/':
- object.sx = 0;
- object.sy = 1;
- break;
- case '^':
- object.sx = 1;
- object.sy = 0;
- break;
- case 'ü':
- object.sx = 1;
- object.sy = 1;
- break;
- case 'g':
- object.sx = 4;
- object.sy = 1;
- break;
- case '`':
- object.sx = 2;
- object.sy = 1;
- break;
- case '{':
- object.sx = 2;
- object.sy = 0;
- break;
- case '=':
- object.sx = 3;
- object.sy = 0;
- break;
- case '}':
- object.sx = 4;
- object.sy = 0;
- break;
- case '@':
- object.sx = 9;
- object.sy = 2;
- object.deadly = true;
- collisionMap.push(object);
- break;
- case '1':
- object.sx = 0;
- object.sy = 7;
- break;
- case '2':
- object.sx = 1;
- object.sy = 7;
- break;
- case '3':
- object.sx = 2;
- object.sy = 7;
- break;
- case '4':
- object.sx = 0;
- object.sy = 8;
- break;
- case '5':
- object.sx = 1;
- object.sy = 8;
- break;
- case '6':
- object.sx = 2;
- object.sy = 8;
- break;
- case '?':
- object.sx = 0;
- object.sy = 11;
- object.type = 'block_coin'
- collisionMap.push(object);
- break;
- case 'ß':
- object.sx = 1;
- object.sy = 11;
- collisionMap.push(object);
- break;
- case 'q':
- object.sx = 0;
- object.sy = 2;
- collisionMap.push(object);
- break;
- case 'w':
- object.sx = 1;
- object.sy = 2;
- collisionMap.push(object);
- break;
- case 'a':
- object.sx = 0;
- object.sy = 3;
- collisionMap.push(object);
- break;
- case 's':
- object.sx = 1;
- object.sy = 3;
- collisionMap.push(object);
- break;
- case 'b':
- object.sx = 13;
- object.sy = 4;
- break;
- case 'p':
- object.sx = 0;
- object.sy = 12;
- object.deadly = true;
- object.type = "enemy_mushroom"
- object.speed_x = 4
- items.push(object);
- replaceLevelSprite(index_x, index_y - line_offset_y, " ");
- break;
- case '\'':
- object.sx = 2;
- object.sy = 3;
- break;
- case '°':
- object.sx = 3;
- object.sy = 2;
- break;
- case 'R':
- object.sx = 3;
- object.sy = 3;
- break;
- case '|':
- object.sx = 3;
- object.sy = 4;
- break;
- case '*':
- object.sx = 1;
- object.sy = 4;
- break;
- case 'W':
- object.sx = 0;
- object.sy = 4;
- break;
- case 'U':
- object.sx = 2;
- object.sy = 6;
- break;
- case 'B':
- object.sx = 1;
- object.sy = 6;
- object.type = 'exit'
- collisionMap.push(object);
- break;
- case 'O':
- object.sx = 1;
- object.sy = 5;
- break;
- case 'X':
- object.sx = 2;
- object.sy = 4;
- break;
- case 'l':
- object.sx = 0;
- object.sy = 5;
- break;
- case 'j':
- object.sx = 2;
- object.sy = 5;
- break;
- case '(':
- object.sx = 11;
- object.sy = 0;
- break;
- case ')':
- object.sx = 12;
- object.sy = 0;
- break;
- case '[':
- object.sx = 11;
- object.sy = 1;
- break;
- case ']':
- object.sx = 12;
- object.sy = 1;
- break;
- case 'z':
- object.sx = 9;
- object.sy = 9;
- collisionMap.push(object);
- break;
- case '8':
- object.sx = 0;
- object.sy = 6;
- collisionMap.push(object);
- break;
- default:
- }
+ var object = getLevelObject(linecontent.charAt(index_x), index_x, index_y);
if (object.sx != null && object.sy != null) {
+ object.x = index_x * tw - offset_x
+ object.y = index_y * th
ctx.drawImage(spriteMap, object.sx * (sw + 1) + 0.5, object.sy * (sh + 1) + 0.5, sw - 0.8, sh - 0.8, object.x - index_x_start * tw, object.y, tw, th);
}
}
-
-
}
);
-
}
@@ -449,7 +212,7 @@ function updateCharacters() {
}
// apply collision to player movement
- if (object && object.solid) {
+ if (object) {
if (collides.top) {
actor.pos.y = object.y + size.tile.target.h;
actor.speed.y = 1;
View
237 js/level_methods.js
@@ -0,0 +1,237 @@
+function replaceLevelSpriteXY(x, y, item) {
+ line_nr = y / size.tile.target.h - line_offset_y
+ replaceLevelSprite(x / size.tile.target.w, line_nr, item)
+}
+
+function replaceLevelSprite(pos, line, item) {
+ current_level.level[line] = current_level.level[line].replaceAt(pos, item);
+}
+
+function getLevelSpriteXY(x, y) {
+ line_nr = y / size.tile.target.h - line_offset_y;
+ return getLevelSprite(x / size.tile.target.w, line_nr);
+}
+
+function getLevelSprite(pos, line) {
+ return current_level.level[line].charAt(pos);
+}
+
+function getLevelObject(character, index_x, index_y) {
+
+ var object = { sx:null, sy:null, deadly:false };
+ /* used characters: # x H k h / ^ ü g ` { = } @ 1 2 3 4 5 6 ?
+ * ß q w a s b p \ ° R | * W U B O X l j ( ) [ ]]
+ * z 8 */
+ switch (character) {
+ case '#':
+ object.sx = 5;
+ object.sy = 0;
+ collisionMap.push(object);
+ break;
+ case 'x':
+ object.sx = 0;
+ object.sy = 0;
+ collisionMap.push(object);
+ break;
+ case 'H':
+ object.sx = 2;
+ object.sy = 2;
+ collisionMap.push(object);
+ break;
+ case 'k':
+ object.sx = 6;
+ object.sy = 0;
+ collisionMap.push(object);
+ break;
+ case 'h':
+ object.sx = 12;
+ object.sy = 6;
+ object.deadly = true;
+ collisionMap.push(object);
+ break;
+ case '/':
+ object.sx = 0;
+ object.sy = 1;
+ break;
+ case '^':
+ object.sx = 1;
+ object.sy = 0;
+ break;
+ case 'ü':
+ object.sx = 1;
+ object.sy = 1;
+ break;
+ case 'g':
+ object.sx = 4;
+ object.sy = 1;
+ break;
+ case '`':
+ object.sx = 2;
+ object.sy = 1;
+ break;
+ case '{':
+ object.sx = 2;
+ object.sy = 0;
+ break;
+ case '=':
+ object.sx = 3;
+ object.sy = 0;
+ break;
+ case '}':
+ object.sx = 4;
+ object.sy = 0;
+ break;
+ case '@':
+ object.sx = 9;
+ object.sy = 2;
+ object.deadly = true;
+ collisionMap.push(object);
+ break;
+ case '1':
+ object.sx = 0;
+ object.sy = 7;
+ break;
+ case '2':
+ object.sx = 1;
+ object.sy = 7;
+ break;
+ case '3':
+ object.sx = 2;
+ object.sy = 7;
+ break;
+ case '4':
+ object.sx = 0;
+ object.sy = 8;
+ break;
+ case '5':
+ object.sx = 1;
+ object.sy = 8;
+ break;
+ case '6':
+ object.sx = 2;
+ object.sy = 8;
+ break;
+ case '?':
+ object.sx = 0;
+ object.sy = 11;
+ object.type = 'block_coin'
+ collisionMap.push(object);
+ break;
+ case 'ß':
+ object.sx = 1;
+ object.sy = 11;
+ collisionMap.push(object);
+ break;
+ case 'q':
+ object.sx = 0;
+ object.sy = 2;
+ collisionMap.push(object);
+ break;
+ case 'w':
+ object.sx = 1;
+ object.sy = 2;
+ collisionMap.push(object);
+ break;
+ case 'a':
+ object.sx = 0;
+ object.sy = 3;
+ collisionMap.push(object);
+ break;
+ case 's':
+ object.sx = 1;
+ object.sy = 3;
+ collisionMap.push(object);
+ break;
+ case 'b':
+ object.sx = 13;
+ object.sy = 4;
+ break;
+ case 'p':
+ object.sx = 0;
+ object.sy = 12;
+ object.deadly = true;
+ object.type = "enemy_mushroom"
+ object.speed_x = 4
+ items.push(object);
+ replaceLevelSprite(index_x, index_y - line_offset_y, " ");
+ break;
+ case '\'':
+ object.sx = 2;
+ object.sy = 3;
+ break;
+ case '°':
+ object.sx = 3;
+ object.sy = 2;
+ break;
+ case 'R':
+ object.sx = 3;
+ object.sy = 3;
+ break;
+ case '|':
+ object.sx = 3;
+ object.sy = 4;
+ break;
+ case '*':
+ object.sx = 1;
+ object.sy = 4;
+ break;
+ case 'W':
+ object.sx = 0;
+ object.sy = 4;
+ break;
+ case 'U':
+ object.sx = 2;
+ object.sy = 6;
+ break;
+ case 'B':
+ object.sx = 1;
+ object.sy = 6;
+ object.type = 'exit'
+ collisionMap.push(object);
+ break;
+ case 'O':
+ object.sx = 1;
+ object.sy = 5;
+ break;
+ case 'X':
+ object.sx = 2;
+ object.sy = 4;
+ break;
+ case 'l':
+ object.sx = 0;
+ object.sy = 5;
+ break;
+ case 'j':
+ object.sx = 2;
+ object.sy = 5;
+ break;
+ case '(':
+ object.sx = 11;
+ object.sy = 0;
+ break;
+ case ')':
+ object.sx = 12;
+ object.sy = 0;
+ break;
+ case '[':
+ object.sx = 11;
+ object.sy = 1;
+ break;
+ case ']':
+ object.sx = 12;
+ object.sy = 1;
+ break;
+ case 'z':
+ object.sx = 9;
+ object.sy = 9;
+ collisionMap.push(object);
+ break;
+ case '8':
+ object.sx = 0;
+ object.sy = 6;
+ collisionMap.push(object);
+ break;
+ default:
+ }
+ return object;
+}
View
BIN themes/super_mario/music/theme.mp3
Binary file not shown.
View
BIN themes/suse/images/resources/geeko_kawaii_thumb.png
Deleted file not rendered

No commit comments for this range

Something went wrong with that request. Please try again.