Closed ghost closed 7 years ago
Only send part of the map
maybe 1.5x screen area and keep fetching on every move
it fetches the screen every move you do, i need to look into sending certain portions of the screen, the current fetch system sends it like every block is claimed (it returns the unclaimed color)
Is this running on an ssd? You seem to be doing a lot of disk writes...
And canvas is probably faster than DOM? (or at least better for what you're doing)
never thought of using canvas. The system is using an HDD, but i am planning to use a ramdisk that is constantly restoring to the HDD, because, if the system goes down, i dont think loosing like 5 blocks is a big issue
i havent really learned canvas, soooo... ill attempt on a seperate page (probably territory.cf/canvas-beta.html)
issue partially solved: the game now completely draws using canvas
the only issue is sync speed
maybe just sustain a socket and send the initial map ex:
xxxxxx xxxx
xx xxxxx
xx xx xxxxxxx
x
then send messages of the form: [color, x-coordinate, y-coordinate]
and the client can do the computing
how would i do sockets? i have only worked with synchronous get requests lol
Idk in php; Node makes it easier because you can handle requests in a more low-level way (and use socket.io)
I think I'll use node for the map and movement system, but the initial game startup will use php to get the coordinates and other data values. I can't program at the moment so I'll do it sometime soon
I can PR
Ok I have the http server and stuff set up and I probably will need to rewrite most of territory.js lol
socket.io is cool
Rewriting the engine would make it very hard for me to make modifications. Thanks for the help, but I don't know what I would do because I don't know much about node,
you'll see
If you do a PR, I might use parts of the video but not all of it, I will definitely be switching to sockets, is it posible with python?
video?
Socket.io is cool because it is event-driven ex on server:
io.on('connection', function(socket) {
// socket is individual connection
// when client does io.emit('hi', [data is optional])
socket.on('hi', function(data) {
// io.emit sends message to all connected clients
io.emit('hello', socket.id)
})
})
the code i would need most is it to tell the server "Hey! im playing the game!" and whenever it asks for the map/moves itll return the info. Dont worry about rewriting the map reciever, i might just leave that up to Python or some function ill rewrite
But thats still kinda slower
I would have the server do io.emit('+', {x: [x], y: [y]})
so the client can do it and its only a few bytes being sent on a move (but send the whole map when starting the game)
wouldn't that send it to all the players?
The client can only send to the server (for security reasons and technical ones)
So the client would say "hey server I wanna move here" "ok mr. dr. sir" "everyone, in your records make [x, y] [color]" "Ok server" "Ok server"
im going to mess with socket.io a little for myself to try some things :)
ok ;) but I already have some stuff done ok
waaiiittt. wat port will i need to open on mai server
You can choose. if linux/mac, do export PORT=[port]
im just wondering, why are you rewriting basiclly the entire game? it kinda seems like you are taking over almost all of it
If you used the express boilerplate, edit bin/www and change 3000 to whatever (put using the command thing will override)
Because it's fun and I need practice lol
i just used npm install socket.io soooo
I never can come up with ideas and I was bored and this looked kinda sad (no offence)... So i decided... Why not rewrite something existing...
https://socket.io/get-started/chat/ look through this
im kinda loosing control of the project it seems...
How? It's just a fork, and I can't modify this repo :P
i know, ill probably use some but not all of the code, ill probably add some changes to it too when you publish it
on another thing, i think im going to leave PHP up to the inital map and variable sending when you first join the game, and then let socket.io take over most of it after that
Kind of weird but ok...
it doenst make it so we have to rewrite a bunch so it saves time
But wouldn't it make more sense to just hold everything in a multidimensional array anyways?
oh well
So so far what do you have written
Well the web server, have socket.io up, and am working on a mechanism to send the map
im getting a little better at it. looked at some of your code, took some code for returning resources (css), and currently it returns the coords of whatever i tell the server to when you start. now to have it restore sessions...
ok cool
currently i have it to save sessions... now... for... the....impossible...part..... maps
yep. im looking at a way to make the backend send a more compressed map of claims, it could also be that stuff is done synchronously for http requests, i need help with fixing that :/