Goran Milovanovic
Thanks I'll have a look at it
Male
!Null hasn't added any contacts yet.
29 November 2012 - 11:54 AM
27 November 2012 - 02:18 PM
It's an FPS
Wait a second. From a one lecture that teaches you an Echo Server, you're supposed to know how to program an FPS networked game? I think something is missing here. Is it just a 2 player game or a true multiplayer (ie, 2 - 16)?
FWIW, creating a truly robust FPS Networked game is PRETTY FRIGGING HARD. Now, you can create a protocol that runs good over LAN, but would do poorly over the internet that's not too difficult (not too difficult for someone who understand networking protocols at least).
BTW, there's a networking forum here that has loads of information that you may want to look over all the posts there.
NetAcceptTCP();
NetClose();
NetConnectTCP();
NetCreateChannel();
NetCreateChannelTCP();
NetDataReady();
NetGetIP();
NetReceiveFrom();
NetReceiveFromTCP();
NetSendTo();
NetSendToTCP();
NetSetMulticastIP();
NetVarReceiveFrom();
NetVarReceiveFromTCP();
NetVarSendTo();
NetVarSendToTCP();
27 November 2012 - 11:54 AM
11 November 2012 - 01:19 PM
While this might be language-dependent, you can't normally switch-case objects like strings. switch-case could only be used on integers, as it creates a jump/branch table. Additonally, in some languages, you are allowed to fall through a case statement.
switch (x) { case 0: doSomething(); case 1: doSomethingElse(); break; default: doDefault(); break; }
if x = 0, doSomething() and doSomethingElse() are executed. This style of coding could be useful in certain cases (no pun intended).
03 November 2012 - 04:31 PM
package example;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.*;
import javax.swing.*;
public class Main implements MouseListener
{
private final static int SCREEN_WIDTH = 640;
private final static int SCREEN_HEIGHT = 480;
private final static int tile_size = 32;
private int map[][];
private int mousex, mousey;
private JFrame frame;
private JPanel panel;
public Main()
{
map = new int[SCREEN_WIDTH / tile_size][SCREEN_HEIGHT / tile_size];
frame = new JFrame();
panel = new JPanel();
panel.setBackground(Color.red);
frame.setSize(new Dimension(640,480));
frame.setContentPane(panel);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.addMouseListener(this);
frame.setVisible(true);
int k = 0;
for(int i = 0; i < map.length; i++)
{
for(int j = 0; j < map[i].length; j++)
{
map[i][j] = k;
k++;
}
}
}
public static void main(String[] args)
{
Main main = new Main();
}
@Override
public void mouseClicked(MouseEvent e)
{
System.out.println(map[e.getX() / tile_size][e.getY() / tile_size]);
}
@Override
public void mousePressed(MouseEvent e) {
}
@Override
public void mouseReleased(MouseEvent e) {
}
@Override
public void mouseEntered(MouseEvent e) {
}
@Override
public void mouseExited(MouseEvent e) {
}
}
Find content