These are chat archives for pixijs/pixi.js

8th
Jan 2016
Olav Lindekleiv
@oal
Jan 08 2016 18:22
Not entirely Pixi related, but do any of you have any good sources for doing real time games with Javascript?
I'm making some sort of 2d platformer in which the map can change fairly often, not a static level
Ivan Popelyshev
@ivanpopelyshev
Jan 08 2016 18:23
I wrote that one from scratch :)
Olav Lindekleiv
@oal
Jan 08 2016 18:24
Websockets or WebRTC?
Ivan Popelyshev
@ivanpopelyshev
Jan 08 2016 18:24
you need at least to read all 0fps.net articles on networking
websockets :)
cant find server-side webrtc implementation yet
and there was that library that is used by Scirra
i forgot which
Olav Lindekleiv
@oal
Jan 08 2016 18:24
Authoritative server with physics etc simulated on server and pushed out, and prediction on the client, or does the client handle physics etc. and push its position etc to the server?
Ivan Popelyshev
@ivanpopelyshev
Jan 08 2016 18:25
Scirra/Construct 2 has multiplayer on webrtc
if you want to do that from scratch you'll need your own buffer (or may be use google protobuf)
Olav Lindekleiv
@oal
Jan 08 2016 18:26
No, I mean what approach did you take?
Ivan Popelyshev
@ivanpopelyshev
Jan 08 2016 18:26
authoritative
*i mean i wrote that one
  • iwrote authoritative for server
but Scirra/Construct 2 uses webrtc p2p as far as i know
Olav Lindekleiv
@oal
Jan 08 2016 18:27
Is the server written in JS as well, so that the same code runs both places in your case?
Ivan Popelyshev
@ivanpopelyshev
Jan 08 2016 18:27
but I wrote everything in Java and compiled to JS, otherwise it could betoo difficult to debug
i wrote everything from scratch
I guess you can use google protobuf to build your protocol
all changes in tilemap can be server-side without predictions
Olav Lindekleiv
@oal
Jan 08 2016 18:28
Ok, I was thinking about using Go for the server. Maybe compiling parts of it with Gopher.js to handle client side prediction
Ivan Popelyshev
@ivanpopelyshev
Jan 08 2016 18:28
use predictions only for client movements
if its possible, send player state and coordinates with unreliable channel (UDP)
Olav Lindekleiv
@oal
Jan 08 2016 18:29
For prediction, do you implement collision detection on the client, or just keep moving the player with its velocity before waiting for corrections/changes from the server?
Ivan Popelyshev
@ivanpopelyshev
Jan 08 2016 18:29
evrything else must be reliable
yeah, there is collision detection on client
it runs the same code ;)
results are a bit different on server, because some objects are actually moving
*some colliders
and server verifies everything and sends coordinates back
Olav Lindekleiv
@oal
Jan 08 2016 18:31
Thanks a lot. Now I know more about where to start. :-)
Ivan Popelyshev
@ivanpopelyshev
Jan 08 2016 18:31
client has queue with stuff that werent taken into account on server yet
so that stuff is appended on top of current gamestate
and if something is wrong that stuff is re-validated , player "teleports"
if delta is small then interpolation will fix that
if not, teleport is the only way
Olav Lindekleiv
@oal
Jan 08 2016 18:32
Yep, I read some articles on Gafferongames, seems similar
Ivan Popelyshev
@ivanpopelyshev
Jan 08 2016 18:32
i hate TCP already
but its very difficult to switch to UDP if you didnt think about that in the beginning
and i dont know about webrtc servers, there are no examples AT ALL
Olav Lindekleiv
@oal
Jan 08 2016 18:33
How many players are typically in your game at a time?
Ivan Popelyshev
@ivanpopelyshev
Jan 08 2016 18:33
"yeah, sure, you can do that" - "where is the fucking example?"
50 on one map
but in extreme situations - 2000
Olav Lindekleiv
@oal
Jan 08 2016 18:34
And then you're pushing TCP over its limits, packet loss, retransmissions etc?
Ivan Popelyshev
@ivanpopelyshev
Jan 08 2016 18:34
yes
the game is perfect if there's no packetloss
Olav Lindekleiv
@oal
Jan 08 2016 18:35
I doubt there'll even be 20 players simultaneously in my game
Ivan Popelyshev
@ivanpopelyshev
Jan 08 2016 18:35
but many rooms :)
Olav Lindekleiv
@oal
Jan 08 2016 18:35
Possibly, but that could run on different hardware, so no problem
Ivan Popelyshev
@ivanpopelyshev
Jan 08 2016 18:36
www.youtube.com/watch?v=az5S9oQKXIQ - player counter is in upper-right corner :)
oh, its too big for gitter
and the only thing that was lagging was THE CHAT
Olav Lindekleiv
@oal
Jan 08 2016 18:37
Impressive. What kind of hardware / network connection does that run on?
Ivan Popelyshev
@ivanpopelyshev
Jan 08 2016 18:38
about 40-50kbit/s per client
2 or 4 core virtual machine (xeon something something)
very optimized java code
Olav Lindekleiv
@oal
Jan 08 2016 18:39
And java compiled to JS for the client?
Ivan Popelyshev
@ivanpopelyshev
Jan 08 2016 18:39
yep
but UI is angular.js
Olav Lindekleiv
@oal
Jan 08 2016 18:39
So that's why the chat is slow
... just kidding :-p
Ivan Popelyshev
@ivanpopelyshev
Jan 08 2016 18:40
yeah, chat wasnt that efficient for constant updates
they just flooded it
Olav Lindekleiv
@oal
Jan 08 2016 18:40
Impressive game, though. :-)
Ivan Popelyshev
@ivanpopelyshev
Jan 08 2016 18:41
Im moving the game to pixi now, but I'm still coding required libraries
well , from coding perspective its the best i saw in HTML5
but monetization sucks. My highscore was about 2000$ per month
Olav Lindekleiv
@oal
Jan 08 2016 18:42
Do you reimplement collision detection, prediction etc in JS too then?
Ivan Popelyshev
@ivanpopelyshev
Jan 08 2016 18:42
no, code is shared
I run 100 bots (100 client gamestates and 1 server) in one thread for a test
Olav Lindekleiv
@oal
Jan 08 2016 18:43
As for monetization of browser games, I came across this on HN a few days ago http://www.gamasutra.com/blogs/MelanieChristin/20150527/241206/
Ivan Popelyshev
@ivanpopelyshev
Jan 08 2016 18:43
my friends say that its bullshit
and I have problems because my game is too hardcore and it lacks tutorials and stuff :)
Olav Lindekleiv
@oal
Jan 08 2016 18:44
ok, I don't know. I skimmed it and found it pretty interesting regardless
Ivan Popelyshev
@ivanpopelyshev
Jan 08 2016 18:44
yep, i read it :)
about 50% of my revenue comes from Japan
Olav Lindekleiv
@oal
Jan 08 2016 18:45
Interesting. Where are you located?
Ivan Popelyshev
@ivanpopelyshev
Jan 08 2016 18:47
in Moscow, but servers are everywhere :)
Olav Lindekleiv
@oal
Jan 08 2016 18:47
ok :)
Ivan Popelyshev
@ivanpopelyshev
Jan 08 2016 18:47
I signed up for testing improbable.io (Spatial OS)
they tried to hire me but i didnt get British visa :)
they claim to have solution for all that networking stuff
based on akka.io
akka.io is good stuff for building servers, Im trying to use the same architecture in node.js in another project :)
So, what do you think you'll use?
if you dont have bullets then websockets will be best solution
or if you dont have PvP
Olav Lindekleiv
@oal
Jan 08 2016 18:51
I'll try to write the server in Go, possibly sharing some code with the client (transpile with Gopher.js)
Ivan Popelyshev
@ivanpopelyshev
Jan 08 2016 18:51
"Realm of the mad god" didnt have lag problems
yes, that's good idea
Olav Lindekleiv
@oal
Jan 08 2016 18:52
It'll mostly be character/entity movement that will happen often, other than that it shouldn't be too heavy on the networking
Ivan Popelyshev
@ivanpopelyshev
Jan 08 2016 18:52
make sure you use "entity-component" approach, like in unity and other game engines
Do you want to validate character movements on server?
Olav Lindekleiv
@oal
Jan 08 2016 18:53
Yep, I read the Gameprogrammingpatterns.com book over Christmas, learned a lot
I think I'll be sending input to the server, and broadcast that to clients
Ivan Popelyshev
@ivanpopelyshev
Jan 08 2016 18:54
if collisions are only with walls or some objects that arent controlled by human, validation is possible
Olav Lindekleiv
@oal
Jan 08 2016 18:54
With corrections, then use prediction on the client
Ivan Popelyshev
@ivanpopelyshev
Jan 08 2016 18:54
input and coordinates
Olav Lindekleiv
@oal
Jan 08 2016 18:54
Yes
Ivan Popelyshev
@ivanpopelyshev
Jan 08 2016 18:54
good
also google Tribes multiplayer engine
i dont remember the link
of course you dont need all that trash, but some concepts and naming conventions are worth it
Olav Lindekleiv
@oal
Jan 08 2016 18:58
Thanks, I'll check them out
Ivan Popelyshev
@ivanpopelyshev
Jan 08 2016 18:59
yep, ghosts!
ghosts are awesome concept
Olav Lindekleiv
@oal
Jan 08 2016 19:00
Thanks so much for the chat. I'll head over and do some reading now. :+1:
Ivan Popelyshev
@ivanpopelyshev
Jan 08 2016 20:56
So many trivial threads in the forum