This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import socket |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
UDP_IP_ADDRESS = "127.0.0.1" | |
UDP_PORT_NO = 6789 | |
Message = "Hello, Server" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
clientSock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
clientSock.sendto(Message, (UDP_IP_ADDRESS, UDP_PORT_NO)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
while True: | |
data, addr = serverSock.recvfrom(1024) | |
print "Message: ", data |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public interface Enemy { | |
public void attack(); | |
public double getHealth(); | |
public void setHealth(double newHealth); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class InfantryImpl implements Enemy{ | |
double health; | |
int ammo; | |
@Override | |
public void attack() { | |
// TODO Auto-generated method stub | |
System.out.println("Infantry Attack!"); | |
} |