Compare commits

...

20 Commits
main ... ueb03

Author SHA1 Message Date
0nlineSam
58cd875b7c Replaced == with equals method and removed unused parameters 2024-11-11 18:43:46 +01:00
8fc59ef134
add pdf 2024-11-09 21:26:58 +01:00
saidic
ee7ed3cb43 ueb03 - Task3_d --second_trial 2024-11-09 21:17:22 +01:00
0nlineSam
96457af2d3 Removed unused classes from previous solution 2024-11-07 22:37:42 +01:00
0nlineSam
32647ef118 Merge branch 'ueb03-semenovykh' into ueb03
# Conflicts:
#	.idea/misc.xml
#	src/fr/enssat/BoulderDash/controllers/BoulderAndDiamondController.java
#	src/fr/enssat/BoulderDash/models/LevelModel.java
2024-11-07 22:32:45 +01:00
Artem Semenovykh
65f226a951 Task 3 - a b c 2024-11-07 21:16:59 +01:00
0nlineSam
a8dc0b20c7 Merge branch 'ueb03-daniel2' into ueb03
# Conflicts:
#	.idea/misc.xml
#	src/fr/enssat/BoulderDash/controllers/GameController.java
#	src/fr/enssat/BoulderDash/controllers/GameKeyController.java
#	src/fr/enssat/BoulderDash/controllers/LevelEditorController.java
#	src/fr/enssat/BoulderDash/controllers/LevelEditorKeyController.java
2024-11-07 20:55:12 +01:00
f8cb868e55
rm unused imports 2024-11-07 20:49:33 +01:00
d350b1eb1c
common key action methods 2024-11-07 19:02:31 +01:00
59a7ecff2e
superclass implements KeyListener 2024-11-07 18:54:47 +01:00
2247c7f43d
mv nav field to superclass 2024-11-07 18:20:47 +01:00
f40b8b4492
AudioLoadHelper singleton 2024-11-07 17:41:49 +01:00
f896028199
mv levelModel field up to superclass 2024-11-07 15:30:55 +01:00
0nlineSam
9fa8eeaed9 Removed unused import 2024-11-07 14:34:16 +01:00
0nlineSam
1b54c07d3c Created a superclass for GameKeyController and LevelEditorKeyController 2024-11-07 14:33:13 +01:00
0nlineSam
2751521dd5 Created a superclass for GameController and LevelEditorController 2024-11-07 14:16:15 +01:00
99db8d4956
idea 2024-11-07 13:27:15 +01:00
0nlineSam
db30b572ff Added .DS_Store to .gitignore 2024-11-07 12:12:04 +01:00
fd3dfb35ca
refactor 2024-11-02 12:27:21 +01:00
0nlineSam
5f6312555d Ueb01 Checkstyle 2024-10-23 20:17:04 +02:00
345 changed files with 981 additions and 1010 deletions

3
.gitignore vendored
View File

@ -1 +1,4 @@
/bin/
/out/
/classes/
.DS_Store

16
.idea/checkstyle-idea.xml generated Normal file
View File

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CheckStyle-IDEA" serialisationVersion="2">
<checkstyleVersion>10.18.2</checkstyleVersion>
<scanScope>JavaOnly</scanScope>
<option name="thirdPartyClasspath" />
<option name="activeLocationIds" />
<option name="locations">
<list>
<ConfigurationLocation id="bundled-sun-checks" type="BUNDLED" scope="All" description="Sun Checks">(bundled)</ConfigurationLocation>
<ConfigurationLocation id="bundled-google-checks" type="BUNDLED" scope="All" description="Google Checks">(bundled)</ConfigurationLocation>
<ConfigurationLocation id="5232a701-ef57-4b8f-b1df-ed9fcf2cc548" type="LOCAL_FILE" scope="All" description="Ueb 01 Checkstyle">$PROJECT_DIR$/ueb01_checkstyle_config.xml</ConfigurationLocation>
</list>
</option>
</component>
</project>

7
.idea/misc.xml generated
View File

@ -1,6 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager">
<output url="file://$PROJECT_DIR$/out" />
<component name="PDMPlugin">
<option name="skipTestSources" value="false" />
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_21" default="true" project-jdk-name="openjdk-21" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/classes" />
</component>
</project>

2
.idea/modules.xml generated
View File

@ -2,7 +2,7 @@
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/sq_2024.iml" filepath="$PROJECT_DIR$/.idea/sq_2024.iml" />
<module fileurl="file://$PROJECT_DIR$/Boulder Dash.iml" filepath="$PROJECT_DIR$/Boulder Dash.iml" />
</modules>
</component>
</project>

9
.idea/sq_2024.iml generated
View File

@ -1,9 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

2
.idea/vcs.xml generated
View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="Git" />
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>

View File

@ -1,93 +1,6 @@
# Software Quality
Boulder Dash
=====================
Boulder Dash game, done in Java.
## Getting started
To make it easy for you to get started with GitLab, here's a list of recommended next steps.
Already a pro? Just edit this README.md and make it your own. Want to make it easy? [Use the template at the bottom](#editing-this-readme)!
## Add your files
- [ ] [Create](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#create-a-file) or [upload](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#upload-a-file) files
- [ ] [Add files using the command line](https://docs.gitlab.com/ee/gitlab-basics/add-file.html#add-a-file-using-the-command-line) or push an existing Git repository with the following command:
```
cd existing_repo
git remote add origin https://gitlab.uni-marburg.de/tadjikys/software-quality.git
git branch -M main
git push -uf origin main
```
## Integrate with your tools
- [ ] [Set up project integrations](https://gitlab.uni-marburg.de/tadjikys/software-quality/-/settings/integrations)
## Collaborate with your team
- [ ] [Invite team members and collaborators](https://docs.gitlab.com/ee/user/project/members/)
- [ ] [Create a new merge request](https://docs.gitlab.com/ee/user/project/merge_requests/creating_merge_requests.html)
- [ ] [Automatically close issues from merge requests](https://docs.gitlab.com/ee/user/project/issues/managing_issues.html#closing-issues-automatically)
- [ ] [Enable merge request approvals](https://docs.gitlab.com/ee/user/project/merge_requests/approvals/)
- [ ] [Set auto-merge](https://docs.gitlab.com/ee/user/project/merge_requests/merge_when_pipeline_succeeds.html)
## Test and Deploy
Use the built-in continuous integration in GitLab.
- [ ] [Get started with GitLab CI/CD](https://docs.gitlab.com/ee/ci/quick_start/index.html)
- [ ] [Analyze your code for known vulnerabilities with Static Application Security Testing (SAST)](https://docs.gitlab.com/ee/user/application_security/sast/)
- [ ] [Deploy to Kubernetes, Amazon EC2, or Amazon ECS using Auto Deploy](https://docs.gitlab.com/ee/topics/autodevops/requirements.html)
- [ ] [Use pull-based deployments for improved Kubernetes management](https://docs.gitlab.com/ee/user/clusters/agent/)
- [ ] [Set up protected environments](https://docs.gitlab.com/ee/ci/environments/protected_environments.html)
***
# Editing this README
When you're ready to make this README your own, just edit this file and use the handy template below (or feel free to structure it however you want - this is just a starting point!). Thanks to [makeareadme.com](https://www.makeareadme.com/) for this template.
## Suggestions for a good README
Every project is different, so consider which of these sections apply to yours. The sections used in the template are suggestions for most open source projects. Also keep in mind that while a README can be too long and detailed, too long is better than too short. If you think your README is too long, consider utilizing another form of documentation rather than cutting out information.
## Name
Choose a self-explaining name for your project.
## Description
Let people know what your project can do specifically. Provide context and add a link to any reference visitors might be unfamiliar with. A list of Features or a Background subsection can also be added here. If there are alternatives to your project, this is a good place to list differentiating factors.
## Badges
On some READMEs, you may see small images that convey metadata, such as whether or not all the tests are passing for the project. You can use Shields to add some to your README. Many services also have instructions for adding a badge.
## Visuals
Depending on what you are making, it can be a good idea to include screenshots or even a video (you'll frequently see GIFs rather than actual videos). Tools like ttygif can help, but check out Asciinema for a more sophisticated method.
## Installation
Within a particular ecosystem, there may be a common way of installing things, such as using Yarn, NuGet, or Homebrew. However, consider the possibility that whoever is reading your README is a novice and would like more guidance. Listing specific steps helps remove ambiguity and gets people to using your project as quickly as possible. If it only runs in a specific context like a particular programming language version or operating system or has dependencies that have to be installed manually, also add a Requirements subsection.
## Usage
Use examples liberally, and show the expected output if you can. It's helpful to have inline the smallest example of usage that you can demonstrate, while providing links to more sophisticated examples if they are too long to reasonably include in the README.
## Support
Tell people where they can go to for help. It can be any combination of an issue tracker, a chat room, an email address, etc.
## Roadmap
If you have ideas for releases in the future, it is a good idea to list them in the README.
## Contributing
State if you are open to contributions and what your requirements are for accepting them.
For people who want to make changes to your project, it's helpful to have some documentation on how to get started. Perhaps there is a script that they should run or some environment variables that they need to set. Make these steps explicit. These instructions could also be useful to your future self.
You can also document commands to lint the code or run tests. These steps help to ensure high code quality and reduce the likelihood that the changes inadvertently break something. Having instructions for running tests is especially helpful if it requires external setup, such as starting a Selenium server for testing in a browser.
## Authors and acknowledgment
Show your appreciation to those who have contributed to the project.
## License
For open source projects, say how it is licensed.
## Project status
If you have run out of energy or time for your project, put a note at the top of the README saying that development has slowed down or stopped completely. Someone may choose to fork your project or volunteer to step in as a maintainer or owner, allowing your project to keep going. You can also make an explicit request for maintainers.
Use of the MVC pattern.

View File

@ -1,2 +0,0 @@
/bin/
/out/

8
boulder-dash/.idea/.gitignore generated vendored
View File

@ -1,8 +0,0 @@
# Default ignored files
/shelf/
/workspace.xml
# Editor-based HTTP Client requests
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml

View File

@ -1,6 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" languageLevel="JDK_21" default="true" project-jdk-name="openjdk-21" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/classes" />
</component>
</project>

View File

@ -1,8 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/Boulder Dash.iml" filepath="$PROJECT_DIR$/Boulder Dash.iml" />
</modules>
</component>
</project>

View File

@ -1,6 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$/.." vcs="Git" />
</component>
</project>

View File

@ -1,6 +0,0 @@
Boulder Dash
=====================
Boulder Dash game, done in Java.
Use of the MVC pattern.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 357 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 72 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 400 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 457 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 832 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 140 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 127 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 605 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 856 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 589 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 135 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 75 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 71 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 471 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 340 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 71 B

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,164 +0,0 @@
package fr.enssat.BoulderDash.controllers;
import fr.enssat.BoulderDash.models.LevelModel;
import fr.enssat.BoulderDash.models.DirtModel;
import fr.enssat.BoulderDash.models.DisplayableElementModel;
import fr.enssat.BoulderDash.helpers.AudioLoadHelper;
/**
* ElementPositionUpdateHelper
*
* Updates position of all elements displayed on the map, according to their
* next potential position. Each object has a weight, which is used to compare
* their power to destroy in the food chain. Sorry for that Darwinism.
*
* @author Colin Leverger <me@colinleverger.fr>
* @since 2015-06-19
*/
public class BoulderAndDiamondController implements Runnable {
private LevelModel levelModel;
private AudioLoadHelper audioLoadHelper;
private Thread elementMovingThread;
/**
* Class constructor
*
* @param levelModel Level model
*/
public BoulderAndDiamondController(LevelModel levelModel, AudioLoadHelper audioLoadHelper) {
this.levelModel = levelModel;
this.audioLoadHelper = audioLoadHelper;
// Start thread
this.elementMovingThread = new Thread(this);
this.elementMovingThread.start();
}
/**
* Watches for elements to be moved
*/
public void run() {
while (this.levelModel.isGameRunning()) {
if(!this.levelModel.getGamePaused()){
this.manageFallingObject();
}
try {
Thread.sleep(250);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
/**
* Scan the ground to detect the boulders & the diamonds, then make them
* fall if necessary
* Note: scan of the ground upside down: we want things to fall slowly !
*/
private void manageFallingObject() {
for (int x = this.levelModel.getSizeWidth() - 1; x >= 0; x--) {
for (int y = this.levelModel.getSizeHeight() - 1; y >= 0; y--) {
// Gets the spriteName of actual DisplayableElementModel object scanned
DisplayableElementModel elementModel = this.levelModel.getGroundLevelModel()[x][y];
if(elementModel == null) {
elementModel = new DirtModel();
}
String spriteName = elementModel.getSpriteName();
// If it is a boulder or a diamond...
if (spriteName == "boulder" || spriteName == "diamond") {
this.manageFall(x, y);
} else if(spriteName == "expandingwall"){
if(this.expandWall(x,y).equals("left")){
x -= 1;
}
}
}
}
}
/**
* Expand the wall at left & right
*
* @param x Horizontal position
* @param y Vertical position
*/
private String expandWall(int x, int y) {
DisplayableElementModel elementLeft = this.levelModel.getGroundLevelModel()[x - 1][y];
DisplayableElementModel elementRight = this.levelModel.getGroundLevelModel()[x + 1][y];
String spriteNameLeft = elementLeft.getSpriteName();
String spriteNameRight = elementRight.getSpriteName();
String way = "";
if(spriteNameLeft == "black"){
this.levelModel.expandThisWallToLeft(x,y);
way = "left";
}
if(spriteNameRight == "black"){
this.levelModel.expandThisWallToRight(x,y);
way = "right";
}
return way;
}
/**
* Manages the fall of elements
*
* @param x Horizontal position
* @param y Vertical position
*/
private void manageFall(int x, int y) {
// Get informed about Rockford surroundings
DisplayableElementModel elementBelow = this.levelModel.getGroundLevelModel()[x][y + 1];
DisplayableElementModel elementLeft = this.levelModel.getGroundLevelModel()[x - 1][y];
DisplayableElementModel elementRight = this.levelModel.getGroundLevelModel()[x + 1][y];
String spriteNameBelow = elementBelow.getSpriteName();
String spriteNameLeft = elementLeft.getSpriteName();
String spriteNameRight = elementRight.getSpriteName();
// Then, process in case of the surrounding
if (spriteNameBelow == "black") {
this.levelModel.makeThisDisplayableElementFall(x, y);
} else if (spriteNameBelow == "boulder") {
// Boulders have to roll if they hit another boulder
if (this.levelModel.getGroundLevelModel()[x - 1][y + 1].getSpriteName() == "black") {
this.levelModel.makeThisBoulderSlideLeft(x, y);
} else if (this.levelModel.getGroundLevelModel()[x + 1][y + 1].getSpriteName() == "black") {
this.levelModel.makeThisBoulderSlideRight(x, y);
}
} else if (spriteNameBelow == "rockford" && this.levelModel.getGroundLevelModel()[x][y].isFalling()) {
this.levelModel.exploseGround(x, y + 1);
this.audioLoadHelper.playSound("die");
try {
Thread.sleep(25);
} catch (InterruptedException e) {
e.printStackTrace();
}
this.levelModel.setGameRunning(false);
} else if (spriteNameBelow == "magicwall") {
if (this.levelModel.getGroundLevelModel()[x][y].getSpriteName() == "boulder"
&& (this.levelModel.getGroundLevelModel()[x][y+2].getSpriteName() == "dirt" ||
this.levelModel.getGroundLevelModel()[x][y+2].getSpriteName() == "black")) {
if(this.levelModel.getGroundLevelModel()[x][y].isConvertible()) {
this.levelModel.transformThisBoulderIntoADiamond(x, y);
} else {
this.levelModel.deleteThisBoulder(x, y);
}
}
} else if (elementBelow.isDestructible() && spriteNameBelow != "dirt" && this.levelModel.getGroundLevelModel()[x][y].isFalling()) {
this.levelModel.exploseThisBrickWall(x, y);
} else if (spriteNameLeft == "rockford" && this.levelModel.getRockford().isRunningRight() && this.levelModel.getGroundLevelModel()[x + 1][y].getSpriteName() == "black") {
this.levelModel.moveThisBoulderToRight(x, y);
} else if (spriteNameRight == "rockford" && this.levelModel.getRockford().isRunningLeft() && this.levelModel.getGroundLevelModel()[x - 1][y].getSpriteName() == "black") {
this.levelModel.moveThisBoulderToLeft(x, y);
} else {
this.levelModel.getGroundLevelModel()[x][y].setFalling(false);
}
}
}

View File

@ -1,119 +0,0 @@
package fr.enssat.BoulderDash.controllers;
import fr.enssat.BoulderDash.models.LevelModel;
import fr.enssat.BoulderDash.helpers.AudioLoadHelper;
import fr.enssat.BoulderDash.controllers.NavigationBetweenViewController;
import fr.enssat.BoulderDash.views.MenuView;
import fr.enssat.BoulderDash.views.GameView;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
/**
* GameController
*
* This system creates the view.
* The game loop is also handled there.
*
* @author Colin Leverger <me@colinleverger.fr>
* @since 2015-06-19
*/
public class GameController implements ActionListener {
private LevelModel levelModel;
private AudioLoadHelper audioLoadHelper;
private boolean firstClickOnPause;
private MenuView menuView;
private GameView gameView;
private NavigationBetweenViewController navigationBetweenViewController;
/**
* Class constructor
*
* @param levelModel Level model
* @param navigationBetweenViewController
*/
public GameController(LevelModel levelModel, AudioLoadHelper audioLoadHelper, NavigationBetweenViewController navigationBetweenViewController) {
this.firstClickOnPause = true;
this.navigationBetweenViewController = navigationBetweenViewController;
this.levelModel = levelModel;
this.audioLoadHelper = audioLoadHelper;
this.gameView = new GameView(this, levelModel);
this.menuView = navigationBetweenViewController.getMenuView();
this.getAudioLoadHelper().stopMusic();
this.getAudioLoadHelper().playSound("new");
}
/**
* Handles the 'action performed' event
*
* @param event Action event
*/
public void actionPerformed(ActionEvent event) {
switch(event.getActionCommand()) {
case "pause":
if(this.firstClickOnPause) {
this.levelModel.setGamePaused(true);
} else if(!this.firstClickOnPause) {
this.levelModel.setGamePaused(false);
}
this.firstClickOnPause = !this.firstClickOnPause;
this.gameView.getGameFieldView().grabFocus();
break;
case "restart":
this.resetGame("restart");
this.getAudioLoadHelper().playSound("new");
this.gameView.getGameFieldView().grabFocus();
break;
case "menu":
this.menuView.setVisible(true);
this.getAudioLoadHelper().startMusic("game");
this.resetGame("menu");
break;
}
}
/**
* Function to reset the game
*/
private void resetGame(String source) {
this.gameView.dispose();
if(source.equals("restart")){
this.levelModel = new LevelModel(this.navigationBetweenViewController.getPickedLevelIdentifier(), audioLoadHelper);
this.gameView = new GameView(this, levelModel);
this.gameView.setVisible(true);
}
}
/**
* Gets the audio load helper instance
*
* @return Audio load helper instance
*/
public AudioLoadHelper getAudioLoadHelper() {
return this.audioLoadHelper;
}
/**
* Return the game view
* @return gameView
*/
public GameView getGameView() {
return gameView;
}
/**
* Set the gameView
* @param gameView
*/
public void setGameView(GameView gameView) {
this.gameView = gameView;
}
}

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