Git Product home page Git Product logo

linkandswitch's Introduction

Introduction

This example project shows a simple Linker and Switcher game. The main purpose of this example was to see if it was possible to create a grid based game such as a linker or switcher without a central data model to keep track of which block is in which cell in the grid.

Despite the ambition of getting rid of a grid like data structure the games are not completely without a central data model. When blocks are spawned from the top of the screen their ids are stored in an array and when blocks are removed their ids are removed from the same array. Keeping track of a single list of blocks is a decent enough tradeoff since it is a lot more manageable than a grid-like data structure that must be kept up to date as blocks are falling, spawning and being removed.

Physics based system

The linker and switcher uses the Defold physics system to detect when a block should fall, when it is touched by a user and what neigboring blocks it has.

Each block has a collision component at the bottom and the top of the block. These are used to determine if a block should fall or not. The collision component at the bottom will detect collisions with the top collision component of any block that happens to be below it. The same collision component is also used to detect collisions with the ground. If no collision occurs the block will fall, otherwise it will stop.

The blocks also have a central collision component that is used to detect touch events. When the mouse or a touch event occurs a small cursor collision component will follow the touch event's x and y and collide with the collision component of the block.

Finally the blocks have four small collision components above, below, left and right of the block to detect neighboring blocks. Each block has a property per cardinal direction to hold the id of neighboring blocks and these properties will be updated when collisions with neighboring blocks occur. This information is used in the switcher to detect groups of blocks in the same color.

Play the game in your browser

linkandswitch's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

Forkers

paweljarosz

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.