Impact

This forum is read only and just serves as an archive. If you have any questions, please post them on github.com/phoboslab/impact

1 decade ago by Conner

I suggest looking in to NodeJS (http://nodejs.org/) as a replacement for Apache+PHP. It seems like it'd fit very nicely, being more light weight and completely javascript.

Also, you could potentially make many parts of your engine run IN Node. This, paired with something like http://socket.io , would definitely open the door for multiplayer games.

I realize that Impact is more of a framework than a library, and there is a fairly tight coupling between all the components. Maybe some sort of server-side project could be built up separately that handles things like collision detection and game logic, and then we could get to work on making the current Impact engine network-ready with some sort of message passing format.

I'm definitely willing to help out with any sort of Node implementation if there seems to be any interest.

- Conner

1 decade ago by ape

I've had some success with having Impact make Ajax calls to a fast Rack based web server to save game state, send down new logic, even update the client on the rough whereabouts of other players. I chose this solution over NodeJS mostly because NodeJS is so new to me.

Speaking of messaging, Telehash looks pretty interesting. JSON over UDP. There are implementations in several languages including NodeJS.

1 decade ago by ape

I played with NodeJS and Impact a bit.

I found out pretty quickly that running Impact as a full NodeJS app isn't possible without some hacking. Impact is relying on the window object being available. The window object exists in browsers, but not in NodeJS.

There are some tricks to simulate the window object but it starts getting weird quickly.

I may try to see if I can tweak something like collision detection to run in NodeJS this evening, but there are some other obstacles to tackle first. For example, I don't think NodeJS is happy about how ImpactJS does modules.

That said, I think there's a hybrid approach for fast sever interaction. For example, if I want to ensure that the server controls the position of an Entity, I can write my own handleMovementTrace method for the entity that asks the server what to do. Given the right server and messaging, this could be done nearly as quickly as it's done client side.

1 decade ago by Conner

Awesome, nice to see someone else is interested in this concept!

I agree with you that Impact as a full NodeJS app isn't the right approach. I took the basic approach of replacing PHP's current role in Impact with NodeJS.

The project can be seen here: https://github.com/cpetzold/node-impact

I'm also planning some sort of binary that creates a new game with template code in place. With npm in place, this could be a very easy and painless process. Something like:

$ npm install impact

And in the directory where you want your game:

$ impact /path/to/impact/ gameName

1 decade ago by ape

I've made interesting progress this evening.

I built a Rails app using Juggernaut and can push logic directly into my entities.

Juggernaut is basically a NodeJS server, Redis client, and Ruby client combined. If you know your way around Ruby and Rails you can get the server side up in a few minutes.

Juggernaut also has a JS client. I just include that, then do something like this in my Entity's init method:

jug = new Juggernaut;
var self = this;
jug.subscribe("/sync/1");
jug.on("message", function(message){ 
   self.handleServerMessage(message);
});

The jug object waits for messages, then executes whatever I've told it to within the message handler.

From my Rails app I can call do:

Juggernaut.publish("/sync/1", {:all => {:sorts => "of data"})

Anything subscribing to the /sync/1 channel will get whatever data I send down (which gets serialized automatically by the JS client).

Redis and NodeJS are responsible for keeping messaging overhead to a minimum.

There's some serious potential here, not just for games that have nicely synced game state data, but for multiplayer games as well. I can just as easily publish messages on a channel from the JS client as I can from Rails.

Next steps: pull together a sample Rails app that demonstrates what I've just described.

1 decade ago by odiemiranda

I would like to suggest to have Transparent RPC protocol in there. It will help alot on message broadcasting.

1 decade ago by MikeL

@ape: that is very, very cool stuff. Hadn't heard of Juggernaut before. Looking forward to seeing your sample since I have used Rails a lot for other projects.

1 decade ago by ape

Alright. I have something about 95% ready. Just want write up the README.

I simplified stuff a lot - in fact it's not longer an example of Rails+Impact+NodeJS+Redis+Juggernaut, it's simply Rails+Impact+Socket.IO.

And the Rails part is optional. It's there simply because it's easy to fire up a server. If I have some free time later tonight I might simply remove the Rails part and make a simple NodeJS server to serve the sample ImpactJS game and the Socket.IO client.

1 decade ago by Hareesun

@ape - That'd be awesome! Totally looking forward to it! :)

1 decade ago by ape

Here it is:

https://github.com/elbowdonkey/ImpactJS-Socket.IO

If anyone has trouble getting it rolling let me know. I suspect there are some console.log() calls in there as well as some orphaned code. I'll make improvements where needed.

1 decade ago by jminor

Works great. Thanks for making this!

Looking over the code it seems like I can just make up new messages without needing to do anything on the server side is that correct?

Also, what sort of limits in terms of speed & number of clients would you expect this to work with?

1 decade ago by MikeL

Good stuff ape. I need to do a little work getting nodejs up and running on my Windows machine, but anxious to give it a try.

Do you have any specific advice or hints for getting Impact going with Rails? That's my next project.

1 decade ago by ape

ImpactJS and Rails work fine together as long as you put stuff in the right place.

Your Rails app's public folder should look something like this:

rails_root/public
rails_root/public/lib
rails_root/public/lib/impact
rails_root/public/lib/game
rails_root/public/lib/game/entities
rails_root/public/lib/game/levels
rails_root/public/lib/media

Etc, etc.

Weltmeister doesn't work since it relies on PHP being there. I tried porting those PHP files to Rails at one point but got hung up on path issues. I've since given up since it's super easy to just fire up XAMPP, edit some levels as needed, and bring them into the games I'm working on manually.

1 decade ago by ape

Quote from MikeL
Good stuff ape. I need to do a little work getting nodejs up and running on my Windows machine, but anxious to give it a try.


Wish I could help you there - I have no idea if it's easy, difficult, or even possible to get it running on Windows. I've read that you can setup a NodeJS host pretty easily on Slicehost, or even Amazon's EC2. In both cases though you'd want to be comfortable with setting stuff up in a non-Windows environment, which may be more trouble then getting it to work on Windows.

1 decade ago by MikeL

Thanks very much for the Rails info. That should save me a good deal of time. Much appreciated.

Regarding NodeJS on Windows, I found this link: Building node.js on Cygwin
which doesn't look too difficult (hopefully) for those with some familiarity with Cygwin.

1 decade ago by MikeL

@ape: Very nice! Seeing it in action is pretty wild.

A few things:
1. It is possible to get nodejs running in Windows (if you are insane enough). These links help:

- Building node.js on Cygwin (be sure to RTFM regarding which version to build).

- helpful comments on StackOverflow - in particular running the obscure ash.exe and doing rebaseall seemed to help

- self-contained windows binaries of nodejs - I did't try this, but seems like it could save some headaches

2. I could get the game to run on Chrome, but not Firefox (this may be a Windows specific issue, so please ignore if that's the case).

3. Some of you may know this already, but Heroku.com - on which you can host Rails apps - is looking to have Node.js support this year. They have already had a beta version, but it looks like it is closed to new users for now:
Heroku Node.js support

1 decade ago by enpu

https://github.com/elbowdonkey/ImpactJS-Socket.IO

i cant get this to work :/
any help please?

1 decade ago by Hareesun

http://peepcode.com/products/nodejs-i - Probably a good ground for a lot of people. :)

1 decade ago by ape

@enpu - sorry for the delay in responding.

In any case, I scrapped that old project and turned it into a plugin.

Read the post here, and grab the repo here:

https://github.com/elbowdonkey/impsock

1 decade ago by StarFlight

Thanks ape for your hard work! I'll surely take a look of that since I'm looking on how to port my multi-player game currently using Html5 canvas and websocket where all the logic is done on the server and rendering part on the client.

Just new to ImpactJs so a lot of reading to get familiar with.

1 decade ago by CG_Wang

Quote from StarFlight
Thanks ape for your hard work! I'll surely take a look of that since I'm looking on how to port my multi-player game currently using Html5 canvas and websocket where all the logic is done on the server and rendering part on the client.

Just new to ImpactJs so a lot of reading to get familiar with.


Hi StarFlight, I have the same issue with you now. Could I ask how is it going with your porting work now ? Is there any way making websocket working with Ejecta? Or did you find some other way to complete this goal?

I would be very appreciate it if you could share some ideas .

1 decade ago by divya

Especially node.js:
===============
I have some carousels at front end...depending on the time the number of carousels have to be changed(for that I dynamically get the data i.e. size of that particular div from backend-->node.js)...
but unable to set that..Iam using dust also...

Some class
carousel-inner
inside dis we have images(which we wants to be slided)
carousel-inner div closed
some class div closed



for static data it results good if we apply height and width to images and as well to "some class"...style inside the images was built in dust whereas for that "some class" at front end unable to set style dynamically....

1 decade ago by dmen

Interesting thread. I know it's a bit old - but Node runs great on Windows. I am running Node with Socket IO in Windows 8 for a mutiplayer Impact game. Socket IO is very fast, though I'm running it locally - and the game will be all run locally as well. Using a Win8 laptop for the node server and Impact is then running on two Microsoft Surface Pro's. I'm about 95% done right now - just need to add sounds and a few more animations and it's a wrap.

1 decade ago by manuelac

I've implemented all the multiplayer features adapting the ImpactConnect plugin to my game and it works flawlessly. Socket.io is a beast.

8 years ago by Bum

I'm added nodejs support to weltmeister. Impactjs is now 100% nodejs.

http://impactjs.com/forums/code/f-l-a-r-e-development-suite-for-impact
Page 1 of 1
« first « previous next › last »