This forum is read only and just serves as an archive. If you
have any questions, please post them on github.com/phoboslab/impact
Hello,
I am trying to create a basic multiplayer game but am stuck at one of the first hurdles. The problem being that the game doesn't show up when visiting the URL with the server running. Google Chrome's Console prints out the following message...
Resource interpreted as Script but transferred with MIME type text/html: "http://localhost:8080/lib/impact/impact.js". localhost/:27
Resource interpreted as Script but transferred with MIME type text/html: "http://localhost:8080/lib/game/main.js". localhost/:28
Uncaught SyntaxError: Unexpected token < impact.js:1
Uncaught SyntaxError: Unexpected token <
index.html:
https://gist.github.com/anonymous/da97346a4ac0253655ca
app.js (server):
https://gist.github.com/anonymous/43bb49fcc0070cadac3b
player.js (emits position to server):
https://gist.github.com/anonymous/ffca57e9669655000e93
I have browsed the web and nothing that I have found has fixed the problem. I hope someone here can help me out please. Thanks! :-)
1 decade ago
by Joncom
What is the URL you are attempting to view?
What web server are you running?
Are you able to get a vanilla copy of Impact running?
URL I am trying to access is "
http://localhost:8080"
The web server I am using is XAMPP.
Vanilla impact works when the server code from player.js is removed.
1 decade ago
by Joncom
Can you show specifically what code you remove to get it working again?
The multiplayer never works but to get the game showing up I need to remove the "emit" code from the player and then remove the server code from the index too. Then it works, when I visit the "
http://localhost/" URL.
1 decade ago
by Joncom
Maybe try adding back the "server code from the index", but leave out the player "emits" code. If you still get that error, this will let you know it's likely not your emits.
Are there any other errors?
From what I know the emit doesn't even get called as the game doesn't show on screen. I think but am not sure that the impact game files in the index are being passed through as text/html instead of JavaScript. I may be wrong but know no way of fixing the problems that the chrome console output.
1 decade ago
by Joncom
That is not the problem. It says "Resource interpreted as Script", therefore even though it's being sent as text/html, it's being treated as if it was sent as JavaScript.
1 decade ago
by Joncom
Do you use version control, like Git?
Can you show a diff of the working and non-working versions of your app?
Or, would you mind sharing two .zip's, one containing the working game.
And the other containing the broken game?
(If you do this, make sure not to include the licensed Impact files.)
Non-working:
http://uploadir.com/uploads/h6f7dzch/downloads/new
Working:
http://uploadir.com/uploads/mxgj4ov5/downloads/new
Difference: One has node and socket.io installed, the other has all that server junk removed.
1 decade ago
by Joncom
The "working" version didn't run because there was a bad curly brace on line 53.
However, the "non-working" version on the other hand worked fine.
Game ran. No errors. Weird?
Did you use the server? E.g. Instead of just going to localhost you went to localhost:8080 with the server running?
1 decade ago
by Joncom
Your Node web server is only configured to serve index.html.
This means that both of these:
localhost:8080/AndreasElia/lib/impact/impact.js
localhost:8080/AndreasElia/lib/game/main.js
point to index.html and not the JavaScript files you intended.
Try running index from XAMPP and you'll find it works.
I tried the URL:
http://localhost:8080/index.html
Instead of just:
http://localhost:8080/
The problem still goes on.
That shows the game but throws an error and freezes due to their being server code in the player class when there is no server running.
1 decade ago
by Joncom
So then make sure the server is running via the command node app
.
XAMPP and Node can both be running at the same time you know...
I run the "server" file that runs the following command:
e:\xampp\htdocs\node app.js
That runs the same as "node app" right?
1 decade ago
by Joncom
If you game resides in e:\xampp\htdocs\
, then yes, right.
Yes it does. Been playing with the code on and off with different solutions and nothing had worked as of yet.
1 decade ago
by Joncom
Run the copy found in the .zip called non-working, which you sent me.
1. Make sure XAMPP is running, because you're going to run the game client from it.
2. Start the Node server, because the client will need to communicate with it. While running, "the command prompt it is running in" should be non-usable (ie. cannot type anything).
3. Load
http://localhost/ in Chrome.
Now, your game should either be working, or show an error. The error may be in the command prompt where you're running Node. Or it may be in Chrome console.
Something has to happen...
Doing that sort of worked... I get the following error...
GET
http://localhost:8080/socket.io/?EIO=2&transport=polling&t=1402164780293-6 net::ERR_CONNECTION_REFUSED
I think the "emit" code in the player might be causing it as the same error appears in the chrome console every 1 second. The timer in the player emits every 1 second too.
Sorry for the double reply, it seems to have fixed itself and now I am not receiving any problems and the players X and Y are being sent to the server. I can not thank you enough Joncom... I was on the edge of going crazy haha.
1 decade ago
by Joncom
You're most welcome.
Good thing you didn't go crazy. :)
Page 1 of 1
« first
« previous
next ›
last »