Witam serdecznie, niestety po odpaleniu wyświetla mi się mapa, wyświetla mi się postać lecz tylko się obraca w stronę w którą naciskał strzałkę, ale postać nie chce iść :/ dlaczego ?
Ogólnie w konsoli mam zero błędów..
game.js
enchant();
var players = false;
var online_players = Array ( );
var ws = false;
window.onload = function() {
var game = new Game(320, 320);
game.fps = 15;
game.preload('map1.gif', 'chara0.gif');
game.onload = function() {
var map = new Map(16, 16);
map.image = game.assets['map1.gif'];
map.loadData([
(TU JEST MAPA ALE USUWAM GDYŻ MAKSYMALNIE MOŻNA UŻYĆ 15 TYŚ ZNAKÓW!)
var foregroundMap = new Map(16, 16);
foregroundMap.image = game.assets['map1.gif'];
foregroundMap.loadData([
[ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1],
[ -1,461,462, -1,461,462, -1,461,462, -1,461,462, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1],
[ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1],
[ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1],
[ -1,461,462, -1, -1, -1, -1, -1, -1, -1,461,462, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1],
[ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1],
[ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1],
[ -1,461,462, -1, -1, -1, -1, -1, -1, -1,461,462, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1],
[ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1],
[ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,461,462, -1, -1],
[ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1],
[ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,402, -1, -1, -1, -1, -1, -1, -1, -1],
[ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,461,462, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1],
[ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1],
[ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1],
[ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1],
[ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1],
[ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,461,462,461,462, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1],
[ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1],
[ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,461,462, -1, -1, -1],
[ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1],
[ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1],
[ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1],
[ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1],
[ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1],
[ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1],
[ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1],
[ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,461,462, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1],
[ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1],
[ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]
]);
var createPlayerShadow = function ( ) {
var shadow = new Sprite(32, 32);
shadow.x = 6 * 16 - 8;
shadow.y = 10 * 16;
var image = new Surface(96, 128);
image.draw(game.assets['chara0.gif'], 0, 0, 96, 128, 0, 0, 96, 128);
shadow.image = image;
shadow.direction = 0;
shadow.walk = 1;
shadow.addEventListener('enterframe', function() {
this.frame = this.direction * 3 + this.walk;
} );
return shadow;
}
ws.onmessage = function ( msg ) {
var j = JSON.parse ( msg.data );
switch ( j.id ) {
case 1:
//New User Connected
online_players[j.uid] = createPlayerShadow ( );
players.addChild ( online_players[j.uid] );
break;
case 2:
//Update User Position
if ( online_players[j.uid] ) {
online_players[j.uid].x = j.x;
online_players[j.uid].y = j.y;
online_players[j.uid].direction = j.d;
} else {
online_players[j.uid] = createPlayerShadow ( );
players.addChild ( online_players[j.uid] );
online_players[j.uid].x = j.x;
online_players[j.uid].y = j.y;
online_players[j.uid].direction = j.d;
}
break;
}
}
var player = new Sprite(32, 32);
player.x = 6 * 16 - 8;
player.y = 10 * 16;
var image = new Surface(96, 128);
image.draw(game.assets['chara0.gif'], 0, 0, 96, 128, 0, 0, 96, 128);
player.image = image;
player.isMoving = false;
player.direction = 0;
player.walk = 1;
player.addEventListener('enterframe', function() {
this.frame = this.direction * 3 + this.walk;
if (this.isMoving) {
this.moveBy(this.vx, this.vy);
if (!(game.frame % 3)) {
this.walk++;
this.walk %= 3;
}
if ((this.vx && (this.x-8) % 16 == 0) || (this.vy && this.y % 16 == 0)) {
this.isMoving = false;
this.walk = 1;
}
} else {
this.vx = this.vy = 0;
if (game.input.left) {
this.direction = 1;
this.vx = -4;
} else if (game.input.right) {
this.direction = 2;
this.vx = 4;
} else if (game.input.up) {
this.direction = 3;
this.vy = -4;
} else if (game.input.down) {
this.direction = 0;
this.vy = 4;
}
if (this.vx || this.vy) {
var x = this.x + (this.vx ? this.vx / Math.abs(this.vx) * 16 : 0) + 16;
var y = this.y + (this.vy ? this.vy / Math.abs(this.vy) * 16 : 0) + 16;
}
}
});
players = new Group ( );
players.addChild(player);
var stage = new Group();
stage.addChild(map);
stage.addChild(players);
stage.addChild(foregroundMap);
game.rootScene.addChild(stage);
var pad = new Pad();
pad.x = 0;
pad.y = 220;
game.rootScene.addChild(pad);
game.rootScene.addEventListener('enterframe', function(e) {
var x = Math.min((game.width - 16) / 2 - player.x, 0);
var y = Math.min((game.height - 16) / 2 - player.y, 0);
x = Math.max(game.width, x + map.width) - map.width;
y = Math.max(game.height, y + map.height) - map.height;
stage.x = x;
stage.y = y;
});
};
game.start();
};