This is an unblocked Excel version of the viral web game 2048 by Gabriele Cirulli. Excel is fun!
Our game has been featured in blogs.Office.com & Mashable.com (read the news section below)
Game play: Use the arrow keys to move tiles left, right, up, & down within the 2048 grid. If two tiles of the same number collide while moving, they will merge into a single tile equal to the total value of the two tiles. During every turn, a new tile will appear with a value of either 2 (90% of the time) or 4 (10%).
Game is over when the 2048 tile is made or when no further move is possible.
If you get frustrated by constant failure, here is quick tip: Place high value tiles near any edge - like in examples shown below - and keep building them up!
Our game has been featured in blogs.Office.com & Mashable.com (read the news section below)
Game play: Use the arrow keys to move tiles left, right, up, & down within the 2048 grid. If two tiles of the same number collide while moving, they will merge into a single tile equal to the total value of the two tiles. During every turn, a new tile will appear with a value of either 2 (90% of the time) or 4 (10%).
Game is over when the 2048 tile is made or when no further move is possible.
If you get frustrated by constant failure, here is quick tip: Place high value tiles near any edge - like in examples shown below - and keep building them up!
Features of the Excel version:
The workbook requires enabled macros to run (VBA is unlocked). Read here how to enable macros |
News
Our 2048 Excel Style Game In The News
Want To Have Fun At Work? Look No Further Than Excel!
Download
DownloadCaution: Addictive game! |
vba
Learn VBA: 2048 Code Is Unlocked!
Option Explicit ' ------------------------------------------------------------ ' Excel version of the 2048 web game by Gabriele Cirulli ' Created by Peter Bartholomew & Petros Chatzipantazis ' http://www.spreadsheet1.com/2048-game-version-for-excel.html ' Please distribute freely. Attribution required. ' ------------------------------------------------------------ ' Modifications by Douglas Bliss: ' - Create Tile property to access grid data based on direction ' - Create a single MakeMove function based on direction ' - Call MakeMove function from key handlers ' ------------------------------------------------------------ ' Tile Property - Accesses grid data based on direction ' (not the most efficient, but it's fast enough here) ' ------------------------------------------------------------ Private Property Get Tile(ByVal Direction As String, ByVal Row As Long, ByVal Col As Long) As Long Select Case Direction Case "L" Tile = Range("State").Cells(Row, Col).Value Case "R" Tile = Range("State").Cells(Row, 5 - Col).Value Case "U" Tile = Range("State").Cells(Col, 5 - Row).Value Case "D" Tile = Range("State").Cells(5 - Col, Row).Value Case Else End Select End Property Private Property Let Tile(ByVal Direction As String, ByVal Row As Long, ByVal Col As Long, ByVal RHS As Long) Select Case Direction Case "L" Range("State").Cells(Row, Col).Value = RHS Case "R" Range("State").Cells(Row, 5 - Col).Value = RHS Case "U" Range("State").Cells(Col, 5 - Row).Value = RHS Case "D" Range("State").Cells(5 - Col, Row).Value = RHS Case Else End Select End Property ' ------------------------------------------------------------ ' MakeMove - abstract logic for shifting/combining tiles ' ------------------------------------------------------------ Private Sub MakeMove(Direction As String) Dim bIsMove As Boolean Dim R As Long, C As Long, I As Long, lScore As Long lScore = 0 For R = 1 To 4 Step 1 For C = 1 To 3 Step 1 ' Move from next tile over if empty: If Tile(Direction, R, C) = 0 Then For I = C + 1 To 4 Step 1 If Tile(Direction, R, I) > 0 Then Tile(Direction, R, C) = Tile(Direction, R, I) Tile(Direction, R, I) = 0 bIsMove = True Exit For End If Next I End If ' Combine with next tile over if they match: If Tile(Direction, R, C) > 0 Then For I = C + 1 To 4 Step 1 If Tile(Direction, R, I) > 0 Then If Tile(Direction, R, C) = Tile(Direction, R, I) Then lScore = lScore + 2 * 2 ^ Tile(Direction, R, C) Tile(Direction, R, C) = Tile(Direction, R, C) + 1 Tile(Direction, R, I) = 0 bIsMove = True End If Exit For ' stop combining after first non-empty tile End If Next I End If Next C Next R m_lTotalScore = m_lTotalScore + lScore If bIsMove Then AddTile FormatTiles Direction, bIsMove If bIsMove Then MidiMakeMove lScore End Sub ' ------------------------------------------------------------ ' Key Handlers: ' ------------------------------------------------------------ Sub LeftArrowPressed() MakeMove "L" End Sub Sub RightArrowPressed() MakeMove "R" End Sub Sub UpArrowPressed() MakeMove "U" End Sub Sub DownArrowPressed() MakeMove "D" End Sub
VBA Chord Diagram With Hierarchical Edge Bundling
This VBA chord diagram uses the free D3.js JavaScript library to demonstrate a graphical method of displaying the inter-relationships between code procedures in the 2048 VBA project powered by Ribbon Commander.
The data is arranged radially around a circle with the relationships between the points drawn as arcs connecting the procedures together. Instead of using straight lines to show the interconnections, this chord diagram employs a technique called 'hierarchical edge bundling' to reduce visual complexity.
The project name, module type and name is shown at the bottom of the chart when the mouse pointer hovers over a VBA procedure (mouse click not required).
The data is arranged radially around a circle with the relationships between the points drawn as arcs connecting the procedures together. Instead of using straight lines to show the interconnections, this chord diagram employs a technique called 'hierarchical edge bundling' to reduce visual complexity.
The project name, module type and name is shown at the bottom of the chart when the mouse pointer hovers over a VBA procedure (mouse click not required).