Jump to content

  • Log In with Google      Sign In   
  • Create Account

Interested in a FREE copy of HTML5 game maker Construct 2?

We'll be giving away three Personal Edition licences in next Tuesday's GDNet Direct email newsletter!

Sign up from the right-hand sidebar on our homepage and read Tuesday's newsletter for details!


We're also offering banner ads on our site from just $5! 1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


miicchhii

Member Since 19 Apr 2012
Offline Last Active Sep 12 2013 02:39 PM

Topics I've Started

Some Feedback on my Multiplayer Pong Game please!

19 December 2012 - 07:25 AM

Hey folks,

I am working on a little game called jPong,
and i would really like to get some feedback from you!

Here's the Link:
http://www.langeder.org/wordpress/games/jpong/

It is not finished yet, but already playable in multiplayer.

Please note that there is a bug when starting the launcher, which will just open a blank window.
This can be fixed by restarting the launcher a few times.

So far it took me around 20 hours to make it.

Thanks!

Pack images into .jar file?

17 December 2012 - 01:22 PM

Hello everyone!

I just started learning Java and i use eclipse.
At the moment i work on a Pong game and i want to include some pictures
i.e. a ball instead of a circle, to make it look better.

This is the Code i use to load the image:

try {
	  img_ball = ImageIO.read(new File("/home/michael/Desktop/workspace-java/JPong/src/ball2.png"));
  } catch (IOException e) {
   System.out.println("ball2.png not found!");
  }

As you can see i use absolute paths, because relative would not work at all.
But using absolute paths is not what i want since i'm not the only to playing it.

Where do i have to place those files to be accessible relatively?
I would also like to put it INTO the jar file, so the release is just one file to run without the folders with files

Thanks in advance!

Networking to Slow - Java Multiplayer Pong

13 December 2012 - 03:07 AM

Hey all!
I created a Pong Game in Java and added Networking,
but it seems to slow the whole game down signifficantly.

I use a thread for the networking routine, on both server and the two clients.
The conversion is as follows:

send a marker (so the receiver knows which value will be sent next)
send the value
send the next marker, etc...

This is the Code for the Server:

/**
  *
  * Klasse (Thread) welche die Netzwerkfunktionen abhandelt
  *
  */
    class Network implements Runnable {
	    Network() {
	    }
	    public void run() {
		    // mit Host verbinden und Kommunizieren
		 try {
	   ServerSocket server = new ServerSocket(8888);
	   System.out.println("Warte auf Verbindung auf Port 8888");
	   Socket Client1 = server.accept();
	   System.out.println("Server: Client1 verbunden");
	   Socket Client2 = server.accept();
	   System.out.println("Server: Client2 verbunden");
	  
	   //Client1 einrichten
	   OutputStream out1 = Client1.getOutputStream();
	   PrintStream ps1 = new PrintStream(out1, true); // Second param: auto-flush on write = true
	   InputStream in1 = Client1.getInputStream();
	   BufferedReader br1 = new BufferedReader(new InputStreamReader(in1));
	   //Client2 einrichten
	   OutputStream out2 = Client2.getOutputStream();
	   PrintStream ps2 = new PrintStream(out2, true); // Second param: auto-flush on write = true
	   InputStream in2 = Client2.getInputStream();
	   BufferedReader br2 = new BufferedReader(new InputStreamReader(in2));
	  
	   String line="";
	   ps1.println("run");
	   ps2.println("run");
	  
	   while(true){
		   
	    //Einlesen Client1
	    for(int i=0;i<1;i++){
		 line = br1.readLine();
	   
		 if(line!=null){
		  if(line.contains("v1")){
		   line = br1.readLine();
		   player1Y=Integer.parseInt(line);
		  }
		 }
	    }//end Einlesen for-Schleife
	   
	    //Einlesen Client2
	    for(int i=0;i<1;i++){
		 line = br2.readLine();
	   
		 if(line!=null){
		  if(line.contains("v1")){
		   line = br2.readLine();
		   player2Y=Integer.parseInt(line);
		  }
		 }
	    }//end Einlesen for-Schleife
			   
	    //Ausgabe an Client1
	    ps1.println("v2");
	    ps1.println(""+player2Y);
	   
	    ps1.println("v4");
	    ps1.println(""+ballY);
	   
	    ps1.println("v3");
	    ps1.println(""+ballX);
	   
	    ps1.println("v5");
	    ps1.println(""+player1Score);
	   
	    ps1.println("v6");
	    ps1.println(""+player2Score);
	   
	    //Ausgabe an Client2
	    ps2.println("v2"); //gespiegelt für Player 2
	    ps2.println(""+player1Y);
	   
	    ps2.println("v4");
	    ps2.println(""+ballY);
	   
	    ps2.println("v3");
	    ball2X=MAXX-ballX;  //gespiegelt für Player2
	    ps2.println(""+ball2X);
	   
	    ps2.println("v5"); //gespiegelt für Player2
	    ps2.println(""+player2Score);
	   
	    ps2.println("v6"); //gespiegelt für Player2
	    ps2.println(""+player1Score);
	   
	   }
	  
	  
	  } catch (IOException e) {
	   // TODO Auto-generated catch block
	   //e.printStackTrace();
	   System.out.println("Verbindungsfehler aufgetreten");
	  }
	    }
    }

And the Client:

/**
  *
  * Klasse (Thread) welche die Netzwerkfunktionen abhandelt
  *
  */
    class Network implements Runnable {
	    String hostAdress;
	    Network(String adress) {
		    this.hostAdress = adress;
	    }
    public void run() {
	 try {
  
   Socket connectionToTheServer = new Socket(hostAdress, 8888);
   System.out.println("Client: Verbindung zu Server hergestellt");
   InputStream in = connectionToTheServer.getInputStream();
   BufferedReader br = new BufferedReader(new InputStreamReader(in));
   OutputStream out = connectionToTheServer.getOutputStream();
   PrintStream ps = new PrintStream(out, true);
   String line="";
   while(!(line.equals("run"))){line=br.readLine();}//warten auf Start des Spiels
  
   while(true){
	   
    //Ausgeben
   
    ps.println("v1");
    ps.println(""+player1Y);
   
    //Einlesen
    for(int i=0;i<5;i++){
	 line = br.readLine();
	 if(line!=null){
	  if(line.contains("v2")){
	   line = br.readLine();
	   player2Y=Integer.parseInt(line);
	  }else
	  if(line.equals("v3")){
	   line = br.readLine();
	   ballX=Double.parseDouble(line);
	  }else
	  if(line.equals("v4")){
	   line = br.readLine();
	   ballY=Double.parseDouble(line);
	  }else
	  if(line.contains("v5")){
	   line = br.readLine();
	   player1Score=Integer.parseInt(line);
	  }else
	  if(line.contains("v6")){
	   line = br.readLine();
	   player2Score=Integer.parseInt(line);
	  }
	 
	 }
    }//end Einlesen for-Schleife
   }
	
  
  } catch (UnknownHostException e) {
   // TODO Auto-generated catch block
   //e.printStackTrace();
   System.out.println("Verbindungsfehler aufgetreten");
  } catch (IOException e) {
   // TODO Auto-generated catch block
   //e.printStackTrace();
   System.out.println("Verbindungsfehler aufgetreten");
  }
   
    }

Logically everything works fine, but its very slow.

I would appreciate some recommendations on how to improve the speed!

Thanks in advance!

Aim using a vector?

20 July 2012 - 03:50 PM

Hey all,

I am new to Game development, i just did some simple 2D games (http://langeder.no-i...=spaceshooter_2),
but now i work on a 3D game and need some informations.

Its an FPS and i have the xyz Coordinates of the Player and a Hitbox (to begin with one).
Now i need to know how to do the aiming the best way.

I thought about using a vector, from the one end of the gun to the other,
and then calculate if it would collide with the box if extended.

Is it proper to do it like this or are there better ways?


Thanks already!



Greetings, michi

PARTNERS