Starting from:

$25

ISOM3230 - Assignment 1 - Solved

Learning Outcomes
 

1.       Apply programming concepts to solve business problems

2.       Describe the logic and flows of given programs

3.       Predict the output of a program  

4.       Write programs with common programming practices

5.       Identify and fix logical and run-time errors in programs

 

 

Background
 

During the revision of midterm, Joe found that he needed a game to relax. He remembered a game called 2048 which was very popular in 2014. The game's objective is to slide numbered tiles on a grid to combine them to create a tile with the number 2048.

 

Gameplay: https://en.wikipedia.org/wiki/2048_(video_game) 

 

2048 is played on a gray 4×4 grid, with numbered tiles that slide smoothly when a player moves them using the four arrow keys. Every turn, a new tile will randomly appear in an empty spot on the board with a value of either 2 or 4. Tiles slide as far as possible in the chosen direction until they are stopped by either another tile or the edge of the grid. If two tiles of the same number collide while moving, they will merge into a tile with the total value of the two tiles that collided. The resulting tile cannot merge with another tile again in the same move. Higher-scoring tiles emit a soft glow.  

A scoreboard on the upper-right keeps track of the user's score. The user's score starts at zero, and is incremented whenever two tiles combine, by the value of the new tile.

The game is won when a tile with a value of 2048 appears on the board. After reaching the 2048 tile, players can continue to play (beyond the 2048 tile) to reach higher scores. When the player has no legal moves (there are no empty spaces and no adjacent tiles with the same value), the game ends.

You may try to play 2048 at here: https://gabrielecirulli.github.io/2048/

 

Now, you are asked to design and develop a simpler version of 2048 on Excel with VBA for Joe. The simpler version is played on a 3x3 grid with a similar gameplay as 2048, except that the winning requirement is no longer 2048, but 256.  

 

             

Requirements
 

1.       Graphical User Interface (GUI): You are free to design your own interface. But here are the  required components in the GUI:

a.       A title showing the program name, e.g. “Refreshing Game - 256”

b.       A 3x3 grid showing the number cells

c.       A label (must be ActiveX label) displaying the current score

d.       A label (must be ActiveX label) displaying the best score

e.       A button for starting new game

f.        Buttons for controlling directions (Up, Down, Left, Right)

 

(Note: Use of ActiveX label is only applicable in Windows computer, make use of the lab computers if you do not have one)

 

The following is a sample design for your reference in case you do not have any ideas of what the layout may look like:

You MUST create your own GUI to ensure user-friendliness.

 2.       Here are the game logics and rules:

a.       When the game starts, the program randomly generates 2 number cells with the values of 2 or 4 and showed in the 3x3 grid. User moves the number cells by clicking  direction buttons.

b.       When a direction button is clicked, all number cells move to the edge of 3x3 grid according to  the selected direction. If 2 number cells appear in the same column or row, the number  cells may remain unchanged the position or move to the selected direction by 1 grid.

 

c.       If 2 number cells with the same number touch, they merge into 1 number cell with  a combined value, i.e.   2  touches  2  then it results in  4  

d.       If 3 number cells with the same number touch, the middle number cell is merged into the  number cell which is next to the selected direction edge of 3x3 grid.

 

 

e.       If 2 number cells merge into 1 number cell, increase the current score by the merged  cell value. For example,  2  touches  2  then it results in  4  , and the score is increased by 4.

f.        Once the number cell is moved with the selected direction, the program randomly  generates 1 number cell with the value of 2 or 4 in one of the remaining empty cells of 3x3 grid.

g.       If 3x3 grid is filled up with number cells and the number cells cannot be merged  anymore, the program will display the game score, together with a message “Game over!”. In additional, the user cannot continue to play the current game.

h.       If a number cell with a value of 256 is showed in the 3x3 grid, the program will display the game score, together with a message “You win!”. In addition, the user cannot continue to play the current game.

i.         If a user clicks the “New Game” button to start a new game, the program will reset the current score and show the highest score as best score.  

More products