Tải bản đầy đủ (.pdf) (53 trang)

Đồ án xây dựng multiplayer peer to peer game

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (832.23 KB, 53 trang )

ĐẠI HỌC QUỐC GIA THÀNH PHỐ HỒ CHÍ MINH
TRƯỜNG ĐẠI HỌC CÔNG NGHỆ THÔNG TIN
KHOA CÔNG NGHỆ PHẦN MỀM

BÁO CÁO ĐỒ ÁN 2
ĐỀ TÀI:
XÂY DỰNG MULTIPLAYER PEER-TO-PEER GAME
Giảng viên:
Trần Thị Hồng Yến
Sinh viên thực hiện:
Nguyễn Tuấn Kiệt

Thành phố Hồ Chí Minh, năm 2022

1


VIETNAM NATIONAL UNIVERSITY - HO CHI MINH CITY
UNIVERSITY OF INFORMATION TECHNOLOGY
THE FACULTY OF SOFTWARE ENGINEERING

PROJECT 2 REPORT
PROJECT:
BUILDING MULTIPLAYER PEER-TO-PEER GAME
Instructor:
Trần Thị Hồng Yến
Student:
Nguyễn Tuấn Kiệt

Hồ Chí Minh, year 2022


2


Document change record sheet
Date

Version Description

Authors

30/06/2023

1.0

Nguyễn Tuấn
Kiệt

Disclaimer:
All of the resources in game are free for commercial usages, or,
drawn by myself. Every credits have been listed in Credit
Section (this document), in Credit File (the game folder) and in
Credit Board (in game).

3


Table of Contents
Table of Contents ................................................................................................................ 4
Images Table of Content ..................................................................................................... 6
Acknowledgement .............................................................................................................. 7

Detailed Outline .................................................................................................................. 8
Chapter I: Introduction ..................................................................................................... 14
I. Basic Information ....................................................................................................... 14
1. Group Information ................................................................................................ 14
2. Project Information ............................................................................................... 14
3. Technology Used ................................................................................................... 14
II. Statement Of The Project ......................................................................................... 16
1. Story ...................................................................................................................... 16
2. Brief About Objects In Game ................................................................................ 17
3. Functional Requirements ...................................................................................... 18
4. Non-functional Requirements .............................................................................. 20
Chapter II: Use Case .......................................................................................................... 22
I. User story ................................................................................................................... 22
II. Use Case Models ....................................................................................................... 23
Chapter III: Data Design .................................................................................................... 36
I. Local Data Control: ..................................................................................................... 36
II. Database Design: ...................................................................................................... 36
1. User ....................................................................................................................... 36
2. Character ............................................................................................................... 36
3. LobbyRoom ........................................................................................................... 37
Chapter IV: Interface Design ............................................................................................. 38
I. Regulation .................................................................................................................. 38
II. List Of UIs: ................................................................................................................. 38
III. Details Description ................................................................................................... 38

4


Chapter V: Installation ...................................................................................................... 51
Chapter VI: Conclusion...................................................................................................... 52

I. Result ......................................................................................................................... 52
II. Limitations................................................................................................................. 52
References ........................................................................................................................ 53

5


Images Table of Content
Image
Image
Image
Image
Image
Image
Image
Image
Image
Image
Image
Image
Image
Image
Image
Image
Image

1: Godot ................................................................................................................ 14
2: GitHub ................................................................. Error! Bookmark not defined.
3: Player Use Case Diagram .................................... Error! Bookmark not defined.
4: Login Screen ........................................................ Error! Bookmark not defined.

5: Register Screen .................................................... Error! Bookmark not defined.
6: Naming Screen..................................................... Error! Bookmark not defined.
7: Main Screen ......................................................... Error! Bookmark not defined.
8: Credit Screen........................................................ Error! Bookmark not defined.
9: Customization Window ....................................... Error! Bookmark not defined.
10: Lobby Screen ..................................................... Error! Bookmark not defined.
11: Host UI............................................................... Error! Bookmark not defined.
12: Join UI................................................................ Error! Bookmark not defined.
13: Password UI ....................................................... Error! Bookmark not defined.
14: Ingame UI .......................................................... Error! Bookmark not defined.
15: Join UI................................................................ Error! Bookmark not defined.
16: Confirm Dialog Window ................................................................................ 49
17: Yes/No Dialog Window.................................................................................. 50

6


Acknowledgement
Have been studying and training in University of Information
Technology – Hồ Chí Minh City as a Software Engineering
student, I now have the fundamental knowledge and practical
abilities needed to attend Project 2.
I would like to offer my sincere appreciation to those who made
it possible to complete this course:
To University of Information Technology. This is where I
created my base programming skills. Without taking part in our
university, I wouldn’t have a chance to pursue my passion.
To Mrs. Yến. Without your enthusiastic help and guidances,
the development would not process as I had planned.
To Juan Linietsky, Ariel Manzur and Godot Community.

Studying and using Godot is one of my best experience in my
“game dev” lifetime. Thanks you for creating a tool that can
make any imagination possible.
And finally, to my family, my love, all the teachers and staffs
in the university, my friends. You are my reasons to keep
working.
In the process of doing Project 2, I will have unavoidable
mistakes. Therefore, it would be so grateful for me if I can
receive guidances, suggestions and advices from everyone. That
will be my inventories to improve and develop myself to take
part in the Graduation Thesis.
I am sincerely appreciated. Wish the best of luck will always
accompany you all.
Hồ Chí Minh City 30/06/2023
Kiệt
Nguyễn Tuấn Kiệt

7


Detailed Outline
PROJECT NAME: PEER-TO-PEER MULTIPLAYER GAME
Instructor: M.S. Trần Thị Hồng Yến.
Implementation time: From 27/02/23 To 17/06/2023
Students:
Nguyễn Tuấn Kiệt – 20520906.
Project information:
1. Purpose of the project:
Before taking part in this course, I have taken part in the Project 1
course by developing a Rogue-Lite game. However, I want to try to

develop a multiplayer game that can be played by multiple people,
from different places at the same time! Using GDScript cannot
optimize the performance of the game; therefore, I need to study
about the database and network.
So, in Project 2, I want to:
• Using C# instead of GDScript to improve performance.
• Developing a multiplayer game using Peer-to-Peer method.
• Having an online database.
And, it is nice to have:
• The game can protect user’s information.
• The game is able to get fixed, updated.

In conclusion, I do not only want to improve my skills after this
course but also want to create a fun game that has wide-range of
players.

8


2. About game:
- The game’s main genre is Platformer with 2D Pixel Graphics.
- As a Platformer game, the game should create challenge by using tricky
platform to restrict players’ movement, or everything else relative to “the
platform”.
- The main purpose of the game is to be the fastest person reaching the
goal before anyone else.

3. Scoop
- Environmental Scope: Windows 7 or later.
- Player Scope: Everyone. (Based on ESRB)

- Features Scope:
• For users:
o Sign in, sign up or finding password through Email.
o Change the appearance of the ingame character.
o Watch the credits.
o Can host a new room or join available rooms.
o Can customize the room when created.
• Game:
o Have lobby to track for all of available rooms.
o Each room has:
▪ Name (required).
▪ Password.
▪ Map (required).
o The character can move left and right, wall climb and wall
jump.
o The game can handle situations like when the host goes
offline, clients disconnect,…
o All the animations, graphics, name can be synced between
multiple devices.

9


o The game needs to run real-time with the online database.
o Has methods to secure users’ information like password.
o Handle errors during game sessions.

4. Implementation
- Working online with instructor during the course.
- Using Godot for game developing.

- C# as programming language.
- Visual Studio Code as the IDE.
- Firestore for online database.
- Version Control through Github.
- Using Google Docs and Microsoft Word/Excel for reports and
documents.
- Using Draw.io, Lucid Chart for diagrams.

5. Developing platforms and environments
- Platforms: Windows 10.
- Environments: Godot.
- Programming Language: C#.
- IDE: Visual Studio Code.
- VCS: Github.
- UML Tools: Draw.io.

6. Expected result
- The game runs without bugs.

10


- Beatable game. (Not impossible to finish the game)
- Collisions are well handled.
- Database runs in real-time.
- The game syncs well with the online database.
- Multiple devices can be synced.

7. Work plan
Time

1. 27/2/2023

Task
- Have written the first version of GDD.
- Decide which functions should be kept after brainstorming.
- Finding/Creating assets for game developing.

2. 1/3/2023

- Having the basic UI for the games – especially the
login UI.
- Creating testing online database for testing
connection.
- Testing the connection between single device to the
online database.
- Refine the connection.

3. 8/3/2023

- Have done the movement functions of the game
characters, including: move left/right, jump, fall, wall
climb, wall jump.
- Imply the standard graphics for the character –
which have not changed based on users’ choices.
- Imply the basic tilesets.
- Imply collisions for environment and character.

4. 15/3/2023

- Have done the main menu/screen.


11


- Have done the basic GUI.
- Have done the customization screen for users where
they can change their character’s appearance.
- Have done Lobby Screen.
- Have done UI for Room Creating.
- Have done UI for In-Room Waiting.
- Have done UI for multiple Pop-up Dialogs.
- Level Design.
5. 22/3/2023

- Have done Login Screen’s Functions:




Sign In.
Sign Up.
Find Password.

- Every function in Login Screen need to connect
successfully to the database.
- Have done Customization’s functions.
6. 31/3/2023

- Imply Main Screen’s functions.
- Imply Lobby’s functions.

- Imply Room’s functions.

7. 7/4/2023

- Imply peer-to-peer connection between 2 players.
- Imply spawner.
- Imply necessary GUIs.

8. 14/4/2023

- Sync the animation of the player’s device when
changing the graphics in Customization Screen.
- Sync the graphics, name and animation between
multiple peers.

9. 21/4/2023

Test and Catch bugs session 1.

10. 28/4/2023

- Handle special situations in game like: disconnection

12


from host, disconnection from clients.
- Imply functions to dialogs.
11. 5/5/2023


- Add more graphics to choose.
- Level Design.

12. 12/5/2023

Test and Catch bugs session 2.

13. 1/6/2023

Polish the whole game.

Xác nhận của CBHD

TP. HCM, ngày 30 tháng 06 năm
2023

(Ký tên và ghi rõ họ tên)

Sinh viên
(Ký tên và ghi rõ họ tên)

Yến

Kiệt

Trần Thị Hồng Yến

Nguyễn Tuấn Kiệt

13



Chapter I: Introduction
I. Basic Information
1. Group Information
Student ID

Name

Email

20520906

Nguyễn Tuấn Kiệt



2. Project Information





Project name: Building a multiplayer peer-to-peer game.
Game name: Poppit Arena.
Technology: Godot.
Game development environment: Windows 11.

3. Technology Used
3.1 Godot


Image 1: Godot

Godot is a cross-platform, free and open-source game engine released under
the MIT license. It was initially developed by Argentine software

14


developers Juan Linietsky and Ariel Manzur for several companies in Latin
America prior to its public release. The development environment runs on
multiple operating systems including Linux, BSDs, macOS, and Microsoft
Windows. It is designed to create both 2D and 3D games targeting PC,
mobile, and web platforms. It can also be used to create non game software,
including editors.

Godot aims to offer a fully integrated game development environment. It
allows developers to create a game, needing no other tools beyond those
used for content creation (visual assets, music, etc.). The engine's
architecture is built around the concept of a tree of "nodes". Nodes are
organized inside of "scenes", which are reusable, instanceable, inheritable,
and nestable groups of nodes. All game resources, including scripts and
graphical assets, are saved as part of the computer's file system (rather than
in a database). This storage solution is intended to facilitate collaboration
between game development teams using software version control systems.

3.2 C#
C# is a modern, object-oriented programming language developed by
Microsoft as part of the .NET framework. It was first released in 2002 and
is widely used for building Windows desktop applications, web

applications, mobile apps, and games.
C# is designed to be simple, efficient, and type-safe, meaning that the
language enforces strict type checking to prevent errors at compile-time. It
also includes features such as garbage collection, automatic memory
management, and support for multithreading, making it well-suited for
building scalable and high-performance applications.
C# syntax is similar to other C-style languages such as Java and C++, with
features such as classes, interfaces, inheritance, and generics. It also
includes newer language features such as async/await for asynchronous
programming, LINQ for querying data, and extension methods for adding
functionality to existing types.

15


C# is a popular choice for building enterprise-level applications and is wellsupported by Microsoft and the .NET community. It also has a large
number of third-party libraries and frameworks available, making it easy to
build complex applications quickly.

3.3 GitHub

Image 2: GitHub

GitHub is an Internet hosting service for software development and version
control using Git. It provides the distributed version control of Git plus
access control, bug tracking, software feature requests, task management,
continuous integration, and wikis for every project. Headquartered in
California, it has been a subsidiary of Microsoft since 2018.

It is commonly used to host open source software development projects. As

of June 2022, GitHub reported having over 83 million developers and more
than 200 million repositories, including at least 28 million public
repositories. It is the largest source code host as of November 2021.

II. Statement Of The Project
1. Story
Once upon a time, there was a kind of creature named Poppit. They are cute,
dynamic and they love to run here and there. Therefore, the highest king of

16


the whole Poppit decide to hold a competition, seeking for the fastest,
strongest, most intelligent to lead the whole kingdom side by side with the
king.

They call it – THE POPPIT ARENA.

2. Brief About Objects In Game
2.1 Player
- The Game Object that we control based on rules of the game.
- Player can do all of the things that were mentioned in the feature section
above.

2.2 The Boat
- The Boat is the object that will carry the players to lobby screen.
- It can be interacted with by using keyboards or click on the floating button.
- The Boat has cute floating animation.

2.3 Decoration Chest

- This is where users can change the player’s appearance.
- It can be interacted with by using keyboards or click on the floating button.

2.4 The Memory Totems
- This is where users can watch the credits.
- It can be interacted with by using keyboards or click on the floating button.

17


2.5 Victory Flag
- This is the flag appearing in each game session (map).
- The first player touch the Victory Flag will be the winner of that game
session.

3. Functional Requirements
3.1 Security
3.1.1 Hash & Salt
- Hash & Salt is a method to secure the users’ passwords by creating a
random string after X times hashing – which means the password is chosen
after X times randomly created.
- Salt is a chain that will be mixed into the encrypted password that will
give the game hint to check if the "pure text” users input match the
password.
- Hash password and salt string will be kept in the Firestore Database.

3.1.2 Database
The database has divided into multiple classes and parts which will create a
better protection to the private information such as name, appearance of the
character,…


3.2 Network
3.2.1 Peer-To-Peer
- Peer-to-peer (P2P) is a decentralized communication model in which two
or more computers or devices are connected to each other directly, without
the need for a centralized server or authority. In a P2P network, each device

18


can act as both a client and a server, allowing them to share resources and
information with each other.
- In a P2P network, all devices are considered equal, and each device has
the ability to initiate and respond to requests. This allows for faster and
more efficient communication, as there is no single point of failure or
bottleneck in the network.
- P2P networks are commonly used for file sharing, as they allow users to
share files with each other without relying on a central server. They are also
used for decentralized applications, such as cryptocurrency networks,
where each node in the network maintains a complete copy of the ledger.
- While P2P networks have several advantages, they also have some
drawbacks, including the potential for security vulnerabilities and the
difficulty of managing large-scale networks.

3.2.2 UPNP
- UPnP stands for Universal Plug and Play, which is a set of networking
protocols that allow devices to discover and communicate with each other
on a local network. UPnP is designed to simplify the process of connecting
devices to a network, and it is widely used in home networking equipment,
such as routers, printers, and media servers.

- UPnP enables devices to automatically discover each other on a network
and establish communication without requiring manual configuration by the
user. For example, a UPnP-enabled device can automatically discover and
connect to a router on the network, and the router can automatically
configure the device's network settings.
- One of the key features of UPnP is its ability to support "port forwarding",
which allows devices on a network to receive incoming network traffic
from the internet. This is often required for applications such as online
gaming or remote access to a home network.
- While UPnP can simplify the process of connecting devices to a network,
it has also been criticized for potential security vulnerabilities. Because

19


UPnP allows devices to automatically discover and communicate with each
other, it can also allow malicious software to spread more easily between
devices on a network. As a result, it is important to use UPnP with caution
and to ensure that devices on the network are properly secured.

3.2.3 Using Database instead of UPnP
- To use UPnP, it is required to have the UPnP settings turning on in every
network modem. It may not have worked in multiple situations such as
using public network like coffee shop, malls,…
- Moreover, a lot of threads have been stated that UPnP can be dangerous to
users, which may not be the case but I want to have the best way to deal
with the problem.
- Therefore, I use database to store users’ public IP when creating the room,
convert them into random combination of 5 characters (numbers and
letters). It is compulsory to check if the combination has been made before

so there will not have the problem of duplicated string codes.
- Now, instead of using UPnP to spider the whole internet to receive room
ids, the game will load all of the stored ids in the lobby. Therefore, users
can connect to each other without worrying of sending IP or opening ports.

4. Non-functional Requirements
4.1 Interface Requirements
- Uniform and easy to read the texts and commands.
- Easy to understand what to do.

4.2 Game Balancing Requirements
- Has replay value.

20


- Player should feel that the game is hard enough to try but still feel it is
beatable.
- Gives Player the ability to complete the game without failing.

4.3 Compatibility Requirements
Should be able to run on Windows 7 or later.

4.4 Quality & Efficiency Requirements
- No drop in FPS.
- No glitching.
- Any game object/entity that has been destroyed need to be realeased from
memory.
- Graphics should have no blur.


21


Chapter II: Use Case
I. User story
User

User Stories
As a player, I want to
create an account.
As a player, I want to
login.
As a player, I want to
find my password in
case I forget it.
As a player, I want to
name my character.
As a player, I want to
customize character’s
appearance.

Player
As a player, I want to
know the credits.

As a player, I want to
go to the lobby.
As a player, I want to
create a new room
with my selected map

and
restrict
the
number of players.

Important
Nouns
player
system
database
player
system
database
player
system
database
player
system
database
player
system
database
HUD
player
system
database
HUD
player
system
database

HUD
player
system
database
HUD

player
As a player, I want to
system
join a room by
database
multiple ways.
HUD

Important
Verbs

Connections

player
system
database
player
sign in
system
database
player
find
system
password

database
player
naming
system
database
player
system
customize
database
HUD
player
system
credits
database
HUD
player
navigate to system
lobby
database
HUD


-

create room

player
system
database
HUD




-

join room

player
system
database
HUD



-

sign up










-

22



II. Use Case Models
1. Use Case Diagrams
The game only has 1 Use Case Model which is “the Player”. Other main
mechanics are game system, database and synchronizer.

Image 3: Player Use Case Diagram

23


2. Actor List
No.

Actor’s Name

1

Player

Brief Description
Is the entity that you use to interact with the
game. Player can move, jump, fall, wall
climbing, wall jumping and interact with other
elements.

Game’s other control elements
No.


Element’s Name

1

Game System

2

Synchronizer

3

Database

Brief Description
Is the element that controls the whole game.
Every action needs to be determined by the
Game System. It check if the action is remotely
or locally or both; determine if the action is for
in-game session or during idle state,…
Is the element that notice other peers in the
game session that the user’s action has been
executed. The message will be sent to the Game
System, examined then send back to all of the
available peers. Peers receive signal then fire
the method which is relative to the signal.
Is the element that control the real-time event in
game. Most of the mechanics are relative to
database. Customization, tutorials attended,
room attendees, password, name,… Everything

needs to be updated ASAP.

3. Use Case List
No.

Use Case’s Name

1

Check Database

2

Sign Up

3

Find Password

4

Sign In

Brief Description
The use case begins when user triggers an
action relative to information like: save,
update, create, delete,…
The use case begins when user presses Sign
Up Button.
The use case begins when user presses Find

Password Button.
The use case begins when user presses Sign In
Button.

24


5

Customize

6

Watch Credits

7

Quit

8

Navigate To Lobby

9

Filter

10

Host


11

Join

12

Play

13

Move

14

Jump

15

Wall Climb

16

Wall Jump

17

Interact

18


Check Restriction

19

Check Action’s
Condition

20

Sync With Peers

The use case begins when user presses or
interacts with Customize Button.
The use case begins when user presses or
interacts with Watch Credits Button.
The use case begins when user presses or
interacts with Quit Button.
The use case begins when user presses or
interacts with Navigate To Lobby Button.
The use case begins when user triggers one or
many filters.
The use case begins when user presses Host
Button.
The use case begins when user presses Join
Button to input the Room’s ID, or, presses
Join Button of the available rooms.
The use case begins when user completes Host
or Join action.
The use case begins when user presses Left or

Right Button.
The use case begins when user presses X
Button.
The use case begins when user presses C
Button.
The use case begins when user presses X
Button when holding C Button.
The use case begins when user presses E
Button.
The use case begins when user triggers an
action relative to collision.
The use case begins when user triggers an
action.
The use case begins when user triggers an
action.

4. Use Case Specification
4.1 Check Database
Short Description

The use case begins when user triggers an action
relative to information like: save, update, create,

25


×