Chat Tutorial in NetBeans/Text Client: Difference between revisions
Jump to navigation
Jump to search
Content deleted Content added
imported>SimonSmall small correction |
imported>SimonSmall Tidy up |
||
| Line 1: | Line 1: | ||
= Introduction = |
|||
These instructions are a continuation of the Chat Tutorial. This is a text based client that runs in a command / terminal window. |
These instructions are a continuation of the Chat Tutorial. This is a text based client that runs in a command / terminal window. |
||
= NetBeans Project = |
|||
In the NetBeans IDE, close all open projects. Click New Project, choose Java and Java Application. Click Next, then give the Project Name as client. Change the Project Location to DEVPATH\DevChat (DEVPATH, see above); the Project Folder is shown as DEVPATH\DevChat\client with DEVPATH being your chosen location. Check that Create Main Class is ticked, and the |
In the NetBeans IDE, close all open projects. Click '''New Project''', choose '''Java''' and '''Java Application'''. Click '''Next''', then give the '''Project Name''' as '''client'''. Change the '''Project Location''' to '''DEVPATH\DevChat''' (DEVPATH, see above); the '''Project Folder''' is shown as '''DEVPATH\DevChat\client''' with DEVPATH being your chosen location. Check that '''Create Main Class''' is ticked, and the '''Main Class''' is '''client.Test''' before clicking '''Finish'''. |
||
The empty Project is created in NetBeans. Under the Files tab you will see the directory structure it has also generated; check this using your file explorer. |
The empty Project is created in NetBeans. Under the Files tab you will see the directory structure it has also generated; check this using your file explorer. |
||
== Adding the Marauroa library == |
|||
| ⚫ | |||
Choose the correct way depending on if you are using the marauroa.jar file, of have created a marauroa project from the source code. |
|||
| ⚫ | |||
=== Using the Jar file === |
|||
Find the '''marauroa.jar''' file from the download, and copy it to the libs directory (created above) if it is not there already. Right click the '''Libraries''' branch of the server Project tree, and select '''Add Jar/Folder'''. Browse to the the libs directory for this project and select the marauroa.jar file. This will include the marauroa library with no view of the source code. |
|||
=== Using the marauroa project === |
|||
| ⚫ | |||
| ⚫ | |||
The following files need to be created, as they are not present in the marauroa source file. |
The following files need to be created, as they are not present in the marauroa source file. |
||
=== Client.java === |
|||
Right-click on the client package and add a new Java Class. Give the |
Right-click on the '''client''' package and add a new '''Java Class'''. Give the '''Class Name''' as '''Client'''. Replace the template code with the following code: |
||
<source lang="Java"> |
<source lang="Java"> |
||
/* |
|||
| ⚫ | |||
*/ |
|||
package client; |
package client; |
||
| Line 33: | Line 47: | ||
import marauroa.common.net.message.MessageS2CPerception; |
import marauroa.common.net.message.MessageS2CPerception; |
||
import marauroa.common.net.message.TransferContent; |
import marauroa.common.net.message.TransferContent; |
||
| ⚫ | |||
/** |
|||
* |
|||
*/ |
|||
public class Client extends ClientFramework { |
public class Client extends ClientFramework { |
||
private PerceptionHandler handler; |
private PerceptionHandler handler; |
||
| Line 112: | Line 129: | ||
@Override |
@Override |
||
protected String getVersionNumber() { |
protected String getVersionNumber() { |
||
return "0. |
return "0.1"; |
||
} |
} |
||
| Line 179: | Line 196: | ||
Close and Save the file. |
Close and Save the file. |
||
=== Test.java === |
|||
This file was created when you created the new Project. Add the following (or replace the existing) code: |
This file was created when you created the new Project. Add the following (or replace the existing) code: |
||
<source lang="Java"> |
<source lang="Java"> |
||
/* |
|||
* |
|||
*/ |
|||
package client; |
package client; |
||
import marauroa.common.game.RPObject; |
import marauroa.common.game.RPObject; |
||
/** |
|||
* |
|||
*/ |
|||
public class Test { |
public class Test { |
||
@SuppressWarnings("SleepWhileInLoop") |
@SuppressWarnings("SleepWhileInLoop") |
||
| Line 231: | Line 255: | ||
Close and Save the file. |
Close and Save the file. |
||
== Build the Project == |
|||
| ⚫ | |||
| ⚫ | |||
| ⚫ | |||
You have created the two class files and compiled them into a java library. Now you can follow the deployment instructions for preparing and testing your game. |
|||
| ⚫ | |||
[[Category:NetBeans]] |
|||
The files in the dist directory are the ones you will need for your game. |
|||