Coder Social home page Coder Social logo

three-jewels's People

Contributors

enzomzaocv avatar ironsigma avatar rejwr avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Forkers

rejwr

three-jewels's Issues

Use model to draw the board and handle click events

Description

We need to display the grid and jewels and handle mouse input.

Acceptance Criteria

  • Load jewel images from sprite sheet and split into separate images.
  • Use the GridModel to manage and display the jewels on the board.
  • Allow jewel to be dragged-and-dropped left, right, up or down.
  • After dropping a jewel check if three or more of the same jewel are in a row and remove from board, otherwise revert jewel back to its original position.

Add a Background to the Grid

Description

Currently the jewel grid is blank, we need to add a background to make it look nice.

Acceptance Criteria

  • Load a background image that we can use as a cell background
  • The image should be the size of the current cell 120x120 so we can change the size and shape of the grid later.
  • Draw the background image before the jewels get drawn

Keep Track of Player Score

Description

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.

Acceptance Criteria

  • Shift the grid down to make space for the score.
  • Draw the score in the top right corner of the new space.
  • All mouse clicks to grid cell calculations must account for the grid shift.
  • Every time a player matches three jewels, they will be awarded 100 points and 50 points for each additional jewel over three.

Create a Jewel Grid Model

Description

In order to generate and play different levels we'll need a model to hold the state of the board.

Acceptance Criteria

  • Create a model that will start with an 8x8 grid
  • The model will track which jewel is in what cell
  • The model will provide a method to swap a jewel to an adjacent cell.
  • The model will provide a method that will check if three or more of the same cells match on the row and/or column at the specified cell and will return a list of matching cells.
  • The model will provide a method to remove a range of cells specified and return a list of newly added jewels to fill in the gaps.

Animate Jewel Drops

Description

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.

Acceptance Criteria

  • When jewels are matched and removed off the board they should slide down to make room for the new jewels
  • Optional: Make new jewels slide in, otherwise just have them pop like it does right now.
  • Optional: Make each jewel drop at a different rate to make it more visually appealing.

Technical Details

  • The method checkAdjacentCells in the model returns the cells that will be removed, use this list to animate the drops
  • Currently the paintComponent 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.
  • When the mouse is release the code should go into a dropping draw state so it uses the alternate drawing function instead of just drawing the grid.
  • After all the cells are dropped, the state should go back to grid draw state to continue as usual

Change the Grid Model to use a GridCell interface instead of Strings

Description

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.

Acceptance Criteria

Grid Model

interface GridCell {
    void setPosition(int x, int y);
    void setImageIndex(int index);
    void getImageIndex(int index);
}
  • Using the above interface change GridModel to use a generic type of cell.
public class GridModel<T extends GridCell> {
  • Using the above interface change the constructor to accept and save the cell type.
public GridModel(int width, int height, int jewelCount, Class<T> clazz) {
    this.clazz = clazz;
}
  • Create a method that uses the saved type to create instances of cells.
  • Change the code where String are newed and use this method instead.
private T newCellInstance() {
    return this.clazz.getDeclaredConstructor().newInstance();
}
  • Update the rest of the model to use the new type and interface
    • When a cell is added to the grid in the constructor and generateCellValue gets called, setImageIndex should be used instead.
    • The setCells method should accept an array of GridCells and setCells should call setPosition on each cell.
    • The getCells method should return an array of the GridCells
    • The getCell method should return the specified GridCell
    • The swapCell method should use GridCell
    • The 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.
    • The generateCellValue method should return an int instead of a String
    • The removeCells method should call setImageIndex and pass the value of generatedCellValue to store it when new cells are created.

Board Panel

  • Rename the JewelCell class to CellSprite and make it implement the GridCell interface.

Organize Jewels Image into cells of equal width and height

Description

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.

Acceptance Criteria

  • Create a transparent PNG image of 720x480
  • Copy each jewel from the existing gems.png to the new transparent image.
  • Each jewel should take up no more than 120x120 pixels in the new image.
  • Each jewel should be centered in the 120x120 cell
  • No lines, borders, or any other dividers should be present in the final image.

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.