How do i update my Network Players sprite_index

K

Kindred

Guest
Hi, so I'm relatively new to game development and I'm currently developing an MMO and so far have multiple clients successfully connecting to my server. My local player object moves correctly and has the correct sprite movements (up,down,left,right). but I'm having a little difficulty in making my network players sprites change.
I'm sending positional data back to my server from my local player object so I'm assuming i need to also send sprite indexes as well so that my network player also has the correct sprite movements.
So should i assign numbers to my 4 sprite indexes and then write them to a buffer as integers and send them to my server along with the positional packet I'm sending?
something like buffer_write(pos_packet,buffer_u8,spriteNumber) ?

Also does that mean the userSchema on my server side would look something like this:
var userSchema = new mongoose.Schema({
username: {type: String, unique: true},
password: String,
sprite: Number,
current_room: String,
pos_x: Number,
pos_y: Number
});
Any help would be much appreciated!
 

chamaeleon

Member
In theory, maybe your client programs could compare pos_x and pos_y with the old values to determine which direction the remote player is travelling and set the sprite accordingly, but it seems simpler to just send an integer representing the data along with the other data you're already sending. Since sprite indices are already numbers, you don't need to assign numbers. Just use whatever it is (maybe ensure it's an integer using floor()..)
 
Top