Skip to content

Commit

Permalink
Merge pull request #115 from itsVrushal/vrushalpatilbranch
Browse files Browse the repository at this point in the history
Vrushalpatilbranch
  • Loading branch information
jvondermarck authored Dec 24, 2024
2 parents a49292a + d48b8aa commit 3fd8a57
Show file tree
Hide file tree
Showing 18 changed files with 415 additions and 124 deletions.
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"java.configuration.updateBuildConfiguration": "interactive"
}
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ $> java -jar dinosaur-exploder.jar
## 🛠 Installation Locally

> You need to make sure that [Java FX](https://openjfx.io/openjfx-docs/#introduction) and [JUnit](https://junit.org/junit5/) are installed on your local computer before installing the project.
- To install our project locally, `fork` our repository, and in an empty directory,
type the following command to `clone` your fork :

Expand All @@ -52,7 +53,7 @@ $> git clone [email protected]: <user>/dinosaur-exploder.git

Play the game with these controls:

- ⬆️ <kbd>Up Arrow</kbd>: move spaceship up.
- ⬆️ <kbd>Up Arrow</kbd>: move spaceship up.
- ⬇️ <kbd>Down Arrow</kbd>: move spaceship down.
- ⬅️ <kbd>Left Arrow</kbd>: move spaceship left.
- ➡️ <kbd>Right Arrow</kbd>: move spaceship right.
Expand All @@ -64,8 +65,9 @@ Play the game with these controls:
> We are very much open to contributions - please read our [code of conduct](https://github.com/dylan-power/dinosaur-exploder/blob/main/CODE_OF_CONDUCT.md) and [contribution guidelines](https://github.com/dylan-power/dinosaur-exploder/blob/main/CONTRIBUTING.md) first.
# 🌍 Support

**Any question ? 🦖 Feel free to write us something :**

**Any question ? 🦖 Feel free to write us something :**

- You can ask any question on [GitHub Discussion](https://github.com/dylan-power/dinosaur-exploder/discussions).
- To be updated of everything, follow us on [Twitter](https://twitter.com/DinosaurExplod1).
- You can post an article on our [Website blog](https://dinosaur-exploder.freecluster.eu/forum).
Expand Down
10 changes: 8 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,13 @@
<artifactId>javafx-graphics</artifactId>
<version>17.0.2</version>
</dependency>
<dependency>
<groupId>com.googlecode.json-simple</groupId>
<artifactId>json-simple</artifactId>
<version>1.1.1</version>
</dependency>


</dependencies>

<build>
Expand All @@ -70,8 +77,7 @@
<!-- Default configuration for running with: mvn clean javafx:run -->
<id>default-cli</id>
<configuration>
<mainClass>com.dinosaur.dinosaurexploder/com.dinosaur.dinosaurexploder.DinosaurApp
</mainClass>
<mainClass>com.dinosaur.dinosaurexploder/com.dinosaur.dinosaurexploder.DinosaurApp</mainClass>
<launcher>app</launcher>
<jlinkZipName>app</jlinkZipName>
<jlinkImageName>app</jlinkImageName>
Expand Down
75 changes: 45 additions & 30 deletions src/main/java/com/dinosaur/dinosaurexploder/DinosaurApp.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package com.dinosaur.dinosaurexploder;



import com.almasb.fxgl.app.GameApplication;
import com.almasb.fxgl.app.GameSettings;
import com.almasb.fxgl.dsl.FXGL;
Expand All @@ -18,74 +16,91 @@

import java.util.Locale;
import java.util.ResourceBundle;

/**
* Summary :
* The Factory handles the DinosaurApp,Physics,Settings and Input of all entities in the game
* The Factory handles the DinosaurApp,Physics,Settings and Input of all
* entities in the game
*/
public class DinosaurApp extends GameApplication {
DinosaurGUI gui = new DinosaurGUI();
DinosaurController controller = new DinosaurController();

/**
* Summary :
* This method for the setting the Game GUI
* This method for the setting the Game GUI
* Parameters :
* GameSettings
* GameSettings
*/
@Override
protected void initSettings(GameSettings settings) {
gui.initSettings(settings);
settings.setAppIcon("icon.png");
settings.setTitle("Dinosaur Exploder");
}

/**
* Summary :
* This method is overriding the superclass method to EventHandling for the keyboard events
* This method is overriding the superclass method to EventHandling for the
* keyboard events
*/
@Override
protected void initInput(){
//If the key pressed is the up arrow key, then call move up from the Player Component etc...
protected void initInput() {
// If the key pressed is the up arrow key, then call move up from the Player
// Component etc...
controller.initInput();
}

/**
* Summary :
* This method is overriding the superclass method to initialize the game
* This method is overriding the superclass method to initialize the game
*/
@Override
protected void initGame()
{
protected void initGame() {
controller.initGame();
}

/**
* Summary :
* This method is overriding the superclass method to initialize the physics to the game
* This method is overriding the superclass method to initialize the physics to
* the game
*/
@Override
protected void initPhysics() {
controller.initPhysics();
}

/**
* Summary :
* This method launches the game as it is the main method of the class
* This method launches the game as it is the main method of the class
* Parameters :
* Strings[]
* Strings[]
*/
public static void main(String[] args) {
launch(args);


}

@Override
protected void onPreInit() {
initLanguages();
}

public static void initLanguages() {
// Init languages
getLocalizationService().addLanguageData(Language.ENGLISH,
ResourceBundle.getBundle("assets.properties.texts_en", Locale.ENGLISH));
getLocalizationService().addLanguageData(Language.GERMAN,
ResourceBundle.getBundle("assets.properties.texts_de", Locale.GERMAN));
getLocalizationService().addLanguageData(Language.SPANISH,
ResourceBundle.getBundle("assets.properties.texts_es", new Locale("es", "ES")));
getLocalizationService().addLanguageData(Language.FRENCH,
ResourceBundle.getBundle("assets.properties.texts_fr", Locale.FRENCH));
getLocalizationService().addLanguageData(Language.RUSSIAN,
ResourceBundle.getBundle("assets.properties.texts_ru", new Locale("ru", "RU")));

// Set first entry as default
getLocalizationService().selectedLanguageProperty().unbind();
getLocalizationService().setSelectedLanguage(Language.ENGLISH);
}

@Override
protected void onPreInit() {
initLanguages();
}

public static void initLanguages() {
// Init languages
getLocalizationService().addLanguageData(Language.ENGLISH, ResourceBundle.getBundle("assets.properties.texts", Locale.ENGLISH));
getLocalizationService().addLanguageData(Language.GERMAN, ResourceBundle.getBundle("assets.properties.texts", Locale.GERMAN));

// Set first entry as default
getLocalizationService().selectedLanguageProperty().unbind();
getLocalizationService().setSelectedLanguage(Language.ENGLISH);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,86 +14,90 @@
import javafx.scene.image.Image;
import javafx.util.Duration;

public class PlayerComponent extends Component implements Player{
public class PlayerComponent extends Component implements Player {
private Image spcshpImg = new Image(GameConstants.SPACESHIP_IMAGEPATH);

int movementSpeed = 8;
//entity is not initialized anywhere because it is linked in the factory

// entity is not initialized anywhere because it is linked in the factory
/**
* Summary :
* This method is overriding the superclass method to limit the upSide movement.
* This method is overriding the superclass method to limit the upSide movement.
*/
public void moveUp(){
if(entity.getY() < 0) {
public void moveUp() {
if (entity.getY() < 0) {
System.out.println("Out of bounds");
return;
}
entity.translateY(-movementSpeed);
spawnMovementAnimation();
}

/**
* Summary :
* This method is overriding the superclass method to limit the downSide movement.
* This method is overriding the superclass method to limit the downSide
* movement.
*/
public void moveDown(){
if(!(entity.getY() < DinosaurGUI.HEIGHT - entity.getHeight())) {
public void moveDown() {
if (!(entity.getY() < DinosaurGUI.HEIGHT - entity.getHeight())) {
System.out.println("Out of bounds");
return;
}
entity.translateY(movementSpeed);
spawnMovementAnimation();
}

/**
* Summary :
* This method is overriding the superclass method to limit the rightSide movement.
* This method is overriding the superclass method to limit the rightSide
* movement.
*/
public void moveRight(){
if(!(entity.getX() < DinosaurGUI.WIDTH - entity.getWidth())) {
public void moveRight() {
if (!(entity.getX() < DinosaurGUI.WIDTH - entity.getWidth())) {
System.out.println("Out of bounds");
return;
}
entity.translateX(movementSpeed);
spawnMovementAnimation();
}

/**
* Summary :
* This method is overriding the superclass method to limit the leftSide movement.
* This method is overriding the superclass method to limit the leftSide
* movement.
*/
public void moveLeft(){
if(entity.getX() < 0) {
public void moveLeft() {
if (entity.getX() < 0) {
System.out.println("Out of bounds");
return;
}
entity.translateX(-movementSpeed);
spawnMovementAnimation();
}

/**
* Summary :
* This method is overriding the superclass method to the shooting from the player and spawning of the new bullet
* This method is overriding the superclass method to the shooting from the
* player and spawning of the new bullet
*/
public void shoot(){
public void shoot() {
FXGL.play(GameConstants.SHOOT_SOUND);
Point2D center = entity.getCenter();
Vec2 direction = Vec2.fromAngle(entity.getRotation() -90);
Vec2 direction = Vec2.fromAngle(entity.getRotation() - 90);
Image projImg = new Image(GameConstants.BASE_PROJECTILE_IMAGEPATH);

spawn("basicProjectile",
new SpawnData(center.getX() - (projImg.getWidth()/2) +3, center.getY() - spcshpImg.getHeight()/2)
.put("direction", direction.toPoint2D() )
);
new SpawnData(center.getX() - (projImg.getWidth() / 2) + 3, center.getY() - spcshpImg.getHeight() / 2)
.put("direction", direction.toPoint2D()));
}




private void spawnMovementAnimation() {

FXGL.entityBuilder()
.at(getEntity().getCenter().subtract(spcshpImg.getWidth() / 2, spcshpImg.getHeight() / 2))
.view(new Texture(spcshpImg))
.with(new ExpireCleanComponent(Duration.seconds(0.15)).animateOpacity())
.buildAndAttach();
}




}
Loading

0 comments on commit 3fd8a57

Please sign in to comment.