Coder Social home page Coder Social logo

meowmeow's Introduction

Meow Meow Puzzle

Code Structure

  • Tile Class: Represents a tile in the puzzle, holding information like its index and associated image segment.
  • preload(): Preloads necessary assets before the application starts, such as the image used in the puzzle.
  • setup(): Initializes the canvas, resizes the source image, and sets up the initial state of the puzzle, including tiles and board configurations.
  • initializeTiles(): Creates and initializes the tiles and the board. Tiles are created with positions, and an image segment and the board keeps track of tile indices.
  • updateTiles(): Aligns the original image segments to the tiles, ensuring that each tile has the correct segment of the image.
  • swap(i, j, arr): A utility function that swaps two elements in an array, used to swap tiles on the board.
  • simpleShuffle(arr) and randomMove(arr): These functions shuffle the board tiles randomly, ensuring that the puzzle starts in a mixed state.
  • mousePressed(): Handles user input, allowing tiles to be moved when clicked, as long as the move is valid.
  • draw(): Continuously renders the puzzle, updating tile positions, displaying images, and handling tile animations and movements.
  • isSolved(): Checks whether the puzzle is solved by comparing the current state of the board with the correct sequence of tiles.
  • isNeighbor(i, j, x, y): Utility function to check whether two tiles are neighbors and therefore, can be swapped.
  • findBlank(): Finds the position of the blank tile, facilitating various operations like valid move checks and tile swapping.

meowmeow's People

Contributors

shiffman avatar

Stargazers

 avatar

Watchers

 avatar  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.