ironsigma / three-jewels Goto Github PK
View Code? Open in Web Editor NEWMatch Three Jewels Game
License: MIT License
Match Three Jewels Game
License: MIT License
We need to display the grid and jewels and handle mouse input.
GridModel
to manage and display the jewels on the board.Currently the jewel grid is blank, we need to add a background to make it look nice.
If we run the game from the jar: java -jar jewels-0.1.0-SNAPSHOT-jar-with-dependencies.jar
the game throws a java.io.FileNotFoundException
when trying to load or save a high-score file.
This is due to using ScorePanel.class.getProtectionDomain().getCodeSource().getLocation().toURI().getPath()
as the path to the file. we should use java.util.prefs instead.
Right now when jewels are matched, they're only removed from the board. We need to keep track of a player score, and assign points for removing jewels off the board.
In order to generate and play different levels we'll need a model to hold the state of the board.
Right now when jewels are matched they disappear from the grid and everything is shifted at the blink of an eye. We need to make it more visually appealing by animating the jewels dropping down.
checkAdjacentCells
in the model returns the cells that will be removed, use this list to animate the dropspaintComponent
method just iterates through the grid and paints the jewel at its location. Move this loop into its own function an create a separate one that draws the drops.Currently we iterate through the grid and check the value of the cell to see what image needs to be drawn for a particular jewel this is easy ans simple but we need to keep position, state, graphics, etc to make it easier to achieve things such as animations. We need to change the model to use a class that implements the interface we design.
interface GridCell {
void setPosition(int x, int y);
void setImageIndex(int index);
void getImageIndex(int index);
}
GridModel
to use a generic type of cell.public class GridModel<T extends GridCell> {
public GridModel(int width, int height, int jewelCount, Class<T> clazz) {
this.clazz = clazz;
}
String
are newed and use this method instead.private T newCellInstance() {
return this.clazz.getDeclaredConstructor().newInstance();
}
generateCellValue
gets called, setImageIndex
should be used instead.setCells
method should accept an array of GridCell
s and setCells
should call setPosition
on each cell.getCells
method should return an array of the GridCell
sgetCell
method should return the specified GridCell
swapCell
method should use GridCell
checkAdjacentCells
method should use getImageIndex
of the cell we're checking, and use getImageIndex
of the cell we're checking against instead of equals
method.generateCellValue
method should return an int
instead of a String
removeCells
method should call setImageIndex
and pass the value of generatedCellValue
to store it when new cells are created.JewelCell
class to CellSprite
and make it implement the GridCell
interface.The current gems.png
has the images of the jewels in roughly a grid. But due to the variable size of each jewel they are not in an exact grid. We'll need this to make it easier to "cut" them up once we load up the entire image.
gems.png
to the new transparent image.A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.