m-byte918 / MultiOgarII

A continued version of the original MultiOgar, an open source Ogar server implementation written with Node.js.
Apache License 2.0
126 stars 131 forks source link

Scaling calculating Formula #954

Closed Gamedevolop closed 7 years ago

Gamedevolop commented 7 years ago

Scaling calculating Formula

Hi, everyone, I'm new to JavaScrip and to Github and I'm not sure if this is the right place to ask questions, forgive me if is the wrong place.

I'm learning JavaScript but I'm still new I went thru the code of your files many times but I still cant to get to understand the code formula that involves the (scaling or zoom) as there is a lot of things going on for a beginner like me. would one of you good hearts try to explain me in simple words and numbers, how do you calculate the (scaling or zooming) the one that scales up and down when you get bigger or smaller or when you split etc.... not the zoom that you zooming with the mouse. I'm only familiar with Polar coordinates & Cartesian coordinates. not vectors yet. I Would be really grateful if you please can explain me step by step how is done and what is the math involve. basically the formula for that. I don't need that you write the whole code, just a simple explanation to get familiar so I can understand how is calculate then from there I can understand and interpret the JavaScrip code. will be sufficient for an Example like: -On Split calculate this Mass from here -Then calculate how many cells the player has -Then the calculate the position x,y etc.... and multiply this by that -How much are the Min Values and all that staff

Thank you very in advance

pabloalber84 commented 7 years ago

The zoom is part of the client (Client sided), is the result of calculating the canvas size cell's size / cell's divisions. The calculating from the mass, are: If you like to convert size to mass, do it this formula: `(size size / 100) And if you want mass to size: Math.sqrt(mass * 100); Are simple's formulas from math's advance. The calculate how many cell the player has, don't need formula, simple use the sub function from arrays/objects/strings javascript.lenght, you can calculate from the PlayerTracker.js, with the variablethis.cells(From PlayerTracker, this are to declare variables own from one script), example, you can see with the command in consoleplayerlist`, this show the number of cells. The positions get's depend's of the borders XXYY (X1: Top left, X2: Top right, Y1: Buttom left, Y2: Buttom right), you can see in the code. The min values you can see in gameserver.ini

Gamedevolop commented 7 years ago

@pabloalber84 Thank you so much for your time, I really appreciate your help, this info that you game it is really valuable and it answers many other questions too, but I'm still in doubt in a few questions if you don't mind. because I'm still new to the servers and clients I don't really understand what is what yet, but I'm studying it. I think it will be easier for me first to understand like if I was going to recreate the game without any server or client, just as if I was developing this game to upload it and play on the web directly if this makes sense for you. And if is possible so I don't complicate myself I will just be trying to understand for now the Scaling that gets triggered by example: -the player gets bigger or smaller -splits -I think but I'm, not 100% sure if any cell gets further away the scale it gets triggered too -And anything that I may have missed to trigger the scale

But not the zoom that we zoom with the middle mouse button up and down, that's why is confusing. So for what I understood till now and for what you said: The canvas is I think 1920, 1080 if I'm not mistaking cell's size: is the total size or Mass of each cell of the player?? cell's divisions is the total of how many cells are in split right??

So will be: (1920 + 1080) * cell's size / cell's divisions = the layout scale Ratio I'm right?? is it that simple the math formula for the scaling?? because I been reading the files for weeks and I saw it gets pretty complicate and is triggered in many places. forgive me my clueless I'm such a big nob,

AlexHGaming commented 7 years ago

I'm such a big nob Alright then.

pabloalber84 commented 7 years ago

The splits, player get's bigger or smaller, etc, are by entity and physics. The zoom is from the client, in every custom client sides, the zoom are between 0.9 ... >. Yeah, but, 1920x1080 of VIEW canvas, this can be incrase. Cell size, is the individual cell size from one player, one player (with the default configuration from FFA gamemode) can split 16 times, when the player have 1 cell (All cell in one) and split, the 1 cell divides half of the mass and lost % of mass (like 0.1%, etc), and if the player splits with this 2 cells, the two cells divide (Get 4 cells in total) and every cell have the same half of the mass from original cell that expels him. Yes, depend so much the scale config, you can check in PlayerTracker, function getScale() and the config from gameserver.ini config serverSpectatorScale, all of this send to user with packet viewnodes (To see good scale from one player and depend's from view scale) and updateposition (To see correct own scale).

I'm such a big nob

:V

Gamedevolop commented 7 years ago

Ha ok so it was more simple than I thought the Scaling, I was getting really confused between the ones you mention (PlayerTracker, function getScale() , gameserver.ini config serverSpectatorScale) and these ones in CODE LINE: 202 // update viewbox https://github.com/Megabyte918/MultiOgar-Edited/blob/master/src/PlayerTracker.js

from Line 205 // update viewbox for players https://github.com/Megabyte918/MultiOgar-Edited/blob/master/src/GameServer.js

Code line 305 updateSpecView: https://github.com/Megabyte918/MultiOgar-Edited/blob/master/src/PlayerTracker.js

So for what you are saying to calculate the scales is base on the size of the player and how many cells he has? that's it? And I was wrong to think that the distances between the player own cells affect the scaling swell, Example: I'm a big fun of agario I played it a lot and I noticed that when lets say you have two cells one with 1000 size and the other one just 65 obviously the one with 65 size is much faster than the 1000 size so the smallest size it travels far far away from the big one and the further it travels the more you can see from the map so meaning that affects the scaling swell to zoom out, and I didn't see any settings for this maybe I was wrong?

Just to finally fully understand the whole logic behind the calculation of the scale, can I represent it with one example? will be much easier for me to fully understand the whole process and from there I can fully understand the JavaScript code. I know you guys are extremely busy and working really hard and I'm sorry to ask many questions but I been many weeks reading those JavaScript confusing myself, I would be really really grateful if you have some spear time to help me understand this scaling math because I know if I understand that I will be able to interpret the other JavaScript Code. especially I get confused with things like (this.cells.length) still not sure if it refers to the cell size, or how many cells, or is for a single cell or multiple etc... you know what I mean. I see (.length) mentioned quite a lot.

So here is one Example: Imagen I'm the player and that I split myself in (8 cells) of (200 size) for each cell, so then will be according to Function Function: PlayerTracker.prototype.getScale = function() { this._score = 0; // reset to not cause bugs with leaderboard var scale = 0; // reset to not cause bugs with viewbox for (var i = 0; i < this.cells.length; i++) { scale += this.cells[i]._size; this._score += this.cells[i]._mass; } if (!scale) return scale = this._score = 0; // reset else return this._scale = Math.pow(Math.min(64 / scale, 1), 0.4); https://github.com/Megabyte918/MultiOgar-Edited/blob/master/src/PlayerTracker.js

This is my view to resolve the problem: i = 7 scale + 7 this._score += this.cells[i]._mass; =>>>>>>>>> 0 + 7???? if return scale is not = this._score = the reset this._score to 0 else return this._scale = Math.pow(Math.min(64 / scale, 1), 0.4);

is correct?? did I miss anything more to calculate??? distances between the same cells maybe?? please help thank you so much for your help @pabloalber84 and for your time you are really are an awesome guy please be patient with me :) :)

pabloalber84 commented 7 years ago

@Gamedevolop Math.pow(Math.min(64 / TOTALMASS, 1), 0.4);

Gamedevolop commented 7 years ago

Thanks @pabloalber84
Math.pow(Math.min(64 / TOTALMASS, 1), 0.4); This is one part of the formula but I can't see where it gets divided by / cell's divisions. like you mention on the first post (canvas size * cell's size / cell's divisions) so it must be another formula that I missed, to combine them together right?? do you speak spanish? for the name it looks like from Spain

Shair17 commented 7 years ago

Si al parecer si habla español :V

Gamedevolop commented 7 years ago

@Wair1o17 Esos paisanos mios :) como estais colegas, si la verdad es que lla se notaba ese buen corazon spanol de la manera que me ha alludado y la paciencia que a tenido pabloalber84, con toda la charla que le he pegao y la pedazo olla que le echo estara el pobre hecho un flan jeje, pues nada queria decirle que deberdad se lo agradezco de corazon la alluda que me esta dando, es muy buena gente. i de paso queria explicar en lo que estaba interesado esque esto se a liado tanto por mi culpa que seguro que estan pensando que estoy flipao jeje. Pero la verdad me a venido bien por que he aprendido otras informaciones muy buenas que necesitava para saber mas como funciona el JavaScript i asi enetender mas los codes que teneis en este projecto. Yo la verdad esque estaba interesado en todo lo relacionado a como funciona la resolucion the pantalla cundo se expande o contrae que hace que pudas ver mas partes del mapa, i por lo que he visto esta relacinado con, si no me equivoco con la (Masa, en cuantas celulas esta split y creo que tambien la distacia entre tus celulas) eso es lo que le intentava explicar aqui a Pablo, pero alomejor yo estaba equibocado y por eso le decia que me corrigiera por favor. Entonces para ir directo al grano i no daros la tabarra mas, esto lo que he entendido asta ahora. La resolucion o (Scaling) se basa en dos partes:

1-La Primera parte -Esta formula yo creo que es para cuando no esta en split: else return this._scale = Math.pow(Math.min(64 / scale, 1), 0.4);

2-La Segunda parte- cuando esta en split, que se basa en?? esa es la cuestion, i me gustaria saber la formula para esta parte tambien si es posible. I por lo que he visto asta ahora en esta parte la formula para calcular el scaling se basa en (alguna Masa, cuantas celulas tienes) y tambien lo que le estaba explicando esque cuando alguna de tus celulas se va demasiado lejos the las otras el scaling se activa y la pantalla se expande para poder ver todas tus celulas, porque si no la celula se perderia por una de las vandas y no la verias mas.

En conclusion necesito la segunda parte de la formula para lla entender como funciona todo relacionado al escaling o zoom como lo quieran llamar. Veis la formula que me haveis dado para calcular la primera parte pues algo asi pero para la segunda parte cuando esta en split, y llo lla lo entenderia perfectamente. Y muchisimas gracias por toda la ayuda i perdonad porrr la taladrada!!

pabloalber84 commented 7 years ago

Te explico simplemente: else return this._scale = Math.pow(Math.min(64 / scale, 1), 0.4); el "scale" que esta en Math.min(64 / scale, 1), se dice que es la suma de todas las masas de todas las celulas, es decir, si esta el jugador esta en 1 (no dividido), no importa, siempre dara esa formula porque scale es la suma de todas las masas de las celulas de un mismo jugador, si te fijaste, arriba hay un loop, que hace que la variable "scale" se le sumen todas las masas de todas las celulas, una por una, aqui va la respuesta a tu segunda pregunta, scale es la suma de todas las masas de todas las celulas que este dividido un jugador, todas se suman y hacen que tenga su rol en la variable scale, dando masa total, dividido o no dividido, entiendes?

Gamedevolop commented 7 years ago

@pabloalber84 Muchas Gracias Pablo por la explicacion y por tu paciencia, pero la verdad es que yo lla entendi como funciona esta formula, pero lo que te intentaba explicar es que tiene que haver otra cosa mas que influencie el (scale) aparte de esa formula. Yo creo que es mejor que te lo demuestre con fotos asi me entenderas mejor lo que te quiero decir. I para demostrartelo voy a seguir la formula que me as dado i asi podras ver con mas claridad que ami no me salen los calculos siguiendo solo esa formula. Para medir los calculos voy a utilizar los cuadros del grid de agario jugando desde mi telefono i va asi: w = cuantos cudrados hay horizontal H = cuantos cuadrados hay vertical Entonces si la formula que utilizais se basa en el (Masa Total de todas las celulas) lla sea en split o no split, entonces mi experimento tendria que dar el mismo resultado de cuadros ya sea que estoy split o no estoy split. Hojo i para esto he utilizado la misma Masa antes del split y despues del split para que sea mas exacto, he hecho cuatro experimentos para demostrarte con Masa 116, 117, 149 i 1817 i las verdad es que hay una gran diferencia, por ejenplo en el de 149 Mass la difrencia es de (4 cuadrados with) i (2 high) entre el no split i el si split, entonces porque hay esta gran diferencia no lo entiendo?

Test 1 Mass 116:

Mass 116 no split :

w 36 h 19

Mass 116 is split:

w 38 H 21 & half

=================================================================== Test 2 Mass 117:

Mass 117 NO Split:

w 36 H 19

Mass 117 is split:

w38 h21

=================================================================== Test 3 Mass 149:

Mass 149 no split:

W 38 H 20

Mass 149 is split:

W 42 H 22

Test 4 Mass 1817

Mass 1817 no split

W 62 H 35

Mass 1817 is split

W 70 H 38 & half

Gamedevolop commented 7 years ago

perdona por las letras grandes es que se an puesto en automatico no lo puedo cambiar, no funcionara bien

pabloalber84 commented 7 years ago

@Gamedevolop Solo una cosa, client side, el cliente tiene que ver mucho en eso, el cliente calcula esos movimientos, no te puedo explicar porque depende del mismo.

Gamedevolop commented 7 years ago

@pabloalber84 Haa vale vale eso era lo que causaba el mal entendido ahora lla lo entiendo jeje, bueno la verdad es que me alegro que halla pasado por que he aprendido otras cosas buenas. Y lla la ultima cosa para terminar i no darte la tabarra mas deverdad lla paro, que lla te tengo loco, Yo tambien estuve aprendiendo JavaScript de este proyecto que se llama (Cigar) que parece ser que es de vosotros tambien y me he fijado que es (client side) entonces el code de esta seria la respuesta a la segunda parte a mi pregunta?? I si la respuesta es si, te importaria alludarme a analizar un poco el code como tu as echo en los mensages anteriores que he aprendido bastante? la verdada es que me ayudarias muchisimo y te estaria eternamente agradecido, sobre todo los loops que es lo que me cuesta mas de entender. Con ejemplos obios i tontos como (la masa total de todas las celulas, o la masa total de la celula mas grande) lla sabes como si llo fuese un tontin :) i no hay prisa aunque se aga poco a poco i cuando tu encuentres timpo libre, yo estoy contento con lo que sea. Muchisimas gracias por toda tu ayuda,

el code se encuentra from line: 715 of this project file https://github.com/CigarProject/Cigar/blob/master/www/assets/js/main_out.js

function canvasResize() { window.scrollTo(0, 0); canvasWidth = wHandle.innerWidth; canvasHeight = wHandle.innerHeight; nCanvas.width = canvasWidth; nCanvas.height = canvasHeight; drawGameScene() }

function viewRange() {
    var ratio;
    ratio = Math.max(canvasHeight / 1080, canvasWidth / 1920);
    return ratio * zoom;
}

function calcViewZoom() {
    if (0 != playerCells.length) {
        for (var newViewZoom = 0, i = 0; i < playerCells.length; i++) newViewZoom += playerCells[i].size;
        newViewZoom = Math.pow(Math.min(64 / newViewZoom, 1), .4) * viewRange();
        viewZoom = (9 * viewZoom + newViewZoom) / 10;
    }
}

function drawGameScene() {
    var a, oldtime = Date.now();
    ++cb;
    timestamp = oldtime;
    if (0 < playerCells.length) {
        calcViewZoom();
        var c = a = 0;
        for (var d = 0; d < playerCells.length; d++) {
            playerCells[d].updatePos();
            a += playerCells[d].x / playerCells.length;
            c += playerCells[d].y / playerCells.length;
        }
        posX = a;
        posY = c;
        posSize = viewZoom;
        nodeX = (nodeX + a) / 2;
        nodeY = (nodeY + c) / 2
    } else {
        nodeX = (29 * nodeX + posX) / 30;
        nodeY = (29 * nodeY + posY) / 30;
        viewZoom = (9 * viewZoom + posSize * viewRange()) / 10;
    }
pabloalber84 commented 7 years ago

@Gamedevolop si, en la parte aritmetica si. Cigar no es de MultiOgar, sin embargo, Cigar usa protocolo 5, aceptable para MultiOgar.

Gamedevolop commented 7 years ago

@pabloalber84 Ha vale perfecto, muchas gracias colega, entonces si que me vale solo tengo que entender el code, Me ayudarias a analizar el codigo para entenderlo?? aunque sea por encima rapido

fayizan commented 7 years ago

It would be awesome if this convo continue with english : |

Sent from my Xiaomi Redmi 3S using FastHub

Gamedevolop commented 7 years ago

sure @fayizan I apologize for that, is true will be nice to speak in English so other people interested in this can benefit from it swell, I just had to switch to Spanish because it was a misunderstanding so thought it will easier to explain it in Spanish to clarify the doubt.

I will briefly translate what happened in the Spanish conversation: as you can see from the English conversation pabloalber84 wich have been really helpful and kind awesome guy, he was trying to explain me that the scale formula is calculated with (this._scale = Math.pow(Math.min(64 / (scale= Total Mass of all the cells), 1), 0.4); ) So I was confused because on my tests Every time I split the screen expanded so you are able to see more of the map, meaning that the scaling is not only calculated from the total Mass it was something else affecting the calculation like (Total Mass + something else) so then I had to show him by pictures what I meant, then pabloalber84 realise what I was referring too, so he explained me that they are a (server) and their scale calculation is with that formula (this._scale = Math.pow(Math.min(64 / (scale= Total Mass of all the cells), 1), 0.4); ) but this formula it gets affected by the Results from the (client side) so I understood too. So then I asked him, this project (CigarProject) is a (client side) and has this code referring to the scaling, is this the missing part to understand the whole formula for the scaling? so he kindly said yes, the last thing I asked him if he please can help me to understand some of that code as I'm new to JavaScript, as I wanna learn the whole process to calculate the scaling so I can learn to interpret the JavasScript better.

And last if you wanna understand the Test pictures that I post, is easy I calculate the scale by counting the grid squares w= horizontal & H = vertically so to show the difference I did the same (Total Mass) before the split and after the split, and as you can see they differ on the Scale Ratio even if they have the exactly Total Mass before and after the split. wich means the scaling is calculated by (Total Mass + something else) that >> (something else) is what I'm trying to find out with the help of pabloalber84, If you have any ideas of what can it be, please share them with us will be really helpful.

pabloalber84 commented 7 years ago

@Gamedevolop yo estoy ocupado casi todo los días con mis propios proyectos.... estudia el código, y verifica para que sirve cada función, así te darás cuenta para que sirve cada cosa.

Gamedevolop commented 7 years ago

No problem @pabloalber84 I understand, you have been really helpful and you contributed quite a lot already to this post, your contribution has been such a great help. Take care, my friend espero que te valla to muy bien y deseo lo mejor muchas gracias por toda la alluda y tu tiempo cuidate.

Gamedevolop commented 7 years ago

Now, ok guys I'm on my own, so I will try to translate those lines of codes by myself and I'm only asking now is, if anyone of you guys that know the JavaScript well can give 3 seconds of your busy life to just say( "Yes" or "No") = To One button per second to my analysis meaning that if I'm wrong or not, well 4 seconds the 4 second to point with an arrow to wich line of code I will be wrong so I can correct it.

I wanna learn and I'm not lazy at all, perhaps you may had bad experience with people here before that they been lazy but I'm not and I don't mind to do the hard work and I will do, I say this because I notice in many other issues that there is that bad karma in the atmosphere like do it yourself as if everyone is lazy. And I think that's wrong because sometimes if somebody knows better one thing and comes another person asking to know that thing, why not helping him with a very short explanation saving him weeks or more of research just to understand that thing. I'm saying this just to let you know that I'm not one of those guys just for the record. This code I will understand it with your help or without, the only difference it may take longer that's all, but I'm not in hurry anyway.

Gamedevolop commented 7 years ago

So I will start from the server side to analysis the scale formula, as there is some valuable information in this post to resolve the analysis

So here is one Example: Imagen I'm the player and that I split myself in (8 cells) of (200 Mass) for each cell, so then will be according to Function Function: PlayerTracker.prototype.getScale = function() { this._score = 0; // reset to not cause bugs with leaderboard var scale = 0; // reset to not cause bugs with viewbox before we start the loop reset score & scale to =0

for (var i = 0; i < this. 8 cells; i++) { add 1 to scale for each cell scale += this. 8 cells._size; = 8 this._score += this. 8 cells[i]._mass; = 1600 } if (!scale) return scale = this._score = 0; // reset if scale is Grater > than 8 cells Return = (scale & score=0)

else return this._scale = Math.pow(Math.min(64 / (1600 the total Mass)

, 1), 0.4);

Is this correct guys??

plazo123 commented 7 years ago

@pabloalber84 do you have discord or skype and you know node right couase ou should get a thumbs up !!

Gamedevolop commented 7 years ago

@plazo123 is it something related to the topic? perhaps my JavaScript guessing is wrong? because I didn't understand what you trying to say

pabloalber84 commented 7 years ago

@Gamedevolop Where you get the "8" xdddd. @plazo123 I don't have none of the above, im scripter independent.

Gamedevolop commented 7 years ago

@pabloalber84 I know right?? Snow White and the Seven Dwarfs following everywhere man jejeje I don't know what is the point for the loop I may just swell put the 8 directly in Math.pow(Math.min(64 / 8, 1), 0.4); and done, totally wrong it couldn't be more wrong, but I think I'm nearly there :) I will be back soon!! they say the third one is the good one let's see if is true

pabloalber84 commented 7 years ago

@Gamedevolop Can't be 8, because the cells can be more of 8, like 16, etc.

Gamedevolop commented 7 years ago

@pabloalber84 Haa I see what you mean now :) sorry I didn't get you yesterday, I thought you were referring that I put the (quantity 8) every where lol de alli venia lo de blancanieves i los siete enanitos, Thanks a lot for the info though. pabloalber84 The idea of the (quantity 8) is coming from that I tried to do the analysis with a real in game example to make sure that I understood everything 100%, it will stick quicker on my brain jeje. The idea of the example was that: before the loop started, the current situation of the game will be like if I had ( 8 cells and Each cell with the size of 200) = to (Total size 1600) of all the cells combined. But even giving this example I was totally wrong because it should be the comparison against ( 7) as the counting starts from 0 up. But I do understand your point wich is the correct one, wich is at the time the loop triggers it compares against the (current total number of cells) at that time and this value can be any number from (0 up to 16) wich is the Max cells that the player can have. In any case thanks for spotting it on and the clarification as it may have caused confusion to someone else that didn't realize that I was analyzing with a specific example in this case.

pabloalber84 commented 7 years ago

@Gamedevolop Dilo en español :B que ya me dio flojera el ingles

Gamedevolop commented 7 years ago

Ok I think I got it right now, I hope!!! :)

And I'm gonna use a specific example to analyze this Function. The Example will be that: before the loop started, the current situation of the game will be like if I had ( 8 cells and Each cell with the size of 200) = to (Total size 1600) of all the cells combined.

//PLAYER TRACKER .JS

    PlayerTracker.prototype.getScale = function() {
       this._score = 0; //  declaring variable
        var scale = 0; // declaring variable
        for (var i = 0; i < this.cells.length; i++) {  //  gets the number of cells when it uses the .length method 

//it uses for loop so it will add up the value of the size of the cell ( this.cells[i]_size) to the scale //so after the for loop you will get the scale variable with the value of all added sizes of the cell. //Same case for adding of score //The questions arize her that got me very confuse, why you need the this._score here if you just use the value from the scale to calculate (else return this._scale) ?? my guess is that you may use this function in other places for calculating the score wich is the same as the Mass, I have no idea yet, I have to investigate more scale += this.cells[i=1600]._size; this._score += this.cells[i= 25, 600]._mass; } if (!scale) return scale = this._score = 0; // reset >> //not sure yet what it means coming soon....... else return this._scale = Math.pow(Math.min(64 / (1600), 1), 0.4); };

Two things to conclud this analisys:

1-what is the perpese of the (this._score) in this function.

2- what it means>>>>if (!scale) return scale = this._score = 0; // reset >>>>> If not what?? this one still doesnt make sence for me, the normal idea will be >>> if for (var i = 0; i < this.cells.length; i++) >>>>is not true meaning the only way is not true is if the player die or is in not split then Reset 0 haaaaah this one is hard one :)

Gamedevolop commented 7 years ago

@pabloalber84 jeje te entiendo perfectament, la verdad es que va bien escuchar nuestra lengua materna de vez encuando para refrescar. Aqui esta mini Resumen: Que ayer no te entendi bien i pensaba que te referias a que he puesto el (8) en todas las lineas the codigo i me hizo gracia por que era verdad, como aquello de 8 for ever. Y hoy as clarificado mas diciendo que pede aber mas de 8 celulas asta 16, Y entonces he entendido lo que querias decir aller que te referias a otra cosa, i te he dado las gracias por aber cazado ese fallo por que ubiese podido causar mal entendido ami o a otra persona que lea este analisis. I al mismo tiempo te decia que el 8 venia de que estaba aziendo el analisis con un ejemplo real como si antes de que empezace el loop yo tendria en ese momento (8 celulas con una size de 200 por cada celula). pero aun asi que tu tenias razon que tu forma es la correcta de ver las cosas asi nadie se podria confundir con mis ejemplos, I entonce en mi ultimo analisis he cambiado el 8 con una nota (// gets the number of cells when it uses the .length method ) para que este todo mas claro. I lla para terminar te agradezco que te allas fijado en ese detalle i corregirme por que en verdad podria haber estado siguiendo ese mal ejemplo, I a sido un bonito detalle por tu parte

pabloalber84 commented 7 years ago

@Gamedevolop Ok, las celulas pueden ser mas de 16 recuerda, ya que pueden variar segun los splits, y la configuración de playerMaxCells que tenga gameserver.ini (playerMaxCells va a ser la maxima, pero es mejor ponerla con ese loop que viste seguro en el codigo, ya que asi pasa solo por las celulas existentes, y no por todas aunque esten vacias.)

Gamedevolop commented 7 years ago

@pabloalber84 Creo que me he perdido un poco, yo pensaba que 16 era el maximo que un jugador puede dividirse. I lo otro si es que te he entendido bien, te refieres a que si utilizo este loop for (var i = 0; i < this.cells.length; i++) {es mas seguro por que solo pasa por las celulas existentes y no por todas las que dice en (playerMaxCells)

pabloalber84 commented 7 years ago

@Gamedevolop mira te explico, por default, es decir, por defecto, esta configurado que el maximo de celulas a los que un jugador puede dividirse, es de 16 celulas al mismo tiempo, por eso pensaste que 16, pero se pueden configurar mas con la configuracion de playerMaxCells en gameserver.ini. Para lo del loop, em un poco bien, pero te complementare: Si, pasa solo por las celulas existentes, pero ese loop solo puede llegar a un maximo de playerMaxCells que te dije anteriormente, es por eso que tienen similitud, y si un jugador tiene mas de lo establecido, seria un error de codigo.

Gamedevolop commented 7 years ago

@pabloalber84 creo que ahora te entendido mejor lo que todabia no entiendo bien la parte de que parece que estas comparando dos loops diferentes por eso dices( tienen similitud) pero yo solo conozco el loop que te puesto en el mensage anterior todabia no se cual es el segundo loop a que te referies para comparar los, i perdona mi ignorancia, I muchisimas gracias por toda tu ayuda

pabloalber84 commented 7 years ago

No hay segundo loop a lo que te dije, sigue siendo lo mismo, te estoy diciendo el porque tiene que ver la configuración playerMaxCells con el loop y el array de las celulas.

Gamedevolop commented 7 years ago

@pabloalber84 Haaa vale vale amigo jaja si ya te he dicho que soy un gran novato, muchisimas gracias por toda la ayuda i los todos los consejos buenos he aprendido muchisimo, an sido the gran ayuda. la verdad es que sin tu ayuda no ubiese podido analizar este loop i entenderla, por cierto el ultimo analisis que he echo esta todo bien?? los numeros y los calculos, esque si se que esta bien asi podria empezar analizar la segunda parte con lo que he aprendido del primer loop analisis y lla acabar con todo, para que lla puedan cerran o hacer lo que tengan que hacer con este post, que no quiero alargarlo mas de lo necesario para que nadie se queje :)

pabloalber84 commented 7 years ago

@Gamedevolop nose de que analisis hablas... Te recomiendo que ejecutes el "pruebas y errores", todos empezamos asi, aprendiendo a usar, tanto de buenas o mala manera, probando codigo, y solucionando los errores que se aparezcan. Te recomiendo por ejemplo, hacer console.log("Prueba"+DATOS);, donde DATOS sera algun array o etc, que quieras comprobar, o de igualmente algun valor, etc, para que lo veas en tu consola y pruebes.

Gamedevolop commented 7 years ago

@pabloalber84 Ahora si que me as matado con lo del (nose de que analisis hablas...) xdddddddd Te explico: yo con este largo post desde el principio intendaba aprender la teorica de como funciona el javaScript primero y luego al tener ya la base the como funciona pues empezar con las practicas (probar experimentar etc....) y todo eso. entonces solo necesitaba que alguien confirmase si estan bien ejecutados mis analisis con ejemplos reales, por ejemplo lo que tu mencionaste con el problema del 8, ves esa frase ya me confirmo que el primer analisis que hice en este post estaba erroneo, entonces despues de eso he echo otro analisis para rectificar, que es el post que empiza con ( Ok I think I got it right now, I hope!!! :)) pues a ese analisis me refiero, i puse todos los detalles que entendi y los que no entendi, Entonces yo creo que ya he aprendido bastante gracias ti y esa era la intencion y creo que es la hora de que cierre este post, por que ya te he dado bastante la taladrada jejeje, i no quiero abusar de tu buena fe que ya as ayudo mas que bastante. entonces seguire mis estudios en privado como tu as dicho con practicas y etc........i asi no molestar a nadie creo que sera lo mejor. :)

Gamedevolop commented 7 years ago

Hi guys I think I'm done with this post, as the purpose of the post has been accomplished Thanks to this awesome guy >>>>pabloalber84 wich has been extremely helpful, you should feel lucky to have him around here as he is very active working and helping people, really cool guy.

I don't know if you guys wanna close this post or leave it open, for me whatever you do is cool, I leave it on your hands

I quite enjoyed the Analysis and I might open another issue ticket to do another analysis for the full "PlayerTracker.js file" jejeje >>>>>>>>>>>>>>>> Nooooo Just kidding!!

Gamedevolop commented 7 years ago

@pabloalber84
Vale amigo pablo cuidate hermano, te agradezco mucho toda la ayuda y tu paciencia, sigue asi Compañero que seguro que llegas muy lejos, y un consejo para ti de corazon, cuidado que no te contagien el karma ese que hay por aqui que tu eres una muy buena persona que ayuda a la gente, i seria una lastima que perdieses eso, i te aseguro que tu llegaras mas lejos que ninguno de ellos, venga cuidate colega i te deseo lo mejor. Nos vemos por aqui asta la proxima!!

pabloalber84 commented 7 years ago

@Gamedevolop claro, de nada. Para cerrar el post puedes hacerlo tu mismo, fijate las opciones de un post issue de github.

Gamedevolop commented 7 years ago

@pabloalber84 haaa gracias ya lo vi

Gamedevolop commented 7 years ago

@pabloalber84 por casualidad sabrias como se calcula (wHandle.innerWidth;) i (wHandle.innerHeight;) sabiendo que ya tenemos una resolucion de (1920, 1080) que llevo varios dias intendando aberiguar que values poner aqui.

function canvasResize() {   | window.scrollTo(0, 0);   | canvasWidth = wHandle.innerWidth;   | canvasHeight = wHandle.innerHeight;   | nCanvas.width = canvasWidth;   | nCanvas.height = canvasHeight;   | drawGameScene()