initial import of BlobWars code

git-svn-id: svn://anubis/gvsu@96 45c1a28c-8058-47b2-ae61-ca45b979098e
This commit is contained in:
josh 2008-04-03 05:39:31 +00:00
parent eb74b46e3d
commit a4356f557a
4 changed files with 119 additions and 0 deletions

View File

@ -0,0 +1,29 @@
import java.awt.*;
import javax.swing.*;
import javax.swing.border.*;
public class BlobWars extends JFrame
{
public static void main(String[] args)
{
BlobWars jt = new BlobWars();
}
public BlobWars()
{
super("Josh's Blob Wars Game for CS654");
setSize(400, 500);
setDefaultCloseOperation(EXIT_ON_CLOSE);
// setResizable(false);
getContentPane().add(new JPanel() {{
setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
add(new JPanel() {{
setLayout(new BoxLayout(this, BoxLayout.X_AXIS));
add(new JLabel("hi!"));
}});
add(new BlobWarsPanel());
}});
setVisible(true);
}
}

View File

@ -0,0 +1,22 @@
import java.awt.*;
import javax.swing.*;
import javax.swing.border.*;
public class BlobWarsPanel extends JPanel
{
public BlobWarsPanel()
{
Dimension sz = new Dimension(400, 400);
setMinimumSize(sz);
setPreferredSize(sz);
setMaximumSize(sz);
}
public void paint(Graphics g)
{
// System.out.println("Width: " + getWidth() + " Height: " + getHeight());
g.setColor(Color.RED);
g.fillRect(0, 0, 40, 20);
}
}

View File

@ -0,0 +1,48 @@
import java.net.*;
public class BlobWarsServer extends Thread
{
public static final int PORT = 38491;
private ServerSocket m_socket;
public void run()
{
try {
m_socket = new ServerSocket(PORT);
} catch (Exception e) {
return;
}
for (;;)
{
Socket client;
try {
client = m_socket.accept();
} catch (Exception e) {
System.out.println("Socket error!");
break;
}
/* handle the client in a separate thread */
Thread t = new Thread(new ClientHandler(client));
t.start();
}
}
private class ClientHandler implements Runnable
{
private Socket m_socket;
public ClientHandler(Socket socket)
{
m_socket = socket;
System.out.println("Incoming connection from " + m_socket.getInetAddress().getAddress());
}
public void run()
{
}
}
}

20
cs654/final-proj/Makefile Normal file
View File

@ -0,0 +1,20 @@
MAINCLASS := BlobWars
all: $(patsubst %.java,%.class,$(wildcard *.java))
%.class: %.java
javac $^
.PHONY: run
run:
java $(MAINCLASS)
.PHONY: javadoc
javadoc:
-mkdir doc
javadoc -d doc *.java
clean:
-rm -f *.class
-rm -rf doc