i want to make a multiplayer pictionary game using client / server.
I have a very simple drawing program like paintbrush, just allows me to paint freehand in black.
Now when one client draws, i want the other clients to view the drawing take place in real time. Whats the best way to stream the data / pixel coordinates out to the server ?
here is the part that draws
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
| protected class JPaintPanel extends JPanel implements MouseMotionListener, MouseListener { public JPaintPanel() { super() ; addMouseListener(this) ; addMouseMotionListener(this) ; } public void mouseDragged(MouseEvent arg0) { Point p = arg0.getPoint() ; getGraphics().drawLine(lastPos.x, lastPos.y, p.x, p.y) ; lastPos = p ; } public void mousePressed(MouseEvent arg0) {lastPos=arg0.getPoint();} public void mouseReleased(MouseEvent arg0) {lastPos=null ;} public void mouseMoved(MouseEvent arg0) {} public void mouseClicked(MouseEvent arg0){} public void mouseEntered(MouseEvent arg0) {} public void mouseExited(MouseEvent arg0) {} protected Point lastPos = null ; } |