sam-ac-dixon / mayhem

0 stars 0 forks source link

Decide upon contract from server to client #14

Open Alex3k opened 8 years ago

Alex3k commented 8 years ago

Thoughts? x = position.x y = position.y a = angle in degrees


{ 
  players: [{
    id: "abc",
    x: 0,
    y: 0,
    a: 0
  },
  {
    id: "def",
    x: 0,
    y: 0,
    a: 0
  }],
  bullets:[{
    x: 0,
    y: 0,
    a: 0
  },
  {
    x: 0,
    y: 0,
    a: 0
  }]
}
sam-ac-dixon commented 8 years ago

@Alex3k - it's a good starting point. Only one thing, should we have the users player as it's own attribute?

Alex3k commented 8 years ago

@sam-ac-dixon So my thought process was that if we put in the user player specifically in the data we would have to create a create a payload for each player. Alternatively by putting everyones id in the payload, the same payload could be sent to everyone.

Each client has to iterate over all players and bullets anyway to draw them so they can just check if their ID == the one they are currently iterating over then they know it themselves and (for example) focus the camera on themselves.

Long story short: generic broadcasted payload vs specific to player payload.

What are your thoughts?

Alex3k commented 8 years ago

@sam-ac-dixon from working on the server stub, it makes MUCH more sense to indeed have the players id in the payload. Therefore I propose the following:


{ 
  id: "abc",
  players: [{
    id: "abc",
    x: 0,
    y: 0,
    a: 0
  },
  {
    id: "def",
    x: 0,
    y: 0,
    a: 0
  }],
  bullets:[{
    x: 0,
    y: 0,
    a: 0
  },
  {
    x: 0,
    y: 0,
    a: 0
  }]
}

Thoughts?