0% found this document useful (0 votes)
8 views41 pages

CPE Main Report

Uploaded by

aryanandhare09
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views41 pages

CPE Main Report

Uploaded by

aryanandhare09
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 41

PROJECT REPORT

ON
Game:2048 Puzzle Game
SUBMITTED IN PARTIAL FULFILLMENT OF THE REQUIREMENTS

FOR THE AWARD OF

DIPLOMA IN

INFORMATION TECHNOLOGY

SUBMITTED TO :-

Maharashtra Board of Technical Education, Mumbai

Government Polytechnic, Solapur


ACADEMIC YEAR 2023- 2024

Submitted by: -
Sr. No Name Enrollment Number Seat Number

13 Deshmukh Shardul Santoshkumar 2100150259 169523


29 Kale Tejas Sudhir 2100150289 169544
52 Sorgekar Yashodip Samarth 2200150716 169566
54 Kenche Sumit Sanjiv 2200150718 169568

GUIDED BY: Prof. Surekha S.N


Government Polytechnic, Solapur
Department of INFORMATION TECHNOLOGY

CERTIFICATE

It is to certify that following student of Class: IF6I


has

Sr. No Name Enrollment Number Seat Number

13 Deshmukh Shardul Santoshkumar 2100150259 169523


29 Kale Tejas Sudhir 2100150289 169544
52 Sorgekar Yashodip Samarth 2200150716 169566
54 Kenche Sumit Sanjiv 2200150718 169568
satisfactorily completed the project planning titled as

“Game:2048 Puzzle Game”


as a partial fulfilment for awarding the Diploma in Information Technology by Maharashtra State Board
of Technical Education, Mumbai for the academic year 2023-2024.

Project Guide Head of Department Principal

Internal Examiner External Examiner

Date:

Place: Solapur
Acknowledgement

We would like to express our sincere gratitude to all those who have contributed to the
successful completion of the Game:2048 Puzzle Game

Creating a 2048 game as a microproject can be a rewarding experience, offering a blend


of technical challenges and creative design opportunities. It's suitable for both beginners
looking to practice their skills and more advanced developers interested in
exploring new ideas.

We are deeply appreciative of the guidance and support provided by our project guide
Prof. Gaikwad S. N., whose expertise and insights have been invaluable in shaping the
direction of our project. We are also grateful to our principal, Dr. Ashok Upadhyay, for their
encouragement and support throughout the project's duration.

We extend our appreciation to the team members who worked tirelessly to bring this
project to fruition, collaborating effectively and contributing their diverse skills and
expertise.

We would like to acknowledge the farmers, industry experts, and stakeholders who
participated in interviews, surveys, and workshops, providing valuable feedback and insights
that informed the development of the web application.

Special thanks to Government Polytechnic, Solapur for providing resources, facilities, and
support for the execution of this project.

Lastly, we express our gratitude to our families, friends, and loved ones for their
unwavering support, patience, and understanding during the challenging moments of this
project.
ABSTRACT

This project presents the development of a 2048 game, a sliding block puzzle that challenges
players to combine tiles with identical numbers on a 4x4 grid, aiming to achieve a tile with
the number 2048. The game is renowned for its simplicity and depth, offering a rich case
study in algorithm efficiency, user interface (UI) design, and the implementation of user
experience (UX) principles in game development. The primary objectives of this project
include the creation of an intuitive and responsive UI, the development of efficient
algorithms for game logic, and the exploration of enhancements to increase user engagement.

A significant focus is placed on UI/UX design, aiming to create a visually appealing and
intuitive interface that enhances player engagement without compromising the game's
minimalist aesthetic. This includes the implementation of smooth animations, coherent color
schemes, and responsive design principles.

Through a systematic methodology encompassing requirement gathering, design,


development, testing, and deployment, the project team has developed a robust and scalable
web application tailored to the needs of gamers. With ongoing maintenance and support, the
application aims to continually evolve to meet the changing demands of the gamening
industry.

This 2048 game project is expected to serve as a foundation for future projects in game
development, offering insights into the balance between functionality and aesthetic appeal,
the importance of algorithm efficiency, and the role of user feedback in iterative
design processes.
Index

Sr. no. Title Page


no
1 Introduction
2 Literature Survey

3 Scope of the project

4 Methodology

5 Details of designs
- I/O design
- UI design
-1 ER Diagram
-.2 setup Design
6 Details of working

7 Details of processes

8 Coding
8.1 Languages /tools used
8.2 Justification for Selection of languages /tools
8.3 Important Modules
8 Results and application
9 Conclusion
10 Appendix
11 References
Introduction

Welcome to the realm of "2048," where the intersection of mathematics, strategy, and
addictive gameplay creates a captivating experience. This capstone project aims to delve deep
into the dynamics of the 2048 game, a digital puzzle that has taken the gaming world by
storm.

2048 is sliding block puzzle game developed by Gabriele Cirulli. It’s a game played on a 4x4
grid with tiles numbered 2n where ‘n’ represents a natural number. The objective of the game
is to combine tiles of the same number to eventually form the number 2048. The user can
move in the four cardinal directions and after every move a new tile is generated randomly in
the grid which is either numbered 2 or 4 with a probability of about .10. A move is legal if at
least one tile can be slid into an empty spot or if the tiles can be combined in the chosen
direction. The game ends when the user does not have any legal moves left. One cannot help
but ask the question, since the game is based on mathematics, whether moves can be
optimised to improve our score by applying different concepts of mathematics.

As you explore this capstone project, you will embark on a journey to uncover the inner
workings "2048." We will examine the game's rules, strategies for success, and even consider
its educational applications. Through this project, we hope to gain a deeper appreciation for
the intricate balance of simplicity and complexity that "2048" offers

1
Literature Survey

A literature survey on the "2048" game can encompass various aspects, including its
history,gameplay, mathematical analysis, educational potential, and social impact. Here's a
brief overview:

1. *History and Evolution of 2048*:

- Explore the origins and development of the game, including the original "2048" by
Gabriele Cirulli and its variants. -
-Investigate how the game gained popularity and its impact on the mobile gaming industry

2. *Gameplay and Mechanics*:

- Describe the fundamental rules of the game, such as merging tiles and achieving higher
numbered tiles. -
-Analyze the strategies and tactics players use to maximize their scores and reach the 2048
tile.

3. *Mathematical Analysis*:

- Discuss the mathematical principles underlying the game, including powers of 2 and
probability. -
-Explore algorithms and heuristics used to optimize gameplay, such as the Monte Carlo Tree
Search (MCTS) algorithm.

4. *Educational Applications*:

- Investigate how "2048" can be used as an educational tool for teaching math,
problemsolving, and logical thinking. -
-Examine case studies and research on the use of "2048" in educational settings.

2
5. *Cognitive and Psychological Aspects*:

- Analyze the cognitive skills and psychological aspects involved in playing "2048," such
as pattern recognition, decision-making, and perseverance.

6. *Social and Cultural Impact*:

- Explore the social phenomenon around the game, including its influence on pop culture,
social media challenges, and community engagement. -
Discuss the addictive nature of "2048" and its impact on player behavior.

7. *Game Variations and Extensions*:

- Review different versions and adaptations of the game, including larger grids, new rules,
and multiplayer variations.
-Discuss the implications of these adaptations on gameplay and player engagement.

8. *Future Directions and Research Opportunities*:

- Identify gaps in the existing literature and suggest potential areas for future research, such
as AI-based gameplay, gamification in education, and neuroscientific studies of player
behavior.

A literature survey on "2048" should encompass a wide range of sources, from academi
papers and articles to online forums and community discussions, to provide a comprehensive
understanding of the game's multifaceted nature and its significance in the world of gaming
and education.

3
Scope of the project

The scope of developing a 2048 game encompasses several key areas, highlighting its
multifaceted potential not just as a game but as a project that touches on various aspects of
programming, design, and user experience. Here are the main components:

1. *Programming and Algorithm Development:*

- *Core Mechanics:* Implementing the basic gameplay mechanics, including tile movements,
combination of tiles, and the spawning of new tiles after each move.

- *Efficiency Optimization:* Developing algorithms for the game logic that are both efficient
and scalable, ensuring smooth gameplay across different devices and platforms.

- *Advanced Features:* Adding functionality such as undo moves, save/load game state, and
possibly implementing AI to suggest the next move or play the game autonomously.

2. *User Interface (UI) and Experience (UX) Design:*

- *Design Principles:* Creating an intuitive and appealing interface that enhances user
engagement without overwhelming the minimalist aesthetic of the game.

- *Responsiveness:* Ensuring the game is playable on various devices and screen sizes,
maintaining a consistent and enjoyable experience.

- *Accessibility:* Implementing features that make the game accessible to a wider range of
players, including those with disabilities.

3. *Technology Integration:*

- *Cross-Platform Development:* Exploring different technologies and frameworks to make


the game available across multiple platforms, such as web, mobile, and desktop.

4
- *Use of Libraries/Frameworks:* Leveraging existing libraries or frameworks to speed up
development time and focus on unique aspects of the game.

4. *Testing and Quality Assurance:*

- *Functionality Testing:* Ensuring the game works as intended across all targeted platforms
and devices.

- *Performance Optimization:* Testing and optimizing the game to run smoothly, minimizing
lag and ensuring responsive controls.

- *User Testing:* Gathering feedback from users to refine gameplay, UI/UX, and address any
issues.

5. *Market and Audience Analysis:*

- *Target Audience:* Understanding the demographic and interests of potential players to


tailor the game's design and marketing strategies.

- *Competitive Analysis:* Evaluating similar games to identify unique features or


improvements that can make the 2048 game stand out.

6. *Educational Value:*

- *Learning Tool:* Using the game development process as a learning tool for programming
concepts, design principles, and project management.

- *Algorithmic Thinking:* Encouraging players to develop strategy and problem-solving


skills through gameplay.

5
Methodology

1. *Understand the Game Rules*:


- Start by thoroughly understanding the game rules, including how tiles merge and how the
game ends when the grid is full.

2. *Master Basic Tactics*:


- Learn the fundamental tactics for efficient tile merging, such as keeping tiles in one corner,
ensuring large numbers are on the edges, and avoiding unnecessary movements.

3. *Develop a Strategy*:
- Create a strategic approach to guide your decisions. Consider factors like prioritizing the
largest tile, maintaining order on the grid, and planning ahead.

4.*Pattern Recognition*:
- Train your ability to recognize common tile patterns that can lead to successful mergers. For
example, understanding the "snake pattern."

5. *Efficient Tile Movement*:


- Focus on efficient tile movements to minimize wasted moves. This involves sliding tiles in
a way that creates opportunities for merging.

6. *Long-Term Planning*:
- Plan not only for the current move but also for future moves. Avoid moves that may block
potential future mergers.

7. *Adapt to New Tiles*:


- Adjust your strategy in response to the appearance of new tiles. Prioritize merging tiles
that help maintain an ordered grid.

8. *Maintain an Escape Route*: -


Always keep a path open to maneuver tiles, especially near the center of the grid.

6
Designs

• *User Interface:*

• 1. *Grid Layout*: The game should feature a 4x4 grid to hold the tiles. The grid should be
visually distinct and easy to navigate.

• 2. *Tile Design*: Each tile should be a square with a number representing its value. Start
with two tiles (e.g., two "2" tiles) on the grid at the beginning.

• 3. *Score Display*: Display the player's score prominently on the screen, updating in real-
time as tiles merge.

• 4. *New Game Button*: Include a button that allows the player to start a new game when
desired.

• 5. *Undo Button*: Offer an "undo" button to allow the player to revert to the previous move.

• 6. *Settings and Options*: Provide options to adjust game settings, such as toggling sound
effects, enabling/disabling hints, or changing the grid size for variations.

7
• *Game Mechanics:*

• 1. *Tile Movement*: Tiles can be moved in four directions: up, down, left, and right.

• 2. *Tile Merging*: When two tiles of the same value are moved into each other, they merge
into a single tile with a value that's the sum of the two merged tiles.

• 3. *Win Condition*: The player wins by reaching the "2048" tile.

• 4. *Lose Condition*: The game ends when no more valid moves can be made.

• 5. *Random Tile Generation*: New tiles (e.g., "2" or "4" tiles) should appear on the grid
after each move, ideally in a random open space

• *Visual Style:*
• 1. *Color Palette*: Use a pleasing color palette for tiles and the background. Different tile
values can be represented with distinct colors.

• 2. *Animations*: Add subtle animations to make tile movements and merging visually
appealing.

• 3. *Responsive Design*: Ensure that the game interface is responsive and works well on
various screen sizes and orientations

. • *Accessibility:*
• 1. *Text Labels*: Use clear text labels and consider providing alternative text for images and
icons for accessibility.

8
.
Procedure:

Creating a "2048" game involves multiple steps in the development process. Here's a
tentative procedure to guide you through building the game:

*1. Conceptualization and Planning:*

- Define the game's objectives, features, and target audience.


- Outline the game mechanics, such as tile movement, merging, and win/lose conditions.
- Plan the user interface design, including grid layout, tile design, and user controls.
- Identify the platform(s) for which you intend to develop the game (e.g., mobile, web,desktop).

*2. Game Development:

- Choose a programming language and development framework (e.g., advance java and Java
for web-based games).
- Create the game grid, tiles, and user interface elements according to your design.
- Implement the core game logic, including tile movement, merging, and random tile
generation. - Develop the scoring system and win/lose condition checks.
- Incorporate sound effects, animations, and other visual elements to enhance the gaming
experience.
- Test the game thoroughly to ensure all mechanics work as intended.

*3. User Interface Design and Integration:*

- Implement the user interface components, including the score display, new game button,
undo button, and settings/options menu.
- Ensure the interface is responsive and user-friendly on various devices and screen sizes

*4. Testing and Debugging:*

-Perform extensive testing to identify and fix any bugs, glitches, or unintended behaviors.
- Test the game on different browsers and devices to ensure compatibility.

*5. Playtesting:*
- Involve playtesters to gather feedback on gameplay, user experience, and difficulty level.

9
- Use this feedback to make necessary adjustments to game mechanics, balance, and user
interface.

*6. Optimization:*

- Optimize the game's code and assets for performance and load times. - Implement strategies
to minimize memory usage and reduce lag.

*7. Accessibility:*

- Ensure that the game is accessible to players with disabilities, including screen reader support
and keyboard navigation.

*8. Deployment:*

- Choose the platforms and app stores where you want to release the game (e.g., Google Play
Store, Apple App Store, or a website). - Follow platform-specific guidelines for submission
and approval.

*9. Marketing and Promotion:*

- Plan a marketing strategy to promote the game, including creating promotional materials and
utilizing social media channels.

10
1 ER Diagram:

11
2 Setup Design:

12
13
Working

Working:

1. *Movement*: Players swipe (up, down, left, or right) to move the tiles on the grid. When
two tiles with the same number touch, they merge into one tile whose value is the sum of the
two original tiles.

1. *Objective*:
The goal is to combine tiles until you create a tile with the number 2048. However, you
can continue to play beyond this point to achieve higher scores.

2. *Scoring*:
Every time two tiles merge, the player earns points equal to the value of the new tile. For
example, merging two tiles of value 4 will give you an 8-point score increase.

4. *Gameplay*:
- After every swipe, a new tile (either a 2 or a 4) randomly appears in an empty spot on the
board.
- The player needs to strategize their swipes to avoid filling up the board. If the board fills
up and no adjacent tiles can be combined (i.e., there are no possible moves left), the game ends.

5. *Strategy*:
- A common strategy is to try to keep the highest value tile in a corner and work to
continuously combine other tiles into it.
- Planning moves ahead and trying to maintain some empty spaces on the grid for as long as
possible are key strategic elements.

14
Processes

Process:

1.Requirement Gathering:
-Conduct interviews, surveys, and workshops with gamers to understand their needs and
key points.
-Identify key features and functionalities required to address these needs effectively.

2.Design and Development:


-Translate requirements into technical specifications and design wireframes/mock-ups for
UI/UX.
-Develop the application iteratively, following agile development methodologies to
prioritize features and respond to feedback.

3.Testing and Quality Assurance:


-Conduct comprehensive testing at each stage of development, including unit testing.
-Identify and address any bugs, errors, or usability issues through rigorous testing and
iteration.

4.Deployment and Maintenance:


-Deploy the application to a production environment, ensuring stability, security, and
performance.
-Provide ongoing maintenance and support to address any issues or updates post-
deployment.
-Continuously monitor user feedback and usage metrics to inform future enhancements
and improvements.

15
Coding

package JustDoIt;

import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.geom.RoundRectangle2D;

import javax.swing.JFrame;
import javax.swing.JPanel;

public class Main extends JPanel implements MouseListener{

int boardWidth = 6;
int boardHeight = 6;
int x = 8;
int y = 8;
int xa;
int ya;
boolean win;
boolean lost;
boolean move;
boolean pressed;
boolean up;
boolean down;
boolean left;
boolean right;

RoundRectangle2D[][] board = new RoundRectangle2D[boardWidth][boardHeight];


int[][] sit = new int[boardWidth][boardHeight];
int[][] con = new int[boardWidth][boardHeight];
Color c = new Color(0, 0, 0);

16
Color c2 = new Color(0, 0, 0);
Font font = new Font("Ariel", Font.BOLD, 0);

public void init() {


for(int i = 0; i<boardWidth; i++) {
for(int j = 0; j<boardHeight; j++) {
sit[i][j] = 0;
}
}
}

public void setCon(){


for(int i = 0; i<boardWidth; i++) {
for(int j = 0; j<boardHeight; j++) {
con[i][j] = 0;
}
}
}

public void setBoard() {


double x = 0;
double y = 0;
double width = getWidth()/boardWidth;
double height = getHeight()/boardHeight;
for(int i = 0; i<boardWidth; i++) {
for(int j = 0; j<boardHeight; j++) {
board[i][j] = new RoundRectangle2D.Double(x, y, width, height, 10, 10);
x += width;
}
x = 0;
y += height;
}
}

public Main() {
this.addMouseListener(this);
}

public void randomNumber() {


boolean isCreated = false;

17
for(int i = 0; i<boardWidth; i++) {
for(int j = 0; j<boardHeight; j++) {
if(Math.random() > 0.99 && sit[i][j] == 0) {
isCreated = true;
sit[i][j] = 2;
break;
}
}
if(isCreated)
break;
}
if(isCreated == false)
randomNumber();
}

public void moveNumbers() {


int activity = 0;
for(int i = 0; i<boardWidth; i++) {
for(int j = 0; j<boardHeight; j++) {
if(sit[i][j] != 0) {
if(right) {
if(j != boardHeight-1) {
if(sit[i][j+1] != 0) {
if(sit[i][j+1] == sit[i][j] && con[i][j] != 1 && con[i][j+1] != 1) {
sit[i][j+1] += sit[i][j];
sit[i][j] = 0;
con[i][j+1] = 1;
activity++;
}
}
else {
sit[i][j+1] = sit[i][j];
sit[i][j] = 0;
if(con[i][j] == 1) {
con[i][j+1] = con[i][j];
con[i][j] = 0;
}
activity++;
}
}

18
}
else if(left) {
if(j != 0) {
if(sit[i][j-1] != 0) {
if(sit[i][j-1] == sit[i][j] && con[i][j] != 1 && con[i][j-1] != 1) {
sit[i][j-1] += sit[i][j];
sit[i][j] = 0;
con[i][j-1] = 1;
activity++;
}
}
else {
sit[i][j-1] = sit[i][j];
sit[i][j] = 0;
if(con[i][j] == 1) {
con[i][j-1] = con[i][j];
con[i][j] = 0;
}
activity++;
}
}
}
else if(up) {
if(i != 0) {
if(sit[i-1][j] != 0) {
if(sit[i-1][j] == sit[i][j] && con[i][j] != 1 && con[i-1][j] != 1) {
sit[i-1][j] += sit[i][j];
sit[i][j] = 0;
con[i-1][j] = 1;
activity++;
}
}
else {
sit[i-1][j] = sit[i][j];
sit[i][j] = 0;
if(con[i][j] == 1) {
con[i-1][j] = con[i][j];
con[i][j] = 0;
}
activity++;

19
}
}
}
else if(down) {
if(i != boardWidth-1) {
if(sit[i+1][j] != 0) {
if(sit[i+1][j] == sit[i][j] && con[i][j] != 1 && con[i+1][j] != 1) {
sit[i+1][j] += sit[i][j];
sit[i][j] = 0;
con[i+1][j] = 1;
activity++;
}
}
else {
sit[i+1][j] = sit[i][j];
sit[i][j] = 0;
if(con[i][j] == 1) {
con[i+1][j] = con[i][j];
con[i][j] = 0;
}
activity++;
}
}
}
}
}
}
if(activity == 0) {
move = false;
randomNumber();
}
}

public void check() {


int op = 0;
try {
for(int i = 0; i<boardWidth; i++) {
for(int j = 0; j<boardHeight; j++) {
if(sit[i][j] == 2048) {
win = true;

20
}
if(sit[i][j] == 0)
op++;
if(j != boardHeight-1 && i != boardWidth-1 && j != 0 && i != 0) {
if(sit[i][j] == sit[i][j+1] || sit[i][j] == sit[i][j-1] || sit[i][j] == sit[i+1][j] || sit[i][j]
== sit[i-1][j] || sit[i][j] == 0) {
op++;

}
else if(j == 0 || j == boardHeight-1){
if(!(i == 0 && j == 0)) {
if(!(i == 0 && j == boardHeight-1)) {
if(sit[i][j] == 0 || sit[i][j] == sit[i+1][j] || sit[i][j] == sit[i-1][j]) {
op++;
}
}
}
}
else if(i == 0 || i == boardWidth-1){
if(!(i == boardWidth-1 && j == 0)) {
if(!(i == boardWidth-1 && j == boardHeight-1)) {
if(sit[i][j] == 0 || sit[i][j] == sit[i][j+1] || sit[i][j] == sit[i][j-1]) {
op++;
}
}
}
}
}
}
}catch(Exception e) {}
if(op == 0) {
lost = true;
}
}

@Override
public void paint(Graphics g) {
super.paint(g);

21
Graphics2D g2d = (Graphics2D)g;
g2d.setColor(Color.GRAY);
g2d.fillRect(0, 0, getWidth(), getHeight());

for(int i = 0; i<boardWidth; i++) {


for(int j = 0; j<boardHeight; j++) {
switch(sit[i][j]) {
case 0:
c = new Color(170, 170, 170);
break;
case 2:
c = new Color(211, 211, 211);
c2 = new Color(0, 0, 0);
font = new Font("Ariel", Font.BOLD, (int)board[i][j].getWidth());
break;
case 4:
c = new Color(255, 218, 185);
c2 = new Color(0, 0, 0);
font = new Font("Ariel", Font.BOLD, (int)board[i][j].getWidth());
break;
case 8:
c = new Color(255, 130, 71);
c2 = new Color(0, 0, 0);
font = new Font("Ariel", Font.BOLD, (int)board[i][j].getWidth());
break;
case 16:
c = new Color(255, 97, 3);
c2 = new Color(0, 0, 0);
font = new Font("Ariel", Font.BOLD, (int)board[i][j].getWidth() -
(int)board[i][j].getWidth()/4);
break;
case 32:
c = new Color(205, 51, 51);
c2 = new Color(0, 0, 0);
font = new Font("Ariel", Font.BOLD, (int)board[i][j].getWidth() -
(int)board[i][j].getWidth()/4);
break;
case 64:
c = new Color(178, 34, 34);
c2 = new Color(255, 255, 255);

22
font = new Font("Ariel", Font.BOLD, (int)board[i][j].getWidth() -
(int)board[i][j].getWidth()/4);
break;
case 128:
c = new Color(255, 193, 37);
c2 = new Color(0, 0, 0);
font = new Font("Ariel", Font.BOLD, (int)board[i][j].getWidth() -
(int)board[i][j].getWidth()/3);
break;
case 256:
c = new Color(238, 180, 34);
c2 = new Color(0, 0, 0);
font = new Font("Ariel", Font.BOLD, (int)board[i][j].getWidth() -
(int)board[i][j].getWidth()/3);
break;
case 512:
c = new Color(238, 173, 14);
c2 = new Color(0, 0, 0);
font = new Font("Ariel", Font.BOLD, (int)board[i][j].getWidth() -
(int)board[i][j].getWidth()/3);
break;
case 1024:
c = new Color(238, 173, 14);
c2 = new Color(0, 0, 0);
font = new Font("Ariel", Font.BOLD, (int)board[i][j].getWidth() -
(int)board[i][j].getWidth()/2);
break;
case 2048:
c = new Color(205, 149, 12);
c2 = new Color(0, 0, 0);
font = new Font("Ariel", Font.BOLD, (int)board[i][j].getWidth() -
(int)board[i][j].getWidth()/2);
break;
case 4096:
c = new Color(0, 0, 0);
c2 = new Color(255, 255, 255);
font = new Font("Ariel", Font.BOLD, (int)board[i][j].getWidth() -
(int)board[i][j].getWidth()/2);
break;
default:

23
c = new Color(255, 0, 0);
c2 = new Color(255, 255, 255);
font = new Font("Ariel", Font.BOLD, (int)board[i][j].getWidth() -
(int)board[i][j].getWidth()/2);
break;
}

g2d.setColor(c);
g2d.fill(board[i][j]);
g2d.setColor(Color.GRAY);
g2d.draw(board[i][j]);
if(sit[i][j] != 0) {
g2d.setColor(c2);
g2d.setFont(font);
if(sit[i][j] < 128)
g2d.drawString(Integer.toString(sit[i][j]), (int)board[i][j].getX() +
(int)board[i][j].getWidth()/4, (int)board[i][j].getY() + (int)board[i][j].getHeight() - 10);
else {
g2d.drawString(Integer.toString(sit[i][j]), (int)board[i][j].getX() +
(int)board[i][j].getWidth()/8, (int)board[i][j].getY() + (int)board[i][j].getHeight() - 15);
}
}
}
}
Font font = new Font("Ariel", Font.BOLD, 100);
g2d.setFont(font);
if(win) {
g2d.setColor(Color.green);
g2d.drawString("YOU WIN!!!", getWidth()/18, getHeight()-getHeight()/2);
}
else if(lost) {
Font font2 = new Font("Ariel", Font.BOLD, 90);
g2d.setFont(font2);
g2d.setColor(Color.red);
g2d.drawString("GAME OVER", getWidth()/150, getHeight()-getHeight()/2);
}
}

@Override
public void mouseClicked(MouseEvent arg0) {

24
// TODO Auto-generated method stub

@Override
public void mouseEntered(MouseEvent arg0) {
// TODO Auto-generated method stub

@Override
public void mouseExited(MouseEvent arg0) {
// TODO Auto-generated method stub

@Override
public void mousePressed(MouseEvent e) {
x = e.getX();
y = e.getY();
}

@Override
public void mouseReleased(MouseEvent e) {
xa = e.getX() - x;
ya = e.getY() - y;
if(Math.abs(xa) > Math.abs(ya)) {
if(xa > 0) {
right = true;
up = false;
down = false;
left = false;
}
else {
right = false;
up = false;
down = false;
left = true;
}
}

25
else {
if(ya < 0) {
right = false;
up = true;
down = false;
left = false;
}
else {
right = false;
up = false;
down = true;
left = false;
}
}

if(right)
System.out.println("right");
if(left)
System.out.println("left");
if(up)
System.out.println("up");
if(down)
System.out.println("down");
setCon();
move = true;

public static void main(String[] args) throws InterruptedException


{
System.out.println("Copy this code to Eclipse in a class called 'Main',\n and then remove
all of the comments symbols (such as // or /*).\n enjoy the game :)");
JFrame frame = new JFrame("2048");
Main m = new Main();
frame.setSize(600, 600);
frame.add(m);
frame.setVisible(true);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
m.init();
m.randomNumber();

26
m.setBoard();
while(true) {
m.repaint();
Thread.sleep(15);
m.setBoard();
if(m.move) {
m.moveNumbers();
m.check();
}
if(m.win || m.lost)
break;
}

}
};

27
Output:

28
29
Setup :

30
Results

1. Results
The results or outcomes of the 2048 game can be categorized based on the player's
achievement and strategy. Here's a brief overview:

1. *Winning the Game*: The primary objective is to create a tile with the number 2048.
Achieving this means the player has won the game. However, it's possible to continue playing
beyond this point to accumulate a higher score by creating tiles with even larger numbers,
such as 4096, 8192, and so on.

2. *High Scores*: The game also keeps track of the player's score, which increases with each
combination of tiles. High scores are often pursued by players as a secondary objective to the
main goal of creating a 2048 tile. The score is a measure of how efficiently a player has
combined the tiles and how long they have been able to continue the game after reaching the
2048 tile.

3. *Game Over*: If the player fills up the board with tiles and no more moves are possible
(i.e., no adjacent tiles can be combined), the game ends. The final score is calculated, and the
player can start over to try and achieve a better result.

4. *Strategy and Improvement*: Over time, players develop strategies to maximize their
scores and chances of winning. These can include tactics like keeping the highest-value tiles
in a corner and carefully planning moves to avoid prematurely filling the board.

31
5. *Personal Bests and Competition*: Many players aim to beat their own high scores, while
others compete with friends or on global leaderboards to see how they rank in achieving the
highest possible tile or score.

The allure of 2048 lies in its simple yet challenging gameplay, where each new game offers
a fresh opportunity to beat previous records or achieve new milestones.

Conclusion

In conclusion, the "2048" game is a captivating puzzle that combines simple mechanics with
complex strategic depth. Its evolution from a single-player mobile game to a global
phenomenon has highlighted the inherent appeal of combining numbers and logic. Whether
as a source of entertainment, a tool for teaching mathematical concepts, or a subject of study,
"2048" continues to leave its mark on the gaming landscape, showcasing the enduring allure
of numerical puzzles in our digital age.

32
Conclusion & Future scope
Conclusion:

The 2048 game, since its inception, has remained a popular and engaging puzzle game, cherished for its
simplicity, cognitive challenge, and the quick satisfaction it offers. Its accessibility and short gameplay loops
make it an enduring choice for casual gamers and those seeking a mental workout alike. Here's a look at its
conclusion and the potential future scope:

Conclusion:

- *Enduring Popularity*: 2048 has cemented its place in the realm of popular puzzle games due to its
straightforward mechanics, challenging gameplay, and the addictive satisfaction of achieving a high score or
reaching the elusive 2048 tile and beyond.

- *Cognitive Benefits*: It encourages strategic thinking, planning, and problem-solving, contributing to its
appeal across a wide age range. Players learn to anticipate the consequences of their moves in advance, a
skill that has broader applications outside the game.

- *Community and Sharing*: The game's success has fostered a community of players who share strategies,
high scores, and variations, enhancing its replay value and keeping the interest alive.

33
Future Scope:

- *Technological Integration*: With advancements in mobile technology and app development, 2048 could
see integration with newer technologies like augmented reality (AR) for a more immersive experience or
social media for easier sharing of achievements and competitive play.

- *Educational Applications*: Its potential for cognitive skill development could be harnessed more formally
in educational contexts, perhaps tailored as a tool for learning mathematics or strategic thinking in a fun and
engaging manner.

- *Variations and Expansions*: Developers can create more complex variations of the game, introducing new
rules, grid sizes, or objectives to keep the gameplay fresh. There's also the potential for multiplayer modes,
where players can compete or collaborate in real-time.

- *Gamification and Rewards*: Implementing a rewards system, achievements, or integrating gamification


elements could enhance player engagement and motivation, making each session more rewarding.

In essence, the 2048 game has a solid foundation with significant potential for growth and adaptation. Its
blend of simplicity, challenge, and the cognitive engagement it offers can serve as a platform for educational
tools, technological innovation, and community building in the gaming world. As long as developers and the
community continue to support and evolve the concept, 2048 is likely to remain a staple in the puzzle game
genre for years to come.

34
References

. https://www.umaexports.net/

• https://creately.com/diagram/example/j9sg1w3e1/e-farmer-classic

• https://aussiefoodexport.com/

• https://www.agrifarming.in/top-agriculture-companies-in-india-best-

35

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy