Giter Site home page Giter Site logo

egrund / java_minesweeper Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 66 KB

This is an implementation of a MineSweeper in java created for the lecture "Einführung in die Software-Entwicklung".

Java 100.00%
java mine-sweeper swing swing-gui model-view-controller observer-pattern gui mine-sweeper-game publish-subscribe publish-subscribe-pattern

java_minesweeper's Introduction

java_MineSweeper

This is an implementation of a MineSweeper in java created for the lecture "Einführung in die Software-Entwicklung".
Author: Eosandra Grund
Date last modified: 31.07.2022
Play by navigating to the bin folder and executing:

java mineSweeper.main.MineSweeper

Game Mechanics

  • You can uncover a field using the left mouse button, it then shows the amount of neighboring bombs. If it was a bomb you lose and the game ends. If it does not have a neighboring bomb, all the neighbors are uncovered as well (recursively).
  • If you think there is a bomb in one field, you can use the right mouse button to mark it. When it is marked it cannot be uncovered, but you can remove the mark by clicking the right mouse button again. If you uncovered all the fields without bombs, you win the game.

A screenshot of playing the game


Picture 1: The View of a running game with 10x15 fields and 15 bombs. Marked fields have a "!".

Model-View-Controller-Pattern and Observer-Pattern

I implemented the game using the Model-View-Controller-Pattern. The game and all the game mechanics are in the model containing the classes game and field. The controller contains all the controls and sends them to the model. The view creates the visuals using Swing and is also an observer of the model so it can change the view depending on the changes in the game. The Observer-Pattern is implemented using java.beans.PropertyChangeSupport.

Execution

  1. Navigate to the bin folder.
  2. Play by executing:
java mineSweeper.main.MineSweeper

Which creates a default game with 10x10 fields and 10 bombs.

  1. Or try your own combinations of sizes and bombs by using
    java mineSweeper.main.MineSweeper (x_dim y_dim (number_bombs)).
    This could for example result in
java mineSweeper.main.MineSweeper 5 15

which creates a game with 5x15 fields and 5*15 / 10 = 7.5 ~ 7 bombs,
or in

java mineSweeper.main.MineSweeper 10 15 15

which creates a game with 10x15 fields and 15 bombs

java_minesweeper's People

Contributors

egrund avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.