Impact and Node.js Video #7
- hallsofvallhalla
- Site Admin
- Posts: 12023
- Joined: Wed Apr 22, 2009 11:29 pm
Re: Video 7
Awesome, got it up and running, although when one player is moving, it looks really choppy on the other screen, but it is moving in real time with no lag..Weird. Can't wait to see what's next, hopefully AI/Combat!
- hallsofvallhalla
- Site Admin
- Posts: 12023
- Joined: Wed Apr 22, 2009 11:29 pm
Re: Video 7
going to smooth out the multiplayer
Re: Video 7
Hey, just watched your video and noticed you were on about installing socket.io, there's a project on Google Code that installs node with socket.io and other libraries automatically on windows.
http://code.google.com/p/nodejs-win/
http://code.google.com/p/nodejs-win/
Fighting for peace is declaring war on war. If you want peace be peaceful.
Re: Video 7
Hey halls really nice job on the tutorials!
Just wanted to know why do I always get this error on chrome console:
Uncaught TypeError: Cannot call method 'getEntitiesByType' of null index.html: 47
(repeated 4 times)
It only happens to the console of the second player that joins, not the first one. Of course everything seems to work fine, but maybe this could affect impact.
Oh and after testings found a better way for the player to animate more smoothly while moving:
Thanks again for the tutorials!!
Just wanted to know why do I always get this error on chrome console:
Uncaught TypeError: Cannot call method 'getEntitiesByType' of null index.html: 47
(repeated 4 times)
It only happens to the console of the second player that joins, not the first one. Of course everything seems to work fine, but maybe this could affect impact.
Oh and after testings found a better way for the player to animate more smoothly while moving:
Code: Select all
this.addAnim( 'up', .21, [9,10,11,10] ); //arregle unos anims
this.addAnim( 'down', .21, [0,1,2,1] );
this.addAnim( 'left', .21, [3,4,5,4] );
this.addAnim( 'right', .21, [6,7,8,7] );
Orgullo Catracho
Re: Video 7
Hey Chris looks like the win install project has been taken under the wing of nodejs.org
http://code.google.com/p/nodejs-win/
"This project will now be discontinued! NodeJS for Windows is now fully supported by the official release. Please use the official release found from this site!(http://nodejs.org/) Thank you all for your support!"
http://code.google.com/p/nodejs-win/
"This project will now be discontinued! NodeJS for Windows is now fully supported by the official release. Please use the official release found from this site!(http://nodejs.org/) Thank you all for your support!"
Re: Video 7
I can also confirm that this happens. Although, since everything appears to work, I'm going to move along. Interesting nonetheless.Ark wrote:Hey halls really nice job on the tutorials!
Just wanted to know why do I always get this error on chrome console:
Uncaught TypeError: Cannot call method 'getEntitiesByType' of null index.html: 47
(repeated 4 times)
It only happens to the console of the second player that joins, not the first one. Of course everything seems to work fine, but maybe this could affect impact.
Oh and after testings found a better way for the player to animate more smoothly while moving:Thanks again for the tutorials!!Code: Select all
this.addAnim( 'up', .21, [9,10,11,10] ); //arregle unos anims this.addAnim( 'down', .21, [0,1,2,1] ); this.addAnim( 'left', .21, [3,4,5,4] ); this.addAnim( 'right', .21, [6,7,8,7] );
-
- Posts: 19
- Joined: Thu May 10, 2012 2:34 am
Re: Video 7
Hi there,
I'm currently adopting this method into making another game use node.js and socket.io
although, I'm getting an error in my firebug (firefox) javascript console saying 'gamename: playername,' is not defined. playername is not defined in player.js line xxx
I followed through with assigning the playername using the arrays but no luck getting this to work ;9
Any ideas?
I'm currently adopting this method into making another game use node.js and socket.io
although, I'm getting an error in my firebug (firefox) javascript console saying 'gamename: playername,' is not defined. playername is not defined in player.js line xxx
I followed through with assigning the playername using the arrays but no luck getting this to work ;9
Any ideas?
Re: Video 7
Need to see code before we can be sure.
Fighting for peace is declaring war on war. If you want peace be peaceful.
-
- Posts: 19
- Joined: Thu May 10, 2012 2:34 am
Re: Video 7
This is my player.js code... Hopefully its clear...
Code: Select all
ig.module(
'game.entities.player'
)
.requires(
'impact.entity'
)
.defines(function(){
var ismove = 0;
var speed = 100;
EntityPlayer = ig.Entity.extend({
type: ig.Entity.TYPE.A,
animSheet: new ig.AnimationSheet( 'media/paddle-blue.png', 64, 128 ),
checkAgainst: ig.Entity.TYPE.NONE,
size: {x:64, y:128},
nettimer: 10,
name: "player",
gamename: playername,
collides: ig.Entity.COLLIDES.FIXED,
messagebox: "",
messageboxtimer: 200,
speed: 100,
init: function( x, y, settings ) {
this.parent( x, y, settings );
this.addAnim( 'idle', 1, [0] );
socket.emit('initializeplayer', this.gamename);
},
//directional movement UP and DOWN
update: function() {
if( ig.input.state('up') ) {
this.vel.y = -this.speed;
//this.messagebox = this.messagebox + "you pressed up \n";
}
else if( ig.input.state('down') ) {
this.vel.y = +this.speed;
//this.messagebox = this.messagebox + "you pressed down \n";
}
else {
this.vel.y = 0
}
if(this.nettimer < 1)
{
this.nettimer = 5;
socket.emit('recievedata', this.pos.y, this.gamename);
}
this.nettimer = this.nettimer -1;
this.parent();
}
});
///other players
EntityOtherplayer = ig.Entity.extend({
size: {x:64, y:128},
type: ig.Entity.TYPE.B,
speed: 100,
name: "otherplayer",
gamename: "",
collides: eg.Entity.COLLIDES.FIXED,
animSheet: new ig.AnimationSheet( 'media/paddle-red.png', 64, 128 ),
init: function( x, y, settings ) {
this.parent( x, y, settings );
this.addAnim( 'idle', 1, [0] );
},
netmoveplayer: function()
{
this.pos.y = positiony;
},
update: function() {
if( ig.input.state('up') ) {
this.vel.y = -this.speed;
this.messagebox = this.messagebox + "you pressed up \n";
}
else if( ig.input.state('down') ) {
this.vel.y = +this.speed;
this.messagebox = this.messagebox + "you pressed down \n";
}
else {
this.vel.y = 0
}
},
});
})