Skip to content

Instantly share code, notes, and snippets.

View elliotforbes's full-sized avatar
:octocat:

Elliot Forbes elliotforbes

:octocat:
View GitHub Profile
@Override
public void run() {
// All our initialization code
init();
// Our main game loop
while(running){
update();
render();
// Checks to see if either the escape button or the
// red cross at the top were pressed.
import socket
UDP_IP_ADDRESS = "127.0.0.1"
UDP_PORT_NO = 6789
Message = "Hello, Server"
clientSock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
clientSock.sendto(Message, (UDP_IP_ADDRESS, UDP_PORT_NO))
# Again we import the necessary socket python module
import socket
# Here we define the UDP IP address as well as the port number that we have
# already defined in the client python script.
UDP_IP_ADDRESS = "127.0.0.1"
UDP_PORT_NO = 6789
# declare our serverSocket upon which
# we will be listening for UDP messages
serverSock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
# One difference is that we will have to bind our declared IP address
# and port number to our newly declared serverSock
serverSock.bind((UDP_IP_ADDRESS, UDP_PORT_NO))
while True:
data, addr = serverSock.recvfrom(1024)
print "Message: ", data
public interface Enemy {
public void attack();
public double getHealth();
public void setHealth(double newHealth);
}
public class InfantryImpl implements Enemy{
double health;
int ammo;
@Override
public void attack() {
// TODO Auto-generated method stub
System.out.println("Infantry Attack!");
}