17 Commits

Author SHA1 Message Date
Lukas Bauer
66798eb3e4 Improved code documentation 2024-10-11 15:22:20 +02:00
Lukas Bauer
edff9e1ad9 Improved code documentation and clarify comments for better readability and understanding 2024-10-11 15:06:09 +02:00
Lukas Bauer
bf16a18b71 Aufgabe 13
edited class BattleState in order to implement the 2D map feature
edited class GameSound to add the Missile launch sound
edited class MapViewSynchronizer in order to implement the 2D map feature
edited class ImpactEffectManager removed unused import
edited class SeaSynchronizer removed unused code
edited class Shell in order to implement the 2D map feature
edited class ShellControl in order to implement the 2D map feature
edited Sound added Missile launch enum
edited FloatMath to improve the animation for the 2D projectile
added missileLaunch.wav
2024-10-11 14:23:49 +02:00
Lukas Bauer
6100e95e76 Aufgabe 13
added class Shell for the feature Airstrike
added class ShellControl for the feature Airstrike
added new Model Bomb to implement the feature Airstrike
added README´S to the Models to show the free to use license
edited class ShipMap for the feature Airstrike
edited class ImpactEffectManager to improve the Fire and Water Particles
edited class MapViewSynchronizer for the feature Airstrike
edited class BattleState for the feature Airstrike
edited class BattleshipApp for the feature Airstrike
2024-10-09 21:10:31 +02:00
Lukas Bauer
1b7b842ca7 JavaDoc adjustments 2024-10-08 19:46:23 +02:00
Lukas Bauer
865b0fc33c Aufgabe 12
added class ImpactEffectManager to implement the funktionality with hit or miss particles
added map4 for particle testing purposes
edited class SeaSynchronizer in order to implement the particle feature
edited class ShipControl in order to implement the particle feature
edited settings.gradle in order to implement the particle feature
2024-10-08 19:43:07 +02:00
Lukas Bauer
5a9b0b1de0 fix Aufgabe 11
edited class NetworkDialog
to change the logic that the checkbox works now as intended
moved BattleshipServer and ReceivedMessage into own folders to separate server from client
2024-10-07 20:11:15 +02:00
Lukas Bauer
8650fa5b58 fix edited class EditorState
fix edited battleship.properties with the right Key to fix an exception
fix edited battleship_de.properties with the right Key to fix an exception
2024-10-05 13:09:05 +02:00
Lukas Bauer
113da79df6 fix edited class NetworkDialog changed Button to Checklist 2024-10-04 18:42:47 +02:00
Lukas Bauer
e41d21584a Aufgabe 11.
added class BattleshipServer, ReceivedMessage
to implement the feature that a client is able to start an server
edited NetworkDialog to implement the logic to start an server and overhauled the GUI to be appropriate for the new features
2024-10-04 18:33:13 +02:00
Lukas Bauer
5e773ca1ba Aufgabe 10.
added class BackgroundMusic
edited BattleshipApp, GameSound, Menu
implemented a Slider for the Gui in order to change the Volume
Quality of Life
implemented feature to Safe the Sound settings to keep them even after shutting down the game
implemented feature to mute Sounds/effects
implemented feature to mute Music
2024-10-03 19:11:53 +02:00
Lukas Bauer
b2b3bc23bf Aufgabe 10.
added class BackgroundMusic
edited BattleshipApp, GameSound, Menu
implemented a Slider for the Gui in order to change the Volume
Quality of Life
implemented feature to Safe the Sound settings to keep them even after shutting down the game
implemented feature to mute Sounds/effects
implemented feature to mute Music
2024-10-03 19:10:36 +02:00
Lukas Bauer
ce490fb877 Aufgabe 10.
added class BackgroundMusic
edited BattleshipApp, GameSound, Menu
implemented a Slider for the Gui in order to change the Volume
Quality of Life
implemented feature to Safe the Sound settings to keep them even after shutting down the game
implemented feature to mute Sounds/effects
implemented feature to mute Music
2024-10-03 19:07:27 +02:00
Lukas Bauer
ce5e908349 edited SeaSynchronizer , EditorState, ServerGameLogic
added JavaDocs for the new and adapted functions
added a new invalid map for testing purposes
fixed implemented the logic to check for invalid maps in the method received in ServerGameLogic
2024-10-03 13:28:41 +02:00
Lukas Bauer
07e922d01e Aufgabe 9.
edited SeaSynchronizer
added 3 Ship Models Small Ship, Medium Ship and Big Ship and tweaked the scaling of all Models
2024-10-02 20:23:05 +02:00
Lukas Bauer
42b442e937 Aufgabe 8.
edited class EditorState and ServerGameLogic
 to check for invalid maps in which ships overlap or are out of the map boundries for clientside and serverside
2024-10-02 18:24:27 +02:00
Lukas Bauer
93ade34282 Aufgabe 7.
fix: in class ShipMap
function remove
hierbei wurde nach dem entfernen eines Items dass Event ItemAddedEvent ausgelöst hierbei sollte aber logischerweiße dass Event ItemRemovedEvent ausgelöst werden.

fix: in class BattleState
function receivedEffect
hierbei wurde die eigene map für die Bedingung isGameOver verglichen wobei man für isGameOver die OpponentMap auf remainingShips untersuchen muss.
2024-10-02 00:31:40 +02:00
234 changed files with 1013978 additions and 2680045 deletions

View File

@@ -1,18 +1,17 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="BattleshipApp (Mac)" type="Application" factoryName="Application"
singleton="false">
<option name="MAIN_CLASS_NAME" value="pp.battleship.client.BattleshipApp"/>
<module name="Projekte.battleship.client.main"/>
<option name="VM_PARAMETERS" value="-XstartOnFirstThread"/>
<option name="WORKING_DIRECTORY" value="$MODULE_WORKING_DIR$"/>
<extension name="coverage">
<pattern>
<option name="PATTERN" value="pp.battleship.client.*"/>
<option name="ENABLED" value="true"/>
</pattern>
</extension>
<method v="2">
<option name="Make" enabled="true"/>
</method>
</configuration>
<configuration default="false" name="BattleshipApp (Mac)" type="Application" factoryName="Application" singleton="false">
<option name="MAIN_CLASS_NAME" value="pp.battleship.client.BattleshipApp" />
<module name="Projekte.battleship.client.main" />
<option name="VM_PARAMETERS" value="-XstartOnFirstThread" />
<option name="WORKING_DIRECTORY" value="$MODULE_WORKING_DIR$" />
<extension name="coverage">
<pattern>
<option name="PATTERN" value="pp.battleship.client.server.*" />
<option name="ENABLED" value="true" />
</pattern>
</extension>
<method v="2">
<option name="Make" enabled="true" />
</method>
</configuration>
</component>

View File

@@ -1,18 +1,19 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="BattleshipApp" type="Application" factoryName="Application" singleton="false"
nameIsGenerated="true">
<option name="MAIN_CLASS_NAME" value="pp.battleship.client.BattleshipApp"/>
<module name="Projekte.battleship.client.main"/>
<option name="VM_PARAMETERS" value="-Djava.util.logging.config.file=logging.properties"/>
<option name="WORKING_DIRECTORY" value="$MODULE_WORKING_DIR$"/>
<configuration default="false" name="BattleshipApp" type="Application" factoryName="Application" singleton="false" nameIsGenerated="true">
<option name="ALTERNATIVE_JRE_PATH" value="temurin-20" />
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="true" />
<option name="MAIN_CLASS_NAME" value="pp.battleship.client.BattleshipApp" />
<module name="Gruppe-01" />
<option name="VM_PARAMETERS" value="-Djava.util.logging.config.file=logging.properties" />
<option name="WORKING_DIRECTORY" value="$MODULE_WORKING_DIR$" />
<extension name="coverage">
<pattern>
<option name="PATTERN" value="pp.battleship.client.*"/>
<option name="ENABLED" value="true"/>
<option name="PATTERN" value="pp.battleship.client.server.*" />
<option name="ENABLED" value="true" />
</pattern>
</extension>
<method v="2">
<option name="Make" enabled="true"/>
<option name="Make" enabled="true" />
</method>
</configuration>
</component>

View File

@@ -2,7 +2,7 @@
<configuration default="false" name="Projekte [test]" type="GradleRunConfiguration" factoryName="Gradle">
<ExternalSystemSettings>
<option name="executionName" />
<option name="externalProjectPath" value="$PROJECT_DIR$/Projekte" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="externalSystemIdString" value="GRADLE" />
<option name="scriptParameters" value="--continue" />
<option name="taskDescriptions">

View File

@@ -0,0 +1,66 @@
{
"width": 10,
"height": 10,
"ships": [
{
"length": 4,
"x": 2,
"y": 8,
"rot": "RIGHT"
},
{
"length": 3,
"x": 2,
"y": 5,
"rot": "DOWN"
},
{
"length": 3,
"x": 5,
"y": 6,
"rot": "RIGHT"
},
{
"length": 2,
"x": 4,
"y": 4,
"rot": "RIGHT"
},
{
"length": 2,
"x": 7,
"y": 4,
"rot": "RIGHT"
},
{
"length": 2,
"x": 7,
"y": 4,
"rot": "RIGHT"
},
{
"length": 1,
"x": 6,
"y": 2,
"rot": "RIGHT"
},
{
"length": 1,
"x": 8,
"y": 2,
"rot": "RIGHT"
},
{
"length": 1,
"x": 6,
"y": 0,
"rot": "RIGHT"
},
{
"length": 1,
"x": 8,
"y": 0,
"rot": "RIGHT"
}
]
}

View File

@@ -0,0 +1,66 @@
{
"width": 10,
"height": 10,
"ships": [
{
"length": 1,
"x": 9,
"y": 0,
"rot": "RIGHT"
},
{
"length": 1,
"x": 9,
"y": 1,
"rot": "RIGHT"
},
{
"length": 1,
"x": 8,
"y": 0,
"rot": "RIGHT"
},
{
"length": 1,
"x": 8,
"y": 1,
"rot": "RIGHT"
},
{
"length": 2,
"x": 8,
"y": 2,
"rot": "RIGHT"
},
{
"length": 2,
"x": 6,
"y": 0,
"rot": "RIGHT"
},
{
"length": 2,
"x": 6,
"y": 1,
"rot": "RIGHT"
},
{
"length": 3,
"x": 5,
"y": 2,
"rot": "RIGHT"
},
{
"length": 3,
"x": 7,
"y": 3,
"rot": "RIGHT"
},
{
"length": 4,
"x": 6,
"y": 4,
"rot": "RIGHT"
}
]
}

View File

@@ -0,0 +1,95 @@
package pp.battleship.client;
import com.jme3.app.Application;
import com.jme3.audio.AudioData.DataType;
import com.jme3.audio.AudioNode;
import com.jme3.audio.AudioSource.Status;
import java.util.prefs.Preferences;
public class BackgroundMusic {
private static final String VOLUME_PREF = "volume";
private static final String MUSIC_ENABLED_PREF = "musicEnabled";
private Preferences prefs = Preferences.userNodeForPackage(BackgroundMusic.class);
private final AudioNode backgroundMusic;
private boolean musicEnabled;
private float volume;
/**
* Constuctor for the BackgroundMusic
* @param app for synchronising and saving data with the application
* @param musicFilePath the filepath for the BackgroundMusic
*/
public BackgroundMusic(Application app, String musicFilePath) {
this.volume = prefs.getFloat(VOLUME_PREF, 1.0f);
this.musicEnabled = prefs.getBoolean(MUSIC_ENABLED_PREF, true);
backgroundMusic = new AudioNode(app.getAssetManager(), musicFilePath, DataType.Stream);
backgroundMusic.setLooping(true);
backgroundMusic.setPositional(false);
backgroundMusic.setVolume(1.0f);
if (musicEnabled) {
play();
}
}
/**
* Checks if the condition is met to play BackgroundMusic
*/
public void play() {
if (musicEnabled && (backgroundMusic.getStatus() == Status.Stopped || backgroundMusic.getStatus() == Status.Paused)) {
backgroundMusic.play();
}
}
/**
* function to stop the BackgroundMusic
*/
public void stop() {
if (backgroundMusic.getStatus() == Status.Playing) {
backgroundMusic.stop();
}
}
/**
* function to toggle the Backgroundmusic also sets the volume to the previous session
*/
public void toogleMusic() {
this.musicEnabled = !this.musicEnabled;
if (musicEnabled) {
play();
} else {
stop();
}
prefs.putFloat(VOLUME_PREF, volume);
}
/**
* Setter for the Volume also safes the volume from the previous session
* @param volume variable for the volume of the BackgroundMusic
*/
public void setVolume(float volume) {
this.volume = volume;
backgroundMusic.setVolume(volume);
prefs.putFloat(VOLUME_PREF, volume);
}
/**
* Getter for Volume
* @return a float value of the volume
*/
public float getVolume() {
return volume;
}
/**
* Getter for musicEnabled
* @return if the music is enabled return true, false otherwise
*/
public boolean isMusicEnabled() {
return musicEnabled;
}
}

View File

@@ -121,11 +121,10 @@ public class BattleshipApp extends SimpleApplication implements BattleshipClient
* Listener for handling actions triggered by the Escape key.
*/
private final ActionListener escapeListener = (name, isPressed, tpf) -> escape(isPressed);
/**
* Listener for handling actions triggered by the Escape key.
*
*/
private GameMusic music;
private BackgroundMusic backgroundMusic;
static {
// Configure logging
@@ -146,6 +145,7 @@ public class BattleshipApp extends SimpleApplication implements BattleshipClient
*/
public static void main(String[] args) {
new BattleshipApp().start();
}
/**
@@ -198,15 +198,6 @@ DialogManager getDialogManager() {
return dialogManager;
}
/**
* Returns the GameMusic responsible for playing music.
*
* @return The {@link GameMusic} instance.
*/
GameMusic getGameMusic() {
return music;
}
/**
* Returns the game logic handler for the client.
*
@@ -239,8 +230,7 @@ public void simpleInitApp() {
setupStates();
setupGui();
serverConnection.connect();
music = new GameMusic(this, "Sound/Music/battleship.ogg");
backgroundMusic = new BackgroundMusic(this, "Sound/Effects/BackgroundMusic/boss_battle_#2_metal_opening.wav");
}
/**
@@ -442,4 +432,12 @@ void errorDialog(String errorMessage) {
.build()
.open();
}
/**
* Getter for the BackgroundMusic
* @return the BackgroundMusic
*/
public BackgroundMusic getBackgroundMusic(){
return backgroundMusic;
}
}

View File

@@ -1,170 +0,0 @@
////////////////////////////////////////
// Programming project code
// UniBw M, 2022, 2023, 2024
// www.unibw.de/inf2
// (c) Mark Minas (mark.minas@unibw.de)
////////////////////////////////////////
package pp.battleship.client;
import com.jme3.app.Application;
import com.jme3.app.state.AbstractAppState;
import com.jme3.app.state.AppStateManager;
import com.jme3.asset.AssetLoadException;
import com.jme3.asset.AssetNotFoundException;
import com.jme3.audio.AudioData;
import com.jme3.audio.AudioNode;
import com.jme3.audio.AudioSource;
import pp.battleship.notification.GameEventListener;
import pp.battleship.notification.SoundEvent;
import java.lang.System.Logger;
import java.lang.System.Logger.Level;
import java.util.prefs.Preferences;
import static pp.util.PreferencesUtils.getPreferences;
/**
* An application state that plays music.
*/
public class GameMusic extends AbstractAppState implements GameEventListener {
private static final Logger LOGGER = System.getLogger(GameMusic.class.getName());
private static final Preferences PREFERENCES = getPreferences(GameMusic.class);
private static final String ENABLED_PREF = "toggle"; //NON-NLS
private static final String SLIDER_PREF = "slider"; //NON-NLS
private AudioNode music;
private boolean enabled;
private float volume;
public GameMusic(Application app, String musicFilePath) {
this.enabled = PREFERENCES.getBoolean(ENABLED_PREF, true);
this.volume = PREFERENCES.getFloat(SLIDER_PREF, 2.0f);
music = new AudioNode(app.getAssetManager(), musicFilePath, AudioData.DataType.Stream);
music.setLooping(true);
music.setPositional(false);
music.setVolume(1.0f);
if(enabled) {
start();
}
}
/**
* Checks if music is enabled in the preferences.
*
* @return {@code true} if music is enabled, {@code false} otherwise.
*/
public static boolean enabledInPreferences() {
return PREFERENCES.getBoolean(ENABLED_PREF, true);
}
/**
* Returns the volume value that is set in the preferences.
*
* @return {@code true} if sound is enabled, {@code false} otherwise.
*/
public static float volumeInPreferences() {
return PREFERENCES.getFloat(SLIDER_PREF, 2.0f);
}
/**
* Toggles the game music on or off.
*/
public void toggleMusic() {
setEnabled(!isEnabled());
}
/**
* Sets the enabled state of this AppState.
* Overrides {@link AbstractAppState#setEnabled(boolean)}
*
* @param enabled {@code true} to enable the AppState, {@code false} to disable it.
*/
@Override
public void setEnabled(boolean enabled) {
super.setEnabled(enabled);
if(enabled) {
start();
} else {
stop();
}
LOGGER.log(Level.INFO, "Music enabled: {0}", enabled); //NON-NLS
PREFERENCES.putBoolean(ENABLED_PREF, enabled);
}
/**
* Sets the volume for the music
*
* @param volume the new volume to be set
*/
public void setVolume(float volume) {
this.volume = volume;
music.setVolume(volume);
LOGGER.log(Level.INFO, "Volume set to: {0}", volume); //NON-NLS
PREFERENCES.putFloat(SLIDER_PREF, volume);
}
/**
* Loads a music from the specified file.
*
* @param app The application
* @param name The name of the sound file.
* @return The loaded AudioNode.
*/
private AudioNode loadSound(Application app, String name) {
try {
final AudioNode sound = new AudioNode(app.getAssetManager(), name, AudioData.DataType.Buffer);
sound.setLooping(false);
sound.setPositional(false);
return sound;
}
catch (AssetLoadException | AssetNotFoundException ex) {
LOGGER.log(Level.ERROR, ex.getMessage(), ex);
}
return null;
}
/**
* Starts the music.
*/
public void start() {
if (enabled && (music.getStatus() == AudioSource.Status.Stopped || music.getStatus() == AudioSource.Status.Paused)) {
music.play();
}
}
/**
* Stops the music.
*/
public void stop() {
if (music.getStatus() == AudioSource.Status.Playing) {
music.stop();
}
}
/**
* This method returns the volume
*
* @return float the current volume
*/
public float getVolume() {
return volume;
}
/**
* Returns if music should be played or not
*
* @return boolean value if music is enabled
*/
public boolean isMusicEnabled() {
return enabled;
}
}

View File

@@ -34,7 +34,7 @@ public class GameSound extends AbstractAppState implements GameEventListener {
private AudioNode splashSound;
private AudioNode shipDestroyedSound;
private AudioNode explosionSound;
private AudioNode missleSound;
private AudioNode missileLaunch;
/**
* Checks if sound is enabled in the preferences.
@@ -45,13 +45,6 @@ public static boolean enabledInPreferences() {
return PREFERENCES.getBoolean(ENABLED_PREF, true);
}
/**
* Toggles the game sound on or off.
*/
public void toggleSound() {
setEnabled(!isEnabled());
}
/**
* Sets the enabled state of this AppState.
* Overrides {@link com.jme3.app.state.AbstractAppState#setEnabled(boolean)}
@@ -79,7 +72,7 @@ public void initialize(AppStateManager stateManager, Application app) {
shipDestroyedSound = loadSound(app, "Sound/Effects/sunken.wav"); //NON-NLS
splashSound = loadSound(app, "Sound/Effects/splash.wav"); //NON-NLS
explosionSound = loadSound(app, "Sound/Effects/explosion.wav"); //NON-NLS
missleSound = loadSound(app, "Sound/Effects/missle.wav");
missileLaunch = loadSound(app, "Sound/Effects/missileLaunch.wav");
}
/**
@@ -95,13 +88,19 @@ private AudioNode loadSound(Application app, String name) {
sound.setLooping(false);
sound.setPositional(false);
return sound;
}
catch (AssetLoadException | AssetNotFoundException ex) {
} catch (AssetLoadException | AssetNotFoundException ex) {
LOGGER.log(Level.ERROR, ex.getMessage(), ex);
}
return null;
}
/**
* Plays the missile launch sound effect.
*/
public void missileLaunch() {
missileLaunch.playInstance();
}
/**
* Plays the splash sound effect.
*/
@@ -110,14 +109,6 @@ public void splash() {
splashSound.playInstance();
}
/**
* Plays the missle flyby sound effect.
*/
public void flyBy() {
if (isEnabled() && missleSound != null)
missleSound.playInstance();
}
/**
* Plays the explosion sound effect.
*/
@@ -134,13 +125,17 @@ public void shipDestroyed() {
shipDestroyedSound.playInstance();
}
/**
* Checks the according case for the soundeffect
* @param event the received event
*/
@Override
public void receivedEvent(SoundEvent event) {
switch (event.sound()) {
case EXPLOSION -> explosion();
case SPLASH -> splash();
case DESTROYED_SHIP -> shipDestroyed();
case MISSLE_FLYBY -> flyBy();
case MISSILE_LAUNCH -> missileLaunch();
}
}
}

View File

@@ -7,12 +7,17 @@
package pp.battleship.client;
import com.simsilica.lemur.*;
import com.simsilica.lemur.core.VersionedReference;
import com.simsilica.lemur.Button;
import com.simsilica.lemur.Checkbox;
import com.simsilica.lemur.Label;
import com.simsilica.lemur.style.ElementId;
import pp.dialog.Dialog;
import pp.dialog.StateCheckboxModel;
import pp.dialog.TextInputDialog;
import com.simsilica.lemur.DefaultRangedValueModel;
import com.simsilica.lemur.Slider;
import com.simsilica.lemur.core.VersionedReference;
import java.io.File;
import java.io.IOException;
@@ -32,7 +37,6 @@ class Menu extends Dialog {
private final BattleshipApp app;
private final Button loadButton = new Button(lookup("menu.map.load"));
private final Button saveButton = new Button(lookup("menu.map.save"));
private final VersionedReference<Double> volumeRef;
/**
@@ -46,24 +50,24 @@ public Menu(BattleshipApp app) {
addChild(new Label(lookup("battleship.name"), new ElementId("header"))); //NON-NLS
addChild(new Checkbox(lookup("menu.sound-enabled"),
new StateCheckboxModel(app, GameSound.class)));
addChild(loadButton)
.addClickCommands(s -> ifTopDialog(this::loadDialog));
addChild(saveButton)
.addClickCommands(s -> ifTopDialog(this::saveDialog));
Checkbox musicToggle = new Checkbox(lookup("menu.music.toggle"));
musicToggle.setChecked(app.getGameMusic().isMusicEnabled());
musicToggle.setChecked(app.getBackgroundMusic().isMusicEnabled());
musicToggle.addClickCommands(s -> toggleMusic());
addChild(musicToggle);
Slider volumeSlider = new Slider(lookup("menu.music.slider"));
volumeSlider.setModel(new DefaultRangedValueModel(0.0 , 4.0, app.getGameMusic().getVolume()));
volumeSlider.setDelta(0.4);
Slider volumeSlider = new Slider();
volumeSlider.setModel(new DefaultRangedValueModel(0.0 , 2.0, app.getBackgroundMusic().getVolume()));
volumeSlider.setDelta(0.1);
addChild(volumeSlider);
volumeRef = volumeSlider.getModel().createReference();
addChild(loadButton)
.addClickCommands(s -> ifTopDialog(this::loadDialog));
addChild(saveButton)
.addClickCommands(s -> ifTopDialog(this::saveDialog));
addChild(new Button(lookup("menu.return-to-game")))
.addClickCommands(s -> ifTopDialog(this::close));
addChild(new Button(lookup("menu.quit")))
@@ -72,33 +76,39 @@ public Menu(BattleshipApp app) {
}
/**
* Updates the state of the load/save buttons and volume based on the game logic.
* Updates the volume if there is a change and adjusts it accordingly.
* @param tmp unused time parameter
*/
@Override
public void update() {
loadButton.setEnabled(app.getGameLogic().mayLoadMap());
saveButton.setEnabled(app.getGameLogic().maySaveMap());
if(volumeRef.update()){
public void update(float tmp){
if(volumeRef.update()) {
double newVolume = volumeRef.get();
adjustVolume(newVolume);
}
}
/**
* this method adjust the volume for the background music
*
* @param volume is the double value of the volume
* Adjusts the background music volume to the specified value.
* @param newVolume the new volume level
*/
private void adjustVolume(double volume) {
app.getGameMusic().setVolume((float) volume);
private void adjustVolume(double newVolume) {
app.getBackgroundMusic().setVolume((float) newVolume);
}
/**
* this method toggles the background music on and off
* Toggles the background music on or off.
*/
private void toggleMusic() {
app.getGameMusic().toggleMusic();
private void toggleMusic(){
app.getBackgroundMusic().toogleMusic();
}
/**
* Updates the state of the load and save buttons based on the game logic.
*/
@Override
public void update() {
loadButton.setEnabled(app.getGameLogic().mayLoadMap());
saveButton.setEnabled(app.getGameLogic().maySaveMap());
}
/**

View File

@@ -7,11 +7,9 @@
package pp.battleship.client;
import com.simsilica.lemur.Checkbox;
import com.simsilica.lemur.Container;
import com.simsilica.lemur.Label;
import com.simsilica.lemur.TextField;
import com.simsilica.lemur.*;
import com.simsilica.lemur.component.SpringGridLayout;
import pp.battleship.client.server.BattleshipServer;
import pp.dialog.Dialog;
import pp.dialog.DialogBuilder;
import pp.dialog.SimpleDialog;
@@ -38,7 +36,10 @@ class NetworkDialog extends SimpleDialog {
private int portNumber;
private Future<Object> connectionFuture;
private Dialog progressDialog;
private boolean hostServer = false;
private BattleshipServer battleshipServer;
private boolean GUI = true;
private Container menu;
private boolean serverToggle = false;
/**
* Constructs a new NetworkDialog.
@@ -52,89 +53,127 @@ class NetworkDialog extends SimpleDialog {
host.setPreferredWidth(400f);
port.setSingleLine(true);
Checkbox serverHost = new Checkbox(lookup("menu.host"));
serverHost.setChecked(false);
serverHost.addClickCommands(s -> toggleServerHost());
addChild(serverHost);
this.menu = new Container();
menu();
addChild(menu);
}
final BattleshipApp app = network.getApp();
final Container input = new Container(new SpringGridLayout());
input.addChild(new Label(lookup("host.name") + ": "));
input.addChild(host, 1);
input.addChild(new Label(lookup("port.number") + ": "));
input.addChild(port, 1);
/**
* Main Menu creation
*/
private void menu() {
DialogBuilder.simple(app.getDialogManager())
.setTitle(lookup("server.dialog"))
.setExtension(d -> d.addChild(input))
.setOkButton(lookup("button.connect"), d -> connectLocally())
.setNoButton(lookup("button.cancel"), app::closeApp)
.setOkClose(false)
.setNoClose(false)
.build(this);
Button connectGame = new Button("Multiplayer");
connectGame.addClickCommands(source -> serverConnectGUI());
Checkbox serverHost = new Checkbox("Host own Game");
serverHost.addClickCommands(source -> toggleServer());
menu.addChild(serverHost);
menu.addChild(connectGame);
}
/**
* Logic for the ServerGUI
*/
private void serverConnectGUI() {
LOGGER.log(Level.INFO, "Hosting Server...");
if (GUI) {
host.setSingleLine(true);
host.setPreferredWidth(400f);
port.setSingleLine(true);
final BattleshipApp app = network.getApp();
final Container input = new Container(new SpringGridLayout());
input.addChild(new Label(lookup("host.name") + ": "));
input.addChild(host, 1);
input.addChild(new Label(lookup("port.number") + ": "));
input.addChild(port, 1);
DialogBuilder.simple(app.getDialogManager())
.setTitle(lookup("server.dialog"))
.setExtension(d -> d.addChild(input))
.setOkButton(lookup("button.connect"), d -> connect())
.setOkClose(false)
.build(this);
GUI = false;
}
}
/**
* Connect to server if serverToggle is false hosts otherwise
*/
private void connect(){
if (serverToggle) {
hostServer();
} else {
connectServer();
}
}
/**
* Handles the action for the connect button in the connection dialog.
* Tries to parse the port number and initiate connection to the server.
*/
private void connect() {
private void connectServer() {
LOGGER.log(Level.INFO, "connect to host={0}, port={1}", host, port); //NON-NLS
try {
hostname = host.getText().trim().isEmpty() ? LOCALHOST : host.getText();
portNumber = Integer.parseInt(port.getText());
openProgressDialog();
connectionFuture = network.getApp().getExecutor().submit(this::initNetwork);
}
catch (NumberFormatException e) {
} catch (NumberFormatException e) {
network.getApp().errorDialog(lookup("port.must.be.integer"));
}
}
/**
* Starts a server or if not host connects to one
* Checks if the Server is running or starts the Server and handles Exceptions *
*/
private void connectLocally() {
if(hostServer){
startServer();
private void hostServer() {
if (battleshipServer == null) {
startServer(); // Starts the server in a new thread
try {
Thread.sleep(1000);
Thread.sleep(1000); // Wait for the server to start
} catch (InterruptedException e) {
LOGGER.log(Level.WARNING, e.getMessage(), e.getMessage());
LOGGER.log(Level.WARNING, e.getMessage(), e);
}
}
connect();
// Proceed with connecting to the server
connectServer();
}
/**
* Starts a host server in a new thread
* Toggle Method for Boolean
*/
private void toggleServer(){
serverToggle = !serverToggle;
}
/**
* Allows Client to Start a Server in a new Thread
*/
private void startServer() {
new Thread(() -> {
try{
BattleshipServer battleshipServer = new BattleshipServer();
battleshipServer.run();
try {
// Initialize and run the server
battleshipServer = new BattleshipServer();
battleshipServer.run(Integer.parseInt(port.getText()));
} catch (Exception e) {
LOGGER.log(Level.ERROR,e);
LOGGER.log(Level.ERROR, e);
}
}).start();
}
/**
* Toggles client/host mode
*/
private void toggleServerHost(){
hostServer = !hostServer;
}
/**
* Creates a dialog indicating that the connection is in progress.
*/
private void openProgressDialog() {
progressDialog = DialogBuilder.simple(network.getApp().getDialogManager())
.setText(lookup("label.connecting"))
.build();
.setText(lookup("label.connecting"))
.build();
progressDialog.open();
}
@@ -147,8 +186,7 @@ private Object initNetwork() {
try {
network.initNetwork(hostname, portNumber);
return null;
}
catch (Exception e) {
} catch (Exception e) {
throw new RuntimeException(e);
}
}
@@ -163,11 +201,9 @@ public void update(float delta) {
try {
connectionFuture.get();
success();
}
catch (ExecutionException e) {
} catch (ExecutionException e) {
failure(e.getCause());
}
catch (InterruptedException e) {
} catch (InterruptedException e) {
LOGGER.log(Level.WARNING, "Interrupted!", e); //NON-NLS
Thread.currentThread().interrupt();
}

View File

@@ -0,0 +1,155 @@
package pp.battleship.client.gui;
import com.jme3.asset.AssetManager;
import com.jme3.effect.ParticleEmitter;
import com.jme3.effect.ParticleMesh.Type;
import com.jme3.material.Material;
import com.jme3.math.ColorRGBA;
import com.jme3.math.Vector3f;
import com.jme3.scene.Node;
import com.jme3.scene.control.AbstractControl;
import pp.battleship.client.BattleshipApp;
import pp.battleship.model.Shot;
import java.lang.System.Logger;
import java.lang.System.Logger.Level;
/**
* Manages the visual effects for impact events such as hits and misses.
*/
public class ImpactEffectManager {
private final AssetManager assetManager;
private static final Logger LOGGER = System.getLogger(ImpactEffectManager.class.getName());
private Material particleMaterial;
private BattleshipApp app;
/**
* Constructor to initialize the asset manager via the main application.
*
* @param app The main application instance.
*/
public ImpactEffectManager(BattleshipApp app) {
this.app = app;
this.assetManager = app.getAssetManager();
this.particleMaterial = new Material(assetManager, "Common/MatDefs/Misc/Particle.j3md");
}
/**
* Generates a visual effect for a hit at the specified position.
*
* @param battleshipNode The node where the effect should be attached.
* @param shot The details of the shot where the hit occurred.
*/
public void triggerHitEffect(Node battleshipNode, Shot shot) {
ParticleEmitter hitEffect = createParticleEmitter("HitEffect", 50, ColorRGBA.Orange, ColorRGBA.Red, 0.45f, 0.1f, 1f, 2f);
hitEffect.setLocalTranslation(shot.getY() + 0.5f, 0, shot.getX() + 0.5f);
LOGGER.log(Level.DEBUG, "Hit effect created at position: {0}", hitEffect.getLocalTranslation().toString());
// hitEffect.emitAllParticles();
hitEffect.addControl(new EffectCleanupControl(hitEffect));
app.getRootNode().attachChild(hitEffect);
}
/**
* Creates a visual effect for a missed shot at the specified location.
*
* @param shot The details of the missed shot.
* @return The particle emitter representing the miss effect.
*/
public ParticleEmitter triggerMissEffect(Shot shot) {
ParticleEmitter missEffect = createParticleEmitter("MissEffect", 50, ColorRGBA.Blue, ColorRGBA.Cyan, 0.3f, 0.05f, 0.5f, 1.5f);
missEffect.setLocalTranslation(shot.getY() + 0.5f, 0, shot.getX() + 0.5f);
missEffect.addControl(new EffectCleanupControl(missEffect));
return missEffect;
}
/**
* Helper method to create a particle emitter with predefined parameters.
*
* @param name The name of the particle emitter.
* @param count The number of particles to emit.
* @param startColor The initial color of the particles.
* @param endColor The final color of the particles.
* @param startSize The initial size of the particles.
* @param endSize The final size of the particles.
* @param lowLife The minimum lifetime of the particles.
* @param highLife The maximum lifetime of the particles.
* @return The configured ParticleEmitter instance.
*/
private ParticleEmitter createParticleEmitter(String name, int count, ColorRGBA startColor, ColorRGBA endColor, float startSize, float endSize, float lowLife, float highLife) {
ParticleEmitter emitter = new ParticleEmitter(name, Type.Triangle, count);
emitter.setNumParticles(0);
emitter.setMaterial(particleMaterial);
emitter.setImagesX(2);
emitter.setImagesY(2);
emitter.setStartColor(startColor);
emitter.setEndColor(endColor);
emitter.getParticleInfluencer().setInitialVelocity(new Vector3f(0, 1, 0));
emitter.setStartSize(startSize);
emitter.setEndSize(endSize);
emitter.setGravity(0, -0.5f, 0);
emitter.setLowLife(lowLife);
emitter.setHighLife(highLife);
return emitter;
}
/**
* Custom control class to handle the cleanup of particle effects once they are no longer visible.
*/
private static class EffectCleanupControl extends AbstractControl {
private final ParticleEmitter emitter;
private float currentTime = 0;
private final float duration = 3.5f;
/**
* Constructor for managing cleanup of a standalone particle emitter.
*
* @param emitter The particle emitter to manage.
*/
public EffectCleanupControl(ParticleEmitter emitter) {
this.emitter = emitter;
}
/**
* Removes the emitter when all particles are no longer visible.
*
* @param tpf Time per frame.
*/
@Override
protected void controlUpdate(float tpf) {
currentTime += tpf;
if (currentTime <= duration) {
}
if (currentTime >= 1f && currentTime <= 1.1) {
//Start
emitter.setNumParticles(50);
emitter.setParticlesPerSec(50);
}
if (currentTime >= duration){
emitter.setParticlesPerSec(0);
}
if (currentTime >= duration+1f) {
//Ende
spatial.removeFromParent();
emitter.emitAllParticles();
}
}
/**
* No custom rendering needed; particle behavior is handled in controlUpdate.
* @param rm handles rendering, and ViewPort
* @param vp defines the view where the scene is displayed.
*/
@Override
protected void controlRender(com.jme3.renderer.RenderManager rm, com.jme3.renderer.ViewPort vp) {
// No rendering-specific behavior needed for this control.
}
}
}

View File

@@ -8,15 +8,14 @@
package pp.battleship.client.gui;
import com.jme3.math.ColorRGBA;
import com.jme3.math.Vector3f;
import com.jme3.scene.Geometry;
import com.jme3.scene.Node;
import com.jme3.scene.Spatial;
import pp.battleship.model.Battleship;
import pp.battleship.model.IntPoint;
import pp.battleship.model.Shell;
import pp.battleship.model.Shot;
import pp.util.Position;
import java.lang.System.Logger;
/**
* Synchronizes the visual representation of the ship map with the game model.
@@ -29,10 +28,8 @@ class MapViewSynchronizer extends ShipMapSynchronizer {
private static final float SHOT_DEPTH = -2f;
private static final float SHIP_DEPTH = 0f;
private static final float INDENT = 4f;
private static final float SHELL_DEPTH = 8f;
private static final float SHELL_SIZE = 0.75f;
private static final float SHELL_CENTERED_IN_MAP_GRID = 0.0625f;
private static final float SHELL_DEPTH = 8f;
// Colors used for different visual elements
private static final ColorRGBA HIT_COLOR = ColorRGBA.Red;
@@ -117,28 +114,23 @@ public Spatial visit(Battleship ship) {
}
/**
* Creates a visual representation of a shell on the map.
*
* @param shell the Shell object representing the shell in the model
* @return a Spatial representing the shell
* Creates a visual representation (Spatial) for the given shell, attaching a control for its behavior.
* @param shell the shell to visit and visualize
* @return the constructed shell node (Spatial)
*/
@Override
public Spatial visit(Shell shell) {
LOGGER.log(Logger.Level.DEBUG, "Visiting {0}", shell);
final Node shellNode = new Node("shell");
final Position startPosition = view.modelToView(shell.getCurrentPosition().x,shell.getCurrentPosition().z);
final Position p1 = view.modelToView(shell.getX(), shell.getY());
final Position p2 = view.modelToView(shell.getX() + SHELL_SIZE, shell.getY() + SHELL_SIZE);
shellNode.attachChild(view.getApp().getDraw().makeRectangle(startPosition.getX(),startPosition.getY(), SHELL_DEPTH, 30, 30, ColorRGBA.Black));
final Position startPosition = view.modelToView(SHELL_CENTERED_IN_MAP_GRID, SHELL_CENTERED_IN_MAP_GRID);
shellNode.attachChild(view.getApp().getDraw().makeRectangle(startPosition.getX(), startPosition.getY(), SHELL_DEPTH, p2.getX() - p1.getX(), p2.getY() - p1.getY(), ColorRGBA.Magenta));
shellNode.setLocalTranslation(startPosition.getX(), startPosition.getY(), SHELL_DEPTH);
shellNode.addControl(new ShellControlMap(p1, view.getApp(), new IntPoint(shell.getX(), shell.getY())));
shellNode.addControl(new ShellControl(shell, this.view, shell.getLogic()));
return shellNode;
}
/**
* Creates a line geometry representing part of the ship's border.
*

View File

@@ -1,193 +0,0 @@
package pp.battleship.client.gui;
import com.jme3.effect.ParticleEmitter;
import com.jme3.effect.ParticleMesh;
import com.jme3.material.Material;
import com.jme3.math.ColorRGBA;
import com.jme3.math.Vector3f;
import com.jme3.scene.Node;
import com.jme3.scene.control.AbstractControl;
import com.jme3.scene.control.Control;
import pp.battleship.client.BattleshipApp;
import pp.battleship.model.Shot;
public class ParticleHandler {
private final BattleshipApp app;
static final System.Logger LOGGER = System.getLogger(ParticleHandler.class.getName());
private Material material;
/**
* Constructs a new ParticleHandler
*
* @param app the main battleship application
*/
public ParticleHandler(BattleshipApp app) {
this.app = app;
material = new Material(app.getAssetManager(), "Common/MatDefs/Misc/Particle.j3md");
}
/**
* this method is used to create a hit effect at the position of a node
*
* @param node the node of the battleship where the effect should be attached to
* @param shot the shot that hit a target
*/
public void createHitParticles(Node node, Shot shot) {
ParticleEmitter smokeParticles = new ParticleEmitter("Effect", ParticleMesh.Type.Triangle,1000);
smokeParticles.setMaterial(material);
smokeParticles.setImagesX(2);
smokeParticles.setImagesY(2);
smokeParticles.setStartColor(ColorRGBA.Orange);
smokeParticles.setEndColor(ColorRGBA.Black);
smokeParticles.getParticleInfluencer().setInitialVelocity(new Vector3f(0,0.8f,0));
smokeParticles.setStartSize(0.5f);
smokeParticles.setEndSize(0.04f);
smokeParticles.setGravity(0, -0.1f, 0);
smokeParticles.setLowLife(1f);
smokeParticles.setHighLife(4f);
smokeParticles.setParticlesPerSec(0);
smokeParticles.setLocalTranslation(shot.getY() + 0.5f, 0 , shot.getX() + 0.5f);
smokeParticles.emitAllParticles();
ParticleEmitter particles2 = new ParticleEmitter("Effect", ParticleMesh.Type.Triangle,300);
particles2.setMaterial(material);
particles2.setImagesX(2);
particles2.setImagesY(2);
particles2.setStartColor(ColorRGBA.Orange);
particles2.setEndColor(ColorRGBA.Yellow);
particles2.getParticleInfluencer().setInitialVelocity(new Vector3f(0,2,0));
particles2.setStartSize(0.7f);
particles2.setEndSize(0.1f);
particles2.setGravity(0, 0, 0);
particles2.setLowLife(0.5f);
particles2.setHighLife(1.5f);
particles2.setParticlesPerSec(0);
particles2.setLocalTranslation(shot.getY() + 1f, 0 , shot.getX() + 1f);
particles2.emitAllParticles();
ParticleEmitter particles3 = new ParticleEmitter("Effect", ParticleMesh.Type.Triangle,300);
particles3.setMaterial(material);
particles3.setImagesX(1);
particles3.setImagesY(1);
particles3.setStartColor(ColorRGBA.Red);
particles3.setEndColor(ColorRGBA.Gray);
particles3.getParticleInfluencer().setInitialVelocity(new Vector3f(0,0.5f,0));
particles3.setStartSize(0.8f);
particles3.setEndSize(0.1f);
particles3.setGravity(0, 0, 0);
particles3.setLowLife(0.5f);
particles3.setHighLife(0.8f);
particles3.setParticlesPerSec(0);
particles3.setLocalTranslation(shot.getY() + 1f, 0 , shot.getX() + 1f);
particles3.emitAllParticles();
ParticleEmitter flames = new ParticleEmitter("Effect", ParticleMesh.Type.Triangle,300);
flames.setMaterial(material);
flames.setImagesX(1);
flames.setImagesY(1);
flames.setStartColor(ColorRGBA.Red);
flames.setEndColor(ColorRGBA.Orange);
flames.getParticleInfluencer().setInitialVelocity(new Vector3f(0,1.0f,0));
flames.setStartSize(0.4f);
flames.setEndSize(0.1f);
flames.setGravity(0, -0.2f, 0);
flames.setLowLife(0.7f);
flames.setHighLife(1.5f);
flames.setLocalTranslation(shot.getY(), 0 , shot.getX());
flames.setLocalTranslation(flames.getLocalTranslation().subtract(node.getLocalTranslation()));
flames.setParticlesPerSec(70);
node.attachChild(smokeParticles);
smokeParticles.addControl((Control) new ParticleControl(smokeParticles, node));
node.attachChild(particles2);
particles2.addControl((Control) new ParticleControl(particles2, node));
node.attachChild(particles3);
particles3.addControl((Control) new ParticleControl(particles3, node));
//node.attachChild(flames);
//flames.addControl((Control) new ParticleControl(flames, node));
LOGGER.log(System.Logger.Level.DEBUG, "Hit-particles at {0}", smokeParticles.getLocalTranslation().toString());
}
/**
* Creates a miss effect at a certain location
* @param shot the shot that missed
* @return A ParticleEmitter
*/
public ParticleEmitter createMissParticles(Shot shot) {
ParticleEmitter particles = new ParticleEmitter("MissEffect", ParticleMesh.Type.Triangle, 200);
particles.setMaterial(material);
particles.setImagesX(2);
particles.setImagesY(2);
particles.setStartColor(ColorRGBA.Blue);
particles.setEndColor(ColorRGBA.White);
particles.getParticleInfluencer().setInitialVelocity(new Vector3f(0.01f, 3f, 0.01f));
particles.setStartSize(0.05f);
particles.setEndSize(0.4f);
particles.setGravity(0, 2f, 0);
particles.setLowLife(1.0f);
particles.setHighLife(2.2f);
particles.setParticlesPerSec(0);
particles.setLocalTranslation(shot.getY(), -0.5f , shot.getX());
particles.emitAllParticles();
LOGGER.log(System.Logger.Level.DEBUG, "Miss-particles at {0}", particles.getLocalTranslation().toString());
return particles;
}
/**
* This inner class is used to control the effects
*/
private static class ParticleControl extends AbstractControl {
private final ParticleEmitter emitter;
private final Node parentNode;
/**
* this constructor is used to when the particle should be attached to a specific node
*
* @param emitter the Particle emitter to be controlled
* @param parentNode the node to be attached
*/
public ParticleControl(ParticleEmitter emitter, Node parentNode) {
this.emitter = emitter;
this.parentNode = parentNode;
}
/**
* This constructor is used when the particle shouldn't be attached to
* a specific node
*
* @param emitter the Particle emitter to be controlled
*/
public ParticleControl(ParticleEmitter emitter) {
this.emitter = emitter;
this.parentNode = null;
}
/**
* The method which checks if the particle is not rendered anymore so it can be removed
*
* @param tpf time per frame (in seconds)
*/
@Override
protected void controlUpdate(float tpf) {
if (emitter.getParticlesPerSec() == 0 && emitter.getNumVisibleParticles() == 0) {
if (parentNode != null)
parentNode.detachChild(emitter);
}
}
/**
* @param rm the RenderManager rendering the controlled Spatial (not null)
* @param vp the ViewPort being rendered (not null)
*/
@Override
protected void controlRender(com.jme3.renderer.RenderManager rm, com.jme3.renderer.ViewPort vp) {
}
}
}

View File

@@ -10,9 +10,6 @@
import com.jme3.material.Material;
import com.jme3.material.RenderState.BlendMode;
import com.jme3.math.ColorRGBA;
import com.jme3.math.FastMath;
import com.jme3.math.Quaternion;
import com.jme3.math.Vector3f;
import com.jme3.renderer.queue.RenderQueue.ShadowMode;
import com.jme3.scene.Geometry;
import com.jme3.scene.Node;
@@ -34,18 +31,21 @@
*/
class SeaSynchronizer extends ShipMapSynchronizer {
private static final String UNSHADED = "Common/MatDefs/Misc/Unshaded.j3md"; //NON-NLS
private static final String KING_GEORGE_V_MODEL = "Models/KingGeorgeV/KingGeorgeV.j3o"; //NON-NLS
private static final String KING_GEORGE_V_MODEL = "Models/KingGeorgeV/KingGeorgeV.j3o";//NON-NLS
private static final String DESTROYER = "Models/Destroyer/Destroyer.j3o";
private static final String FERRY = "Models/Ferry/13922_Staten_Island_Ferry_V1_l1.obj";
private static final String SMALL = "Models/Small/10634_SpeedBoat_v01_LOD3.obj";
private static final String BOMB = "Models/Bomb/BombGBU.j3o";
private static final String COLOR = "Color"; //NON-NLS
private static final String SHIP = "ship"; //NON-NLS
private static final String SHOT = "shot"; //NON-NLS
private static final ColorRGBA BOX_COLOR = ColorRGBA.Gray;
private static final ColorRGBA SPLASH_COLOR = new ColorRGBA(0f, 0f, 1f, 0.4f);
private static final ColorRGBA HIT_COLOR = new ColorRGBA(1f, 0f, 0f, 0.4f);
private static final String BOMB = "Models/Bomb/Files/Bomb GBU-43B(MOAB).obj";
private final ShipMap map;
private final BattleshipApp app;
private final ParticleHandler handler;
private ImpactEffectManager effectHandler;
/**
* Constructs a {@code SeaSynchronizer} object with the specified application, root node, and ship map.
@@ -58,41 +58,10 @@ public SeaSynchronizer(BattleshipApp app, Node root, ShipMap map) {
super(app.getGameLogic().getOwnMap(), root);
this.app = app;
this.map = map;
handler = new ParticleHandler(app);
effectHandler = new ImpactEffectManager(app);
addExisting();
}
/**
* Visits a {@link Shell} and creates a graphical representation of it.
*
* @param shell the shell to be represented
* @return the graphical representation of the shell
*/
@Override
public Spatial visit(Shell shell) {
final Node node = new Node("shell");
final Spatial model = app.getAssetManager().loadModel(BOMB);
model.rotate(-PI/2, 0, 0);
model.scale(0.09f);
model.setShadowMode(ShadowMode.CastAndReceive);
model.move(0, 0, 0);
node.attachChild(model);
final float x = shell.getY();
final float z = shell.getX();
node.setLocalTranslation(x, 8f, z);
ShellControll control = new ShellControll(shell, app);
node.addControl(control);
return node;
}
/**
* Visits a {@link Shot} and creates a graphical representation of it.
* If the shot is a hit, it attaches the representation to the ship node.
@@ -103,7 +72,7 @@ public Spatial visit(Shell shell) {
*/
@Override
public Spatial visit(Shot shot) {
return shot.isHit() ? handleHit(shot) : handler.createMissParticles(shot);
return shot.isHit() ? handleHit(shot) : effectHandler.triggerMissEffect(shot);
}
/**
@@ -111,14 +80,15 @@ public Spatial visit(Shot shot) {
* contains the ship model as a child so that it moves with the ship.
*
* @param shot a hit
* @return always null to prevent the representation from being sattached
* @return always null to prevent the representation from being attached
* to the items node as well
*/
private Spatial handleHit(Shot shot) {
final Battleship ship = requireNonNull(map.findShipAt(shot), "Missing ship");
final Node shipNode = requireNonNull((Node) getSpatial(ship), "Missing ship node");
handler.createHitParticles(shipNode, shot);
System.out.println(shot.getX() + " " + shot.getY());
effectHandler.triggerHitEffect(shipNode, shot);
return null;
}
@@ -139,7 +109,7 @@ private Geometry createCylinder(Shot shot) {
geometry.setMaterial(createColoredMaterial(color));
geometry.rotate(HALF_PI, 0f, 0f);
// compute the center of the shot in world coordinates
geometry.setLocalTranslation(shot.getY() + 0.5f, 0f, shot.getX() + 0.5f);
return geometry;
@@ -165,41 +135,42 @@ public Spatial visit(Battleship ship) {
return node;
}
@Override
public Spatial visit(Shell shell) {
final Spatial bombModel = app.getAssetManager().loadModel(BOMB);
// Apply transformations to the bomb model (scale, rotate, etc. if needed)
bombModel.scale(0.05f);
bombModel.rotate(-HALF_PI, 0f, 0f);
// Set the position of the bomb at the shell's current position
bombModel.setLocalTranslation(shell.getCurrentPosition());
// Add a control to animate the bomb's movement (similar to the previous cylinder animation)
bombModel.addControl(new ShellControl(shell,shell.getLogic()));
return bombModel;
}
/**
* Creates the appropriate graphical representation of the specified battleship.
* The representation is either a detailed model or a simple box based on the length of the ship.
* The representation is a detailed model based on the length of the ship.
*
* @param ship the battleship to be represented
* @return the spatial representing the battleship
*/
private Spatial createShip(Battleship ship) {
final int len = ship.getLength();
Quaternion q0 = new Quaternion();
Quaternion q1 = new Quaternion();
q1.fromAngleAxis(PI/2, new Vector3f(1, 0, 0));
Quaternion q2 = new Quaternion();
q2.fromAngleAxis(PI/2, new Vector3f(1, 0, 0));
switch (len) {
case 1 -> {
return createBattleship(ship, "Models/Uboat/uboat.j3o", 0.2f, new Vector3f(0.0f, -0.1f, 0.0f), q0);
}
case 2 -> {
return createBattleship(ship, "Models/KingGeorgeV/KingGeorgeV.j3o", 1.0f, new Vector3f(0.0f, 0.0f, 0.0f), q0);
}
case 3 -> {
return createBattleship(ship, "Models/EssexClass/essex.j3o", 0.8f, new Vector3f(0.0f, 0.3f, 0.0f), q2);
}
case 4 -> {
return createBattleship(ship, "Models/Container/container.j3o", 0.05f, new Vector3f(0.0f, 0.0f, 0.0f), q1);
}
default -> {
return createBox(ship);
}
// return ship.getLength() == 4 ? createBattleship(ship) : createBox(ship);
if (ship.getLength() == 4) {
return createBattleship(ship);
} else if (ship.getLength() == 3) {
return createBigShip(ship);
} else if (ship.getLength() == 2) {
return createMediumShip(ship);
} else if (ship.getLength() == 1) {
return createSmallShip(ship);
}
return createBattleship(ship);
}
/**
@@ -239,22 +210,63 @@ private Material createColoredMaterial(ColorRGBA color) {
}
/**
* Creates a 3D model to represent a "battleship".
* Creates a detailed 3D model to represent a "King George V" battleship.
*
* @param ship the battleship to be represented
* @param path the battleship to be represented
* @param scale the battleship to be represented
* @param translation the battleship to be represented
* @param rotation the battleship to be represented
* @return the spatial representing the battleship
* @return the spatial representing the "King George V" battleship
*/
private Spatial createBattleship(Battleship ship, String path, float scale, Vector3f translation, Quaternion rotation) {
final Spatial model = app.getAssetManager().loadModel(path);
private Spatial createBattleship(Battleship ship) {
final Spatial model = app.getAssetManager().loadModel(KING_GEORGE_V_MODEL);
model.rotate(-HALF_PI, calculateRotationAngle(ship.getRot()), 0f);
model.rotate(rotation);
model.scale(scale);
model.setLocalTranslation(translation);
model.scale(1.48f);
model.setShadowMode(ShadowMode.CastAndReceive);
return model;
}
/**
* Creates a detailed 3D model to represent a "Big Ship"
* @param ship The Battleship object with position and rotation info.
* @return the spatial representing the "Big Ship" battleship
*/
private Spatial createBigShip(Battleship ship) {
final Spatial model = app.getAssetManager().loadModel(DESTROYER);
model.move(0,0.4f,0);
model.rotate(-HALF_PI, calculateRotationAngle(ship.getRot()) + HALF_PI, 0f);
model.scale(0.0001f);
model.setShadowMode(ShadowMode.CastAndReceive);
return model;
}
/**
* Creates a detailed 3D model to represent a "Medium Ship"
* @param ship The Battleship object with position and rotation info.
* @return the spatial representing the "Medium Ship" battleship
*/
private Spatial createMediumShip(Battleship ship) {
final Spatial model = app.getAssetManager().loadModel(FERRY);
model.move(0,0.25f,0);
model.rotate(-HALF_PI, calculateRotationAngle(ship.getRot()), 0f);
model.scale(0.00025f);
model.setShadowMode(ShadowMode.CastAndReceive);
return model;
}
/**
* Creates a detailed 3D model to represent a "Small Ship"
* @param ship The Battleship object with position and rotation info.
* @return the spatial representing the "Small Ship" battleship
*/
private Spatial createSmallShip(Battleship ship) {
final Spatial model = app.getAssetManager().loadModel(SMALL);
model.rotate(-HALF_PI, calculateRotationAngle(ship.getRot()) + HALF_PI, 0f);
model.scale(0.0009f);
model.setShadowMode(ShadowMode.CastAndReceive);
return model;

View File

@@ -0,0 +1,96 @@
////////////////////////////////////////
// Programming project code
// UniBw M, 2022, 2023, 2024
// www.unibw.de/inf2
// (c) Mark Minas (mark.minas@unibw.de)
////////////////////////////////////////
package pp.battleship.client.gui;
import com.jme3.renderer.RenderManager;
import com.jme3.renderer.ViewPort;
import com.jme3.scene.control.AbstractControl;
import pp.battleship.game.client.ClientGameLogic;
import pp.battleship.message.server.EffectMessage;
import pp.battleship.model.Shell;
import pp.battleship.notification.Sound;
import pp.util.Position;
/**
* Controls the oscillating pitch motion of a battleship model in the game.
* The ship oscillates to simulate a realistic movement on water, based on its orientation and length.
*/
class ShellControl extends AbstractControl {
private final Shell shell;
private MapView view;
private final ClientGameLogic logic;
private final EffectMessage msg;
private boolean hasPlayedSound = false;
/**
* Constructs a new ShipControl instance for the specified Battleship.
* The ship's orientation determines the axis of rotation, while its length influences
* the cycle duration and amplitude of the oscillation.
*
* @param shell the Battleship object to control
*/
public ShellControl(Shell shell, ClientGameLogic clientGameLogic) {
this.shell = shell;
this.logic = clientGameLogic;
this.msg = shell.getMsg();
}
/**
* Initializes ShellControl with a shell, map view, and game logic.
* @param shell the shell to be controlled
* @param view the map view to display the shell
* @param clientGameLogic the game logic instance
*/
public ShellControl(Shell shell, MapView view, ClientGameLogic clientGameLogic) {
this.shell = shell;
this.view = view;
this.logic = clientGameLogic;
this.msg = shell.getMsg();
}
/**
* Updates the ship's pitch oscillation each frame. The ship's pitch is adjusted
* to create a continuous tilting motion, simulating the effect of waves.
*
* @param tpf time per frame (in seconds), used to calculate the new pitch angle
*/
@Override
protected void controlUpdate(float tpf) {
if (spatial == null)
return;
if (shell.isFinished() && !hasPlayedSound) {
if (!msg.getShot().isHit())
logic.playSound(Sound.SPLASH);
else if (msg.getDestroyedShip() == null)
logic.playSound(Sound.EXPLOSION);
else
logic.playSound(Sound.DESTROYED_SHIP);
hasPlayedSound = true;
}
if (view == null) {
shell.updatePosition(tpf);
spatial.setLocalTranslation(shell.getCurrentPosition());
} else {
shell.updatePosition(tpf);
Position pos2d = view.modelToView(shell.getCurrentPosition().x - 0.3f, shell.getCurrentPosition().z - 0.3f);
spatial.setLocalTranslation(pos2d.getY(), pos2d.getX(), 0);
}
}
/**
* Called during rendering, but no operations are needed as this control only affects spatial transformation.
* @param rm the RenderManager rendering the spatial
* @param vp the ViewPort being rendered
*/
@Override
protected void controlRender(RenderManager rm, ViewPort vp) {
// No rendering logic is needed for this control
}
}

View File

@@ -1,67 +0,0 @@
package pp.battleship.client.gui;
import com.jme3.math.Vector3f;
import com.jme3.renderer.RenderManager;
import com.jme3.renderer.ViewPort;
import com.jme3.scene.control.AbstractControl;
import pp.battleship.client.BattleshipApp;
import pp.battleship.message.client.AnimationEndMessage;
import pp.battleship.model.IntPoint;
import pp.util.Position;
/**
* Controls the movement of a shell in a specified position on the battlefield.
* This control updates the shell's position and sends a message when it reaches
* its target location.
*/
public class ShellControlMap extends AbstractControl {
private final Position position; // Target position for the shell
private final IntPoint pos; // Target coordinates as an IntPoint
private static final Vector3f vector = new Vector3f(); // Movement vector
private final BattleshipApp app; // Reference to the main application
/**
* Constructs a ShellControlMap object with the specified target position,
* application instance, and target coordinates.
*
* @param position The target Position for the shell.
* @param app The BattleshipApp instance managing the game logic.
* @param pos The IntPoint representing the target coordinates of the shell.
*/
public ShellControlMap(Position position, BattleshipApp app, IntPoint pos) {
super();
this.position = position;
this.pos = pos;
this.app = app;
vector.set(new Vector3f(position.getX(), position.getY(), 0));
}
/**
* Updates the shell's position based on the time per frame.
* If the shell reaches or exceeds the target position, it detaches
* the shell from the scene and sends an animation end message.
*
* @param tpf Time per frame, used to calculate movement.
*/
@Override
protected void controlUpdate(float tpf) {
spatial.move(vector.mult(tpf));
if (spatial.getLocalTranslation().getX() >= position.getX() &&
spatial.getLocalTranslation().getY() >= position.getY()) {
spatial.getParent().detachChild(spatial);
app.getGameLogic().send(new AnimationEndMessage(pos));
}
}
/**
* Renders the shell control. This method can be overridden to implement
* custom rendering behavior, but it is currently empty.
*
* @param rm The RenderManager for rendering the control.
* @param vp The ViewPort where the control is rendered.
*/
@Override
protected void controlRender(RenderManager rm, ViewPort vp) {
// No rendering logic implemented for ShellControlMap
}
}

View File

@@ -1,62 +0,0 @@
package pp.battleship.client.gui;
import com.jme3.renderer.RenderManager;
import com.jme3.renderer.ViewPort;
import com.jme3.scene.control.AbstractControl;
import pp.battleship.client.BattleshipApp;
import pp.battleship.message.client.AnimationEndMessage;
import pp.battleship.model.IntPoint;
import pp.battleship.model.Shell;
import java.util.logging.Logger;
/**
* Controls the movement and behavior of a shell in the battleship game.
* This control updates the position of the shell and sends a message
* when the shell reaches the ground.
*/
public class ShellControll extends AbstractControl {
private final Shell shell;
private final BattleshipApp app;
private static final float MOVE_SPEED = 20.0f; // Speed at which the shell moves
/**
* Constructs a ShellControll object with the specified shell and application instance.
*
* @param shell The Shell instance to control.
* @param app The BattleshipApp instance managing the game logic.
*/
public ShellControll(Shell shell, BattleshipApp app) {
this.shell = shell;
this.app = app;
}
/**
* Updates the shell's position based on the time per frame.
* If the shell's position falls below a certain threshold,
* it detaches the shell from the scene and sends an animation end message.
*
* @param tpf Time per frame, used to calculate movement.
*/
@Override
protected void controlUpdate(float tpf) {
spatial.move(0, -MOVE_SPEED * tpf, 0);
if (spatial.getLocalTranslation().getY() <= 0.1f) {
spatial.getParent().detachChild(spatial);
app.getGameLogic().send(new AnimationEndMessage(new IntPoint(shell.getX(), shell.getY())));
}
}
/**
* Renders the shell control. This method can be overridden to implement
* custom rendering behavior, but it is currently empty.
*
* @param rm The RenderManager for rendering the control.
* @param vp The ViewPort where the control is rendered.
*/
@Override
protected void controlRender(RenderManager rm, ViewPort vp) {
// No rendering logic implemented for ShellControll
}
}

View File

@@ -14,6 +14,10 @@
import com.jme3.scene.control.AbstractControl;
import pp.battleship.model.Battleship;
import java.lang.System.Logger;
import java.lang.System.Logger.Level;
import static pp.util.FloatMath.DEG_TO_RAD;
import static pp.util.FloatMath.TWO_PI;
import static pp.util.FloatMath.sin;
@@ -23,12 +27,6 @@
* The ship oscillates to simulate a realistic movement on water, based on its orientation and length.
*/
class ShipControl extends AbstractControl {
/**
* The sinking height, after wich the ship will get removed
*/
private static final Float SINKING_HEIGHT = -0.6f;
/**
* The axis of rotation for the ship's pitch (tilting forward and backward).
*/
@@ -53,11 +51,14 @@ class ShipControl extends AbstractControl {
* The current time within the oscillation cycle, used to calculate the ship's pitch angle.
*/
private float time;
/**
* The ship, that the ShipControl controls
* The current Ship
*/
private final Battleship ship;
private final Battleship battleship;
/**
* Logger for logging messages related to ShipControl operations.
*/
static final Logger LOGGER = System.getLogger(ShipControl.class.getName());
/**
* Constructs a new ShipControl instance for the specified Battleship.
@@ -67,8 +68,7 @@ class ShipControl extends AbstractControl {
* @param ship the Battleship object to control
*/
public ShipControl(Battleship ship) {
this.ship = ship;
battleship = ship;
// Determine the axis of rotation based on the ship's orientation
axis = switch (ship.getRot()) {
case LEFT, RIGHT -> Vector3f.UNIT_X;
@@ -76,7 +76,7 @@ public ShipControl(Battleship ship) {
};
// Set the cycle duration and amplitude based on the ship's length
cycle = ship.getLength() * 2f;
cycle = battleship.getLength() * 2f;
amplitude = 5f * DEG_TO_RAD / ship.getLength();
}
@@ -91,24 +91,23 @@ protected void controlUpdate(float tpf) {
// If spatial is null, do nothing
if (spatial == null) return;
if (ship.isDestroyed() && spatial.getLocalTranslation().getY() < SINKING_HEIGHT) { // removes the ship, if it is completely sunk
spatial.getParent().detachChild(spatial);
}
else if (ship.isDestroyed() && spatial.getLocalTranslation().getY() >= SINKING_HEIGHT) { // sink the ship, if it's not completely sunk
spatial.move(0, tpf * -0.03f, 0);
}
// Update the time within the oscillation cycle
time = (time + tpf) % cycle;
if (battleship.isDestroyed() && spatial.getLocalTranslation().getY() <= -0.6f) {
LOGGER.log(Level.INFO, "Ship removed {0}", spatial.getName());
spatial.getParent().detachChild(spatial);
} else if (battleship.isDestroyed()) {
spatial.move(0, -0.05f * tpf, 0);
} else {
// Update the time within the oscillation cycle
time = (time + tpf) % cycle;
// Calculate the current angle of the oscillation
final float angle = amplitude * sin(time * TWO_PI / cycle);
// Apply the pitch rotation to the spatial
spatial.setLocalRotation(pitch);
}
// Update the pitch Quaternion with the new angle
pitch.fromAngleAxis(angle, axis);
// Apply the pitch rotation to the spatial
spatial.setLocalRotation(pitch);
}
/**

View File

@@ -5,7 +5,7 @@
// (c) Mark Minas (mark.minas@unibw.de)
////////////////////////////////////////
package pp.battleship.client;
package pp.battleship.client.server;
import com.jme3.network.*;
import com.jme3.network.serializing.Serializer;
@@ -13,11 +13,13 @@
import pp.battleship.game.server.Player;
import pp.battleship.game.server.ServerGameLogic;
import pp.battleship.game.server.ServerSender;
import pp.battleship.message.client.AnimationEndMessage;
import pp.battleship.message.client.ClientMessage;
import pp.battleship.message.client.MapMessage;
import pp.battleship.message.client.ShootMessage;
import pp.battleship.message.server.*;
import pp.battleship.message.server.EffectMessage;
import pp.battleship.message.server.GameDetails;
import pp.battleship.message.server.ServerMessage;
import pp.battleship.message.server.StartBattleMessage;
import pp.battleship.model.Battleship;
import pp.battleship.model.IntPoint;
import pp.battleship.model.Shot;
@@ -38,7 +40,6 @@ public class BattleshipServer implements MessageListener<HostedConnection>, Conn
private static final Logger LOGGER = System.getLogger(BattleshipServer.class.getName());
private static final File CONFIG_FILE = new File("server.properties");
private final BattleshipConfig config = new BattleshipConfig();
private Server myServer;
private final ServerGameLogic logic;
private final BlockingQueue<ReceivedMessage> pendingMessages = new LinkedBlockingQueue<>();
@@ -55,32 +56,35 @@ public class BattleshipServer implements MessageListener<HostedConnection>, Conn
}
}
/**
* Starts the Battleships server.
*/
public static void main(String[] args) {
new BattleshipServer().run();
}
/**
* Creates the server.
*/
BattleshipServer() {
public BattleshipServer() {
BattleshipConfig config = new BattleshipConfig();
config.readFromIfExists(CONFIG_FILE);
LOGGER.log(Level.INFO, "Configuration: {0}", config); //NON-NLS
logic = new ServerGameLogic(this, config);
}
public void run() {
startServer();
/**
* Starts the server on the given port and continuously processes incoming messages.
* @param port the port to start the server on
*/
public void run(int port) {
startServer(port);
while (true)
processNextMessage();
}
private void startServer() {
/**
* Initializes and starts the server on the specified port, handling exceptions if the server fails to start.
* @param port the port to start the server on
*/
private void startServer(int port) {
try {
LOGGER.log(Level.INFO, "Starting server..."); //NON-NLS
myServer = Network.createServer(config.getPort());
myServer = Network.createServer(port);
initializeSerializables();
myServer.start();
registerListeners();
@@ -92,6 +96,9 @@ private void startServer() {
}
}
/**
* Retrieves and processes the next message from the queue, handling interruptions during the wait.
*/
private void processNextMessage() {
try {
pendingMessages.take().process(logic);
@@ -102,10 +109,10 @@ private void processNextMessage() {
}
}
/**
* Processes the next message from the queue, handling interruptions during message retrieval.
*/
private void initializeSerializables() {
Serializer.registerClass(AnimationEndMessage.class);
Serializer.registerClass(AnimationStartMessage.class);
Serializer.registerClass(SwitchBattleState.class);
Serializer.registerClass(GameDetails.class);
Serializer.registerClass(StartBattleMessage.class);
Serializer.registerClass(MapMessage.class);
@@ -116,13 +123,20 @@ private void initializeSerializables() {
Serializer.registerClass(Shot.class);
}
/**
* Registers message and connection listeners for the server.
*/
private void registerListeners() {
myServer.addMessageListener(this, AnimationEndMessage.class);
myServer.addMessageListener(this, MapMessage.class);
myServer.addMessageListener(this, ShootMessage.class);
myServer.addConnectionListener(this);
}
/**
* Handles received messages, logging the source and adding client messages to the pending queue.
* @param source the connection the message was received from
* @param message the received message
*/
@Override
public void messageReceived(HostedConnection source, Message message) {
LOGGER.log(Level.INFO, "message received from {0}: {1}", source.getId(), message); //NON-NLS
@@ -130,12 +144,22 @@ public void messageReceived(HostedConnection source, Message message) {
pendingMessages.add(new ReceivedMessage(clientMessage, source.getId()));
}
/**
* Handles a new connection by logging it and adding a new player to the game logic.
* @param server the server receiving the connection
* @param hostedConnection the newly added connection
*/
@Override
public void connectionAdded(Server server, HostedConnection hostedConnection) {
LOGGER.log(Level.INFO, "new connection {0}", hostedConnection); //NON-NLS
logic.addPlayer(hostedConnection.getId());
}
/**
* Handles the removal of a connection by logging it, checking if it belongs to an active player, and exiting if necessary.
* @param server the server losing the connection
* @param hostedConnection the removed connection
*/
@Override
public void connectionRemoved(Server server, HostedConnection hostedConnection) {
LOGGER.log(Level.INFO, "connection closed: {0}", hostedConnection); //NON-NLS
@@ -148,6 +172,10 @@ public void connectionRemoved(Server server, HostedConnection hostedConnection)
}
}
/**
* Closes all client connections and terminates the server with the given exit value.
* @param exitValue the exit code to terminate the application with
*/
private void exit(int exitValue) { //NON-NLS
LOGGER.log(Level.INFO, "close request"); //NON-NLS
if (myServer != null)

View File

@@ -5,7 +5,7 @@
// (c) Mark Minas (mark.minas@unibw.de)
////////////////////////////////////////
package pp.battleship.client;
package pp.battleship.client.server;
import pp.battleship.message.client.ClientInterpreter;
import pp.battleship.message.client.ClientMessage;

Binary file not shown.

Before

Width:  |  Height:  |  Size: 55 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 55 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 59 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 31 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 54 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 332 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 78 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 74 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 629 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 95 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 49 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 122 KiB

View File

@@ -1,35 +0,0 @@
# Blender 4.2.1 LTS MTL File: 'untitled.blend'
# www.blender.org
newmtl Bridge
Ns 250.000000
Ka 1.000000 1.000000 1.000000
Ks 0.500000 0.500000 0.500000
Ni 1.500000
illum 2
map_Kd Bridge_baseColor.png
map_Ke Bridge_emissive.jpg
map_d Bridge_baseColor.png
map_Bump -bm 1.000000 Bridge_normal.jpg
newmtl Containers
Ns 250.000000
Ka 1.000000 1.000000 1.000000
Ks 0.500000 0.500000 0.500000
Ke 0.000000 0.000000 0.000000
Ni 1.500000
d 1.000000
illum 2
map_Kd Containers_baseColor.jpg
map_Bump -bm 1.000000 Containers_normal.jpg
newmtl Hull
Ns 250.000000
Ka 1.000000 1.000000 1.000000
Ks 0.500000 0.500000 0.500000
Ke 0.000000 0.000000 0.000000
Ni 1.500000
d 1.000000
illum 2
map_Kd Hull_baseColor.jpg
map_Bump -bm 1.000000 Hull_normal.jpg

View File

@@ -0,0 +1,73 @@
newmtl Battleship
illum 4
Kd 0.00 0.00 0.00
Ka 0.00 0.00 0.00
Tf 1.00 1.00 1.00
map_Kd BattleshipC.jpg
Ni 1.00
Ks 0.00 0.00 0.00
Ns 256.00
newmtl blinn1SG
illum 4
Kd 0.50 0.50 0.50
Ka 0.00 0.00 0.00
Tf 1.00 1.00 1.00
Ni 1.00
Ks 0.00 0.00 0.00
Ns 256.00
newmtl blinn2SG
illum 4
Kd 0.50 0.50 0.50
Ka 0.00 0.00 0.00
Tf 1.00 1.00 1.00
Ni 1.00
Ks 0.00 0.00 0.00
Ns 256.00
newmtl blinn3SG
illum 4
Kd 0.50 0.50 0.50
Ka 0.00 0.00 0.00
Tf 1.00 1.00 1.00
Ni 1.00
Ks 0.50 0.50 0.50
Ns 256.00
newmtl blinn4SG
illum 4
Kd 0.50 0.50 0.50
Ka 0.00 0.00 0.00
Tf 1.00 1.00 1.00
Ni 1.00
Ks 0.50 0.50 0.50
Ns 256.00
newmtl blinn5SG
illum 4
Kd 0.50 0.50 0.50
Ka 0.00 0.00 0.00
Tf 1.00 1.00 1.00
Ni 1.00
Ks 0.50 0.50 0.50
Ns 256.00
newmtl blinn6SG
illum 4
Kd 0.50 0.50 0.50
Ka 0.00 0.00 0.00
Tf 1.00 1.00 1.00
Ni 1.00
Ks 0.50 0.50 0.50
Ns 256.00
newmtl blinn7SG
illum 4
Kd 0.50 0.50 0.50
Ka 0.00 0.00 0.00
Tf 1.00 1.00 1.00
Ni 1.00
Ks 0.50 0.50 0.50
Ns 256.00
newmtl blinn8SG
illum 4
Kd 0.50 0.50 0.50
Ka 0.00 0.00 0.00
Tf 1.00 1.00 1.00
Ni 1.00
Ks 0.50 0.50 0.50
Ns 256.00

File diff suppressed because it is too large Load Diff

Binary file not shown.

After

Width:  |  Height:  |  Size: 360 KiB

View File

@@ -0,0 +1,3 @@
based on:
https://free3d.com/3d-model/battleship-v1--611736.html
License: Free Personal Use Only

Binary file not shown.

Before

Width:  |  Height:  |  Size: 35 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 54 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 66 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 264 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 80 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 91 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 33 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 98 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 79 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 79 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 79 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 78 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 78 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 79 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 78 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 78 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 78 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 79 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 79 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 79 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 78 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 78 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 79 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 79 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 79 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 78 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 79 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 79 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 78 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 78 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 78 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 78 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 79 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 79 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 79 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 78 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 78 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 78 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 79 B

Some files were not shown because too many files have changed in this diff Show More