Page 1 of 1

Impact and Node.js Video #7

Posted: Fri Mar 16, 2012 12:32 am
by hallsofvallhalla

Re: Video 7

Posted: Fri Mar 16, 2012 2:09 am
by MikeD
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! ;)

Re: Video 7

Posted: Fri Mar 16, 2012 1:47 pm
by hallsofvallhalla
going to smooth out the multiplayer

Re: Video 7

Posted: Fri Mar 16, 2012 2:10 pm
by Chris
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/

Re: Video 7

Posted: Sat Mar 24, 2012 4:11 pm
by Ark
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:

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] );
Thanks again for the tutorials!!

Re: Video 7

Posted: Sat Mar 31, 2012 10:30 pm
by gxxaxx
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!"

Re: Video 7

Posted: Sun Apr 22, 2012 12:18 am
by Joncom
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:

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] );
Thanks again for the tutorials!!
I can also confirm that this happens. Although, since everything appears to work, I'm going to move along. Interesting nonetheless.

Re: Video 7

Posted: Mon May 14, 2012 7:19 am
by patrick.bell
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?

Re: Video 7

Posted: Mon May 14, 2012 7:32 am
by Chris
Need to see code before we can be sure.

Re: Video 7

Posted: Mon May 14, 2012 7:36 am
by patrick.bell
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
		}
	},
	
});

})