Multi-Player Game With Multiple Worlds - Unhandled Packets

Sep 16, 2014

So I am trying to create a Multi-Player game in java, and I have a Game server and a Client. They normally connect with either but I would like to add a login server so that there can be an option to go to a different world then just the main one. It will have the same map and data but will be separate from the Players that are on world one per say. Now if you are on world two I would like it to have the option for you to be able to Private message players that are on World one. That is where the login server comes in to play.

I am still new at Java and would like to be able to understand Packets and how to handle them more clearly. So far I have gotten the basis of the login server connected to the server and the client connects to the server via the login server. But I am getting a bunch of "unhandled packets" and I would like to know how to handle them. Here are some bits of the code.

package com.ls.net;
import org.jboss.netty.channel.ChannelHandlerContext;
import org.jboss.netty.channel.ChannelStateEvent;
import org.jboss.netty.channel.ExceptionEvent;
import org.jboss.netty.channel.MessageEvent;
import org.jboss.netty.channel.SimpleChannelUpstreamHandler;

[Code] ....

So when I run my client this pops up in the console:

[Tue Sep 16 16:50:56 EDT 2014][LoginServer]: Finished initializing login server.
[Tue Sep 16 16:50:56 EDT 2014][SignalMultiplexer]: Unhandled packet: 15
[Tue Sep 16 16:50:56 EDT 2014][SignalMultiplexer]: Unhandled packet: 41
[Tue Sep 16 16:50:56 EDT 2014][SignalMultiplexer]: Unhandled packet: 74

[Code] ....

And here are the class's for Accounts:

package com.ls.net.codec.decoder.packets;
import org.jboss.netty.buffer.ChannelBuffer;
import org.jboss.netty.channel.ChannelHandlerContext;
import com.ls.bufutils.BufferUtils;
import com.ls.net.codec.decoder.PacketDecoder;
import com.ls.net.codec.decoder.handlers.AccountHandler;

[Code] ....

View Replies


ADVERTISEMENT

Turning Single Player Blackjack Game Into Multiplayer

Mar 19, 2014

I wrote a single player blackjack code and i want to play this game with multiplayers, which steps should i take to do this

package blackjack;
import java.util.Random;
import java.util.Scanner;
public class Blackjack {
public static void main(String[] args) {
Random kagit=new Random ();

[Code] .....

View Replies View Related

Hangman 2 Player Game - User Cannot Guess More Than 6 Times

May 27, 2014

I am creating a hangman code. So the game i am creating is 2 player, first player enters the word and second player guesses. i made the code but i don't know how to restrict the first player from adding random characters into the secret word because for my project the word can only contain letters. so i need making the code so the player 1 can only enter letters.

My code is below:

/**
* Auto Generated Java Class.
*/
import java.util.Scanner;
public class Hangman {
public static void main(String[] args) {
Scanner input= new Scanner(System.in);
String player1,player2;
int wrongguessamount = 0; //keeps the count of the amount of wrong guesses
int correctguessamount = 0; //keeps count of the amount of correct guesses
int maxincorrect=6;//makes sure the user cant guess more than 6 times

[Code] .....

View Replies View Related

Sound Won't Play When Player Dies And A Game Over Screen Pops Up

Jan 14, 2014

I am making a game with java in a program called greenfoot.My problem is that a sound won't play when the player dies and a Game Over screen pops up..

- I have saved the audio file in my sound map of the scenario
- Applied the good name of the file
- tested the sound effect and it's working

this is my code:

public GameOver()
{
setImage(new GreenfootImage("GAME OVER", 100, Color.BLACK, null));
Greenfoot.playSound("fail-trombone-03.wav");
Greenfoot.stop();
}

View Replies View Related

Keeping Track Of Player Position In Monopoly Board Game

Jun 28, 2014

I am trying to design a monopoly board game with a class and a main program. I can not make the method to keep track of the player's position after every roll. After every roll it prints "Previous position: 0".The player should also not go over 14th spot because the board is just 15 including 0. That is what I have (just the particular method and the part from the main program which call it).

public int getpospl1()
{
System.out.println( getplayer1name() + " Rolls "
+ "Dice 1: " + getrolld1() + "" + "Dice 2: " + getrolld2() + "" );
int spot1 = 14; //The end spot
int start = 0;
int previousPosition = start;

[Code] .....

View Replies View Related

Multi-word Hangman Game - Spaces Not Displayed When Program Run

Apr 9, 2015

I created a simple Hangman game. It functions correctly, the only issue is when the file contains a phrase (2 or more words), spaces are not displayed when the program is run. For example, if the phrase was Java Programming Forums.

It would appear as _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _.

I want there to be spaces in between the words. How could I fix this? What would I need to add to my code?

import java.util.Scanner;
import java.io.*;
 public class hangman{
public static void main (String[] args) throws FileNotFoundException{
Scanner kb = new Scanner(System.in);
String guess;
String guesses = "";
int wrongGuess = 8;

[Code] ....

View Replies View Related

Connect Four Game With Java Swing / Make Multi D Panel Maker When Try To Run It

May 31, 2014

I am trying to make a Connect Four game with java swing, but I am getting an error with my attempt at making an multi D panel maker when I try to run it.

import javax.swing.*;
import java.awt.Color;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
 
[code]...

View Replies View Related

Complicated ArrayList Function - Moving Between Fields Which A Player Can Perform Based On Game Rules

May 27, 2014

I have been working on this function and i can't get it to work. It's a little bit complicated so let me first explain what this is about:

1. As a little exam in my studies i have to program a halma console game with KI an stuff.

2. Everything is finished and works except for the Move-Calculation.

3. A Move is a Move from Field a to Field b which a player can perform in one round based on the game rules (Careful: We are not using the standard halma rules, we use different ones).

4. Class Move consists of the Starting Cell where the Figure before the Move stands and a target Cell where the figure will stay on at the Move end. It may include an Array of serveral Cells, the stop cells which the figure passes from start -> target since several jumps can be performed in one Move.

Valid Examples for Moves:

a -> b (From Field a to Field b)
d -> f through g,h,i (From Field d to Field f through the Field g,h,i

My Move Calculation where all possible Moves are calculated for a given figure consists of 2 parts. An expand() function which will generate all possible moves (works perfectly) and a jumpFix() function which isn't working properly.

Example:

After expand() I'm getting something like that:

a -> b
b -> c
c -> d
s -> t

This is however not finished, because the first 3 Moves are actually 1 Move. Because the player can Move from a -> d in one turn because those 3 are consecutive Move. The fixed Move would look like that:

a -> d through b,c

jumpFix() is also perfectly working for that situation, however there is one specific situation when it doesn't work. Let's say we have this situation.

a -> b
b -> c
c -> d
b -> e
e -> f
f -> g
s -> t

Then the only valid jumpFix() output would be:

a -> d through b,c
a -> g through b,e,f
s -> t

However i can not get it to work yet. Note: It definitely needs to be iterative, not rekursive else i would get an StackoverflowError.

This is my current Code of jumpFix():

Java Code:

/**
* Takes a look into all calculated moves and finds those which should be seen as one move, but are still considered to be more than one move (several jumps in one move)
*/

public static List<Move> jumpFix(List<Move> moves) {
Set<Move> result = new HashSet<Move>();
Set<Move> remove = new HashSet<Move>();
int lastSize = -1;
// repeat action until no moves could be merged
while (lastSize != remove.size()) {

[Code] ....

How to implement the special case where a Move splits into 2 or more branches and jumpFix() able to handle this case.

View Replies View Related

Player One Type A Number And Player Two Suppose To Guess - Infinite Looping

Apr 2, 2014

Its a basic program that is played by 2 people. Player one is suppose to type a number and the second player is suppose to guess the number. However after I test it out, and if I guess too low or too high I get stuck in "Your guess is too low, try again." infinite loop, what is wrong.

import java.io.*;
class GuessingGame
{
public static void main (String[] args) throws IOException
{
BufferedReader stdin = new BufferedReader (new InputStreamReader (System.in));
String firstPlayer, secondPlayer;
int firstInput, secondInput;
int guessCount = 0;

[Code] .....

View Replies View Related

Using Multiple Arrays To Play A Roulette Game

Mar 20, 2015

I am creating a roulette program that I converted from C++ to Java. Why its not finding the main class. Therefore it will not compile. Heres the code:

import java.util.Scanner;
public class P1RouletteDB
{
// This program demonstrates the use use multiple arrays to play a roulette game.
//Also a random number will generated to be used as the ball in the game. The user will be provided the random number to test the win algorithms
// Program Set 2 Roulette Game

// Global constants
public static final int COLS = 3; // Number of columns in each array

[Code] ....

View Replies View Related

Text Based RPG Game - Working With Multiple ArrayLists

Feb 22, 2014

I have come across an issue with arraylists. I am writing a text based RPG game as something to start with ...

Initially I had a single zone which was all stored in an arraylist and everything was working in regards to the player moving around. The problem I now have is how to add further zones to my game. Ideally I would like an arraylist for each zone, and would use the below to create each arraylist

public static ArrayList<RoomsClass> castleMap = new ArrayList<>();

The problem I now have is how to handle the player moving, initially with a single zone/arraylist I could reference that arraylist directly

public void findRoomCoords(int ID) {
for (int i = 0; i < castleMap.size(); i++) {
if (castleMap.get(i).roomID.equals(ID)) {
PLAYER.setCurrentRoomZone(castleMap.get(i).roomZone);
PLAYER.setCurrentRoomX(castleMap.get(i).roomX);
PLAYER.setCurrentRoomY(castleMap.get(i).roomY);
PLAYER.setCurrentRoomZ(castleMap.get(i).roomZ);
}
}
}

My initial thought was to use a getter/setter to remove the reference of castleMap from my movement code in order to access different arraylists, however this is where things have fallen over, I can't seem to work out how to get the arraylist name to change, depending on the outcome of the setZoneMap() method.

public void setZoneMap() {
switch (PLAYER.getCurrentRoomZone()) {
case 0: {
zoneMap = Castle.castleMap;
break;

[Code] ....

View Replies View Related

Video Streaming Using Java - Convert File Into RTP Packets

Mar 11, 2015

I am doing project on Video streaming using java.

How to convert video file into RTP packets....?

View Replies View Related

Java Library Function That Searches Stream Of Tcp Packets

Apr 28, 2014

i need a java library function that searches the stream of tcp packets coming to my computer from a particular ip address, so i can perform regular expressions on the contents of those packets.

View Replies View Related

Client And Server Class For UDP Protocol Sending Integer Numbers By Packets

Apr 21, 2014

I have to write a client and server class for a UDP protocol sending integer numbers by UDP packets. So far i have this;

Client Code:

import java.io.*;
import java.net.*;
class UDPClient {
public static void main(String args[]) throws Exception {
BufferedReader inFromUser =
new BufferedReader(new InputStreamReader(System.in));

[Code] ....

But i now need to change this so that:

The client;

1. Reads an integer from keyboard input and stores its value in a UDP packet.
// byte[] send = ByteBuffer.allocate(4).putInt(num).array(); ???

2. Sends the UDP packet to the server, on port number 1999;

3. Listens for UDP packets from the server (until it receives a packet with a non-positive number; see
step (b) below). While listening:

(a) Once it receives a UDP packet from the server, it subtracts 2 from the integer value num contained in it.
// int num = ByteBuffer.wrap(receive).getInt(); ???
(b) Checks the integer value num: if the value is greater than 0 (num>0) then the client stores it in a new UDP packet and sends the packet to the server; otherwise (num<=0) the client terminates.

The Server;

1. Listens on port 1999;

2. For each UDP packet it receives from a client:
(a) extracts the integer value n contained in it;
(b) decreases the value of n by 2;
(c) sends back to the client a UDP packet containing the new value of n.

View Replies View Related

Swing/AWT/SWT :: BorderLayout - Adding Multiple Video Game Oriented Objects Such As Sprites To JFrame?

May 24, 2014

I decided to write a small Java program to experiment around with BorderLayout, because I'm developing a Java game and I need to have 2 objects placed in a single JFrame at the same time, and everyone I asked said I need BorderLayout to do that.Before you answer: Also, is using BorderLayout the best option for adding multiple video game oriented objects such a sprites to a JFrame?

So the Java program I wrote is supposed to place a JButton on the JFrame and ALSO place a graphic component (a rectangle in this case). The problem is, only the button shows up, as can be seen in the image link below: URL....

Here is the code:

**main.java** --> The main method class + JFrame/JPanel/JButton constructor
import java.awt.BorderLayout;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
public class main {

[code]....

View Replies View Related

Java Media Player

Feb 24, 2014

I am using the Netbeans IDE for Java creations. What are the steps of creating a media player using Java thru Netbeans as i don't understand most of the jargon and the forms,classes,etc.I don't want to use JavaFx but plain Java Application.I am coming from a Delphi pascal background.

View Replies View Related

Unable To Create MP3 Player

Jul 6, 2014

I am trying to create an MP3 player with a totally customized look and feel to it. I know how to do this with .net, but I must be missing something in Java.

I want to be able to NOT have to present the user with the default mediaPlayer.getControlPanelComponent() in order to control the media player. I want to be able to code it to when the user clicks on my "Play" button, I can tell the player to play the song, and so on.

so far I get this far:

try {
player = Manager.createPlayer(playit.toURI().toURL());
player.start();
//Component c = player.getControlPanelComponent();
} catch (IOException | NoPlayerException ex) {
Logger.getLogger(TagTester.class.getName()).log(Level.SEVERE, null, ex);
}

...but cannot seem to find out where to go from there.

If familiar with AxWindowMediaPlayer in .NET, I am looking for something similar to:

AxWindowMediaPlayer.Ctlcontrols.play()

when my "Play" button is clicked.

View Replies View Related

How To Track Player Positioning

Nov 25, 2014

So I have a player an enemy and enemy bounds the enemy can go. I need to have the enemy track my position and when I go into the position (I am using a collision method for this) the enemy comes over at a speed of 1. My problem is the enemy jumps to me and then follows at speed of 2 (2 is the player speed). The code is wrong this is why it is jumping and I have my other problems. so my question is what is a good solution for this? I am trying to make a method to track playerposition() so what I am thinking I could do is find x, y of player then store those into an array and return the array to Enemy so he tracks.

player.java
public class Player{
int x = 100; // Location of player
int y = 200; // location of player
int xa = 0; // Representation of where the player goes
int ya = 0; // Representation of where the player goes
private int speed = 2;

[Code] .....

Please note this is not the entire code I have cut some things out that did not need to be there. Also, the code is just to get an idea of what I was thinking of doing. The ideas that are came up with are not meant to be a reflection of what I already have but, what I could add or replace.

View Replies View Related

Java Music Player - Volume Control

Dec 5, 2014

I am currently building a java music player and need getting the volume control to work. I want to be able to set the computers volume directly using an integer. I've created a slider and put the value into an integer. The part that I am having trouble with is getting the volume to work.

View Replies View Related

Server / Multi Clients

Mar 9, 2014

I have made a server/multi Clients where Clients send Double data but my problem is that the clients send this data to Server only wonce, and the server waits again the connection from client. (I have to run the clients manually each time)what i'm looking: the client should always send data to server. like an infinite loop.

View Replies View Related

Multi-Array Of JButtons

May 18, 2014

Java Code:

import java.awt.Color;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.*;
public class Screen implements ActionListener {
public JButton[][] b=new JButton[200][200];

[Code] ....

I am trying to create the A* Algorithm and I REALLY need a 2D array to handle this.

This is the error:

Java Code:

at java.awt.AWTEventMulticaster.componentShown(AWTEventMulticaster.java:162)
at java.awt.AWTEventMulticaster.componentShown(AWTEventMulticaster.java:162)
at java.awt.AWTEventMulticaster.componentShown(AWTEventMulticaster.java:162)
at java.awt.AWTEventMulticaster.componentShown(AWTEventMulticaster.java:162)
at java.awt.AWTEventMulticaster.componentShown(AWTEventMulticaster.java:162) mh_sh_highlight_all('java');

View Replies View Related

Multi Array Of Buttons?

May 18, 2014

import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

[Code]....

I am trying to program an A* algorithm and I cannot even get past the buttons. I need a 2D array of buttons to handle this problem but I am getting the following errors.

at java.awt.AWTEventMulticaster.componentShown(AWTEventMulticaster.java:162)
at java.awt.AWTEventMulticaster.componentShown(AWTEventMulticaster.java:162)
at java.awt.AWTEventMulticaster.componentShown(AWTEventMulticaster.java:162)
at java.awt.AWTEventMulticaster.componentShown(AWTEventMulticaster.java:162)

[Code] ....

View Replies View Related

Designing Media Player - Program Cannot Play Any Song

Feb 24, 2014

i want to design a media player but my program can't play any song it is showing me error "Uncompilable source code - cannot find symbol

symbol: class MediaPanel
location: class media.Media
at media.Media.main(Media.java:28)"

This is my code.

package media;
import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;
import javax.swing.JFileChooser;

[Code] .....

I got the code from [URL] .....

View Replies View Related

Collision Detection Using Rectangles - Player Sometimes Passes Through The Tiles

May 19, 2014

I have already tried every possible way for removing this bug but all failed. The problem is that sometimes my player passes through the map tiles, i mean, the algorithm is like -- if not colliding, move in required direction; else if colliding, move in opposite direction. But sometimes the second condition fails i dont understand why.

private void movement(){
left=bindObject.getLeft();
right=bindObject.getRight();
up=bindObject.getUp();
down=bindObject.getDown();
bindObject.setColliding(colliding);

[Code] .....

Where bindObject is a class which contains key bindings of following keys:-

left arrow key (when pressed) , left arrow key (when released),
right arrow key (when pressed), right arrow key (when released),
up arrow key (when pressed), up arrow key (when released),
down arrow key (when pressed), down arrow key (when released)

View Replies View Related

Servlets :: Multi Threading Mechanism?

Nov 16, 2014

Is there any specific name for servlet's multi threading mechanism? I mean any technical term for it.

View Replies View Related

Java UDP Sockets And Multi-Threading

Dec 26, 2014

I have been practicing writing java code, my university course is going to cover socket programming and multi-threading.

I am presently just starting to write myself a framework for all multiplayer games I may make in the future, my aim really is simply to practice and understand better and this time, im not using an ide, just sublime text, all new grounds for me, I have a good basic understanding of the subject but I want to be fluent.

import java.net.*;
import java.util.ArrayList;
import java.io.*;
/*SMOOTH THREAD SAFE MULTI CLIENT HANDLING CLASS.
*
*This class will create connection objects when a connection is detected, these connections will run in a separate thread and update an array list in their parent class containing their last sent data

[Code] .....

View Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved