CrowdGaming - your smartphone is your controller

Discussion of tools and resources for game developers

Post » Sat Jul 18, 2015 9:40 pm

@onemuppet - Is there a way to be able to make the server connection stuff lookup a dynamic IP address instead of pre-filling it in the project properties?

Imagine a situation where you export the app to nw.js for example and when you run it you would need to main program to show you the connection information where the players will need connect to. If it could display in a text field the main games local ip address that would be awesome.

thanks!
B
89
S
44
G
16
Posts: 1,010
Reputation: 17,998

Post » Sun Jul 19, 2015 6:31 am

OneMuppet wrote:@russpuppy

I also think that the NW.js exporter could be a good choice since we could start files from the OS with the nwjs plugin. Hypothetically we should be able to run a .bat file or equivalent On Start of layout in the "Start" layout and when running that bat command try to find out the ip (ipconfig) and then start the nodejs server (node server.js) then instead of having prodUrl as a static variable in the construct 2 project we could read this from a file which we modify in the start.bat with something like:
for /f "delims=[] tokens=2" %%a in ('ping %computername% -n 1 ^| findstr "["') do (set thisip=%%a)
echo %thisip%


@OneMuppet - I was playing around with this idea, but can't get nwjs to run a bat file, it seems to only like .exe's
B
89
S
44
G
16
Posts: 1,010
Reputation: 17,998

Post » Sun Jul 26, 2015 12:45 am

@OneMuppet

Hi,
just a question...
Anyway to display several maingame on several devices ?
For now it's always the first connected which is maingame, and all the others are controllers.
in the start sheet, it's "on connected to server / Is Controller => Goto ctrlJoystick
Else goto Space"
how to "not be Controller" anymore, and just display the main game screen ?

Thx
B
6
S
1
Posts: 25
Reputation: 450

Post » Thu Jul 30, 2015 10:11 pm

@Justifun I'm not sure if I ever got the bat file to work or not, but you will have to do an export and then run the exe-file to test the "Run file" action. But you probably already tried that since you were able to run exe-files.

I did some research about nwjs and learned that it doesn't use any web server (which I originally thought) but instead it reads directly from disk. The export produces a file called package.nw if you rename this to package.zip and look in the zip-archive you find all your files there. However these files only work when run in the nodewebkit environment, which means I can't just "server" these file from a web server because there would be dependency errors.

So why do we need a web server? Well we need the "controllers" to be able to connect to something. What I have done to make this work is:
- add server.js as a project file
- modified the nwjs plugin and added a start web server action
- In the Start event sheet I've added Start Web Server and Run "node server.js"
- Export with Nwjs exporter
- Open package.nw (rename to zip and open)
- Export with html5 exported
- Create a directory called "controller" and add html5 export to it
- Add the "controller" directory to the package.zip file
- rename package.zip to package.nw
- run the exe

When you run the exe it will start a web server that will "serve" the html5 export on port 50000, so when you connect to ip-of-host-machine:50000 you will see the controller, as you normally would. The main game also starts the server.js file so the main game an controllers can connect to one another.

This is a step in the right direction towards being able to package CrowdGaming games to the masses. The problem with showing the ip-that the "controllers" should connect to still remains.
B
39
S
9
G
4
Posts: 163
Reputation: 6,516

Post » Thu Jul 30, 2015 10:41 pm

@Amadeus The server doesn't know much about the game, it's basically the main game that has all the info, plus we only send actions and preferably only delta actions (when anything changes), . So if we want a controller to act/show the main game screen we would have to the that info from the main game. Only the main game know the exact state of the game.

I would suggest that we use the System Save to send the entire state of the main game, and then use load from json in the controller to draw the state of the main game.

You could do this with the CrowdGaming plugin as it is today, but it will require some well placed events. Or we could make this into a plugin feature. So that the main game could use an action like "Update Main Game State" which would take a string (the saveStateJson), and when this is sent to the server it will broadcast it to every controller that has activated the ListenForMainGameChanges. In the controller a On Main Game State Changed condition would be triggered with a Main Game State Json, that can be use to load the game.

Your thoughts?
B
39
S
9
G
4
Posts: 163
Reputation: 6,516

Post » Thu Jul 30, 2015 10:43 pm

Yeah being able to save and load the state would be awesome. Can't wait to show you what I have made so far with the plug in. It's been a lot of fun.
B
89
S
44
G
16
Posts: 1,010
Reputation: 17,998

Post » Thu Jul 30, 2015 10:49 pm

@justifun I would love to see it! I'm too tired right now though. Not that many hours before my kids will wake me up, I will try to turn on skype once in awhile to see if you're there :)
B
39
S
9
G
4
Posts: 163
Reputation: 6,516

Post » Sat Aug 01, 2015 9:35 am

@OneMuppet

good idea.

I don't have any specific requirement, I just wonder if this was possible, cause it may be veryusefull to have multiple game screen
Actually, i found free server where you can host nodejs server : https://www.heroku.com/home
I didn't try it by now...

so i just wander if it was possible to have a game hosted on the web, and multiple players playing on multiple computers and devices. My idea was a Menu at start when you connect the URL, where you choose if your device is a screen game or a controller for a new player.
B
6
S
1
Posts: 25
Reputation: 450

Post » Mon Aug 03, 2015 2:42 am

@OneMuppet


There's some new progress on the "getting your local IP address" front

Thanks to @noncentz705 in a different thread, a much simpler cleaner solution has been provided.

https://dl.dropboxusercontent.com/u/139 ... tIPc2.capx

Image

Old messy method:

I made a tiny exe file that gets the local IP of your machine, then adds it to a txt file and stores it in the same location as where you ran it from.

So. Copy the GetIP.exe file i've included and put it in the same folder as your exported NW.JS project .exe file (https://dl.dropboxusercontent.com/u/403350/LocalIP/GetIP.exe)

Then checkout the capx i've included to see how to execute and read the IP into your project.

Now you can tell the controller players which IP to connect to once the main game window starts!

Edit: Also, if you are Testing using NW.JS for previewing, put the GetIP.exe also in your C:\Program Files\NWjsForC2\win32 folder

Capx: https://dl.dropboxusercontent.com/u/403350/LocalIP/WorkingMakeIPaddress.capx

Image

Image
B
89
S
44
G
16
Posts: 1,010
Reputation: 17,998

Post » Mon Aug 03, 2015 9:47 pm

@justifun. Great!! That's awesome! I'll check this out tomorrow! Thanks for sharing! :)
B
39
S
9
G
4
Posts: 163
Reputation: 6,516

PreviousNext

Return to Tools and Resources

Who is online

Users browsing this forum: No registered users and 1 guest