0% found this document useful (0 votes)
461 views25 pages

2d Platformer

This document provides a project report for a 2D platformer game. It includes an introduction describing 2D platformer games in general. The design and implementation section covers the design of the game using use case and data flow diagrams and implementation using the Godot game engine and scripting. Testing results and conclusions are also presented.

Uploaded by

Namitha
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)
461 views25 pages

2d Platformer

This document provides a project report for a 2D platformer game. It includes an introduction describing 2D platformer games in general. The design and implementation section covers the design of the game using use case and data flow diagrams and implementation using the Godot game engine and scripting. Testing results and conclusions are also presented.

Uploaded by

Namitha
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/ 25

2D Platformer Game

A project report submitted in partial fulfillment of the requirements for


the award of the degree of

Bachelor of Computer Application (BCA)

Submitted by
Vaishnav V

St. George’s College, Aruvithura


Aruvithura PO, Erattupetta

Affiliated to

Mahatma Gandhi University


Kottayam
St. George’s College, Aruvithura
Aruvithura PO, Erattupetta - 686122

CERTIFICATE

This is to certify that report entitled “2D Platformer Game” is a bonafide


report of the main project (CA6CRP08 -Software Development Lab II ( Main
Project)) presented during VIth semester by Vaishnav V, in partial fulfillment of
the requirements for the award of the degree of Bachelor of Computer Application
(BCA).

Staff in Charge Project Guide Head of the Department

Place:

Date:

External Examiner Internal Examiner


ABSTRACT

A platform game is a subgenre of video game and can be of two types such
as a puzzle game or an action game. The main concept of a 2D platformer
is that the player will control a character or avatar and guide him through a
series of platforms that can be grounded or elevated depending on the level
design. The the mission of such games is always to collect certain items
(coins, rubies, etc.) and avoid or fight the enemy characters. The game
consists of air-suspended platforms and a system to collect coins.
ACKNOWLEDGEMENT

The successful completion of any project requires the collective effort


of many people, and I would like to take this opportunity to express my
heartfelt appreciation to everyone who contributed to the success of my
project.
First and foremost, I would like to express my sincere gratitude to Prof.
Dr. Siby Joseph, Principal of St. George’s College Aruvithura, for grant-
ing me access to all the necessary facilities during the project. I am truly
grateful for your unwavering support throughout the duration of my project.
I would also like to extend my thanks to Dr. Jestin Joy, Head of the
Department of Computer Applications, whose encouragement and guidance
enabled me to complete this project successfully. Your expertise and advice
have been invaluable to me.
I am also deeply grateful to my mentor, Dr. Gemini George, Assistant
Professor in the Department of Computer Applications, for her exceptional
guidance and support throughout the project. Your insightful feedback and
encouragement has been instrumental in the successful completion of this
project.
I would also like to thank every faculty member in the Department of
Computer Applications for their prompt assistance and support throughout
the project. Your enthusiasm and willingness to help have been invaluable
to me.
Lastly, I would like to express my gratitude to all my friends and family
members for their spiritual support and encouragement. Your unwavering
support has been a source of strength for me throughout this project.
Once again, thank you to everyone who contributed to the success of
this project. Your support and guidance have been instrumental in making
this project a reality.

Vaishnav V
Contents

List of Figures iv

List of Tables v

1 INTRODUCTION 1
1.1 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1

2 DESIGN and IMPLEMENTATION 2


2.1 Design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
2.1.1 Use-case Diagram . . . . . . . . . . . . . . . . . . . . . . . . 2
2.1.2 Data Flow Diagram . . . . . . . . . . . . . . . . . . . . . . . 4
2.2 Implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
2.2.1 Godot Engine . . . . . . . . . . . . . . . . . . . . . . . . . . 6
2.2.2 Godot Script . . . . . . . . . . . . . . . . . . . . . . . . . . 7

3 TESTING 8

4 RESULTS 9

5 CONCLUSION 11

Appendices 13

A Code for Main Menu 14

B Code for Main Screen/Activity 15

C Code for Player 16

iii
List of Figures

2.1 Use-case Symbols . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3


2.2 Use-case Symbols . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
2.3 DFD Symbols . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
2.4 Level 0 DFD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
2.5 Level 1 DFD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5

4.1 Main Menu . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9


4.2 Main Game screen . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
4.3 Pause Menu . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10

iv
List of Tables

3.1 Test Table for 2D Platformer Game . . . . . . . . . . . . . . . . . . 8

v
Chapter 1

INTRODUCTION

1.1 Overview
2D platformer games have been a beloved genre in the world of video games for
decades. With their iconic side-scrolling perspective, challenging platforming me-
chanics, and engaging gameplay, they have captivated players of all ages. From
leaping over gaps, dodging obstacles, defeating enemies, and collecting power-ups,
2D platformers offer thrilling adventures that require precise timing and quick
reflexes. Whether you’re a seasoned gamer or new to the genre, 2D platformers
provide a nostalgic and exciting gaming experience that keeps players coming back
for more.
The game’s popularity has only increased with the advent of modern gaming
platforms, and it remains a favorite among gamers of all ages. Whether playing
alone or with friends, ”2D Platformer” is an exhilarating and addictive game that
is sure to provide hours of entertainment.

1
Chapter 2

DESIGN and IMPLEMENTATION

2.1 Design

2.1.1 Use-case Diagram


A use case diagram is a type of diagram used in software development to describe
the functionality of a system or project from a user’s perspective. It provides a
high-level view of the system’s features and interactions with its users, and is often
used to aid in requirements gathering and analysis.
In a use case diagram, the actors (users or other systems) are represented as
stick figures, and the system’s functions are represented as ovals or rectangles.
The relationships between the actors and functions are depicted as arrows, which
indicate the interactions or behaviors that occur in the system.
A use case diagram typically includes the following elements:

• Actors: The users or other systems that interact with the system being
modeled.

• Use cases: The functions or tasks that the system can perform to meet the
needs of its users.

• Relationships: The interactions or behaviors between the actors and use


cases, which are depicted as arrows between the corresponding elements.

2
Figure 2.1: Use-case Symbols

The use-case diagram for this project is given below in Figure 3.3:

Figure 2.2: Use-case Symbols

3
In the above use-case diagram, there is only one user : Player .
The player has the following process

• Play the Game.

• Exit the Game.

2.1.2 Data Flow Diagram


A Data Flow Diagram (DFD) is a traditional visual representation of the infor-
mation flows within a system. A neat and clear DFD can depict the right amount
of the system requirement graphically. It shows how data enters and leaves the
system, what changes the information, and where data is stored. The following
observations about DFDs are essential:

• All names should be unique. This makes it easier to refer to elements in the
DFD.

• Remember that DFD is not a flow chart. Arrows in a flow chart represent
the order of events; arrows in DFD represent flowing data. A DFD does not
involve any order of events.

• Suppress logical decisions. If we ever have the urge to draw a diamond-


shaped box in a DFD, suppress that urge! A diamond-shaped box is used in
flow charts to represent decision points with multiple existing paths of which
only one is taken. This implies an ordering of events, which makes no sense
in a DFD.

• Do not become bogged down with details. Defer error conditions and error
handling until the end of the analysis

Different symbols used in DFD are given in Figure 3.4:

Figure 2.3: DFD Symbols

4
Levels or layers are used in DFDs to represent progressive degrees of detail
about the system or process. These levels include:
• Level 0: Also known as a ”context diagram,” this is the highest level and
represents a very simple, top-level view of the system being represented.
• Level 1: Still a relatively broad view of the system, but incorporates sub-
processes and more detail.

Figure 2.4: Level 0 DFD

Figure 2.5: Level 1 DFD

5
The level 0 and level 1 DFDs are given in Figure 3.5 and Figure 3.6 respectively:

1. Input Data: This process receives input data from the Player entity, which
could be in the form of keyboard or gamepad inputs.

2. Controls: This process interprets the input data and generates commands
for the game engine, such as movement or slashing.

3. Collision Data: This process detects and resolves collisions between game
objects.

4. Visuals: This process generates the visual effects based on the Object State
data.

5. Output Data: This process combines the sound and visual data into a
single output stream.

6. Display : This process outputs the final combined data stream to the display
device.

These processes provide an overview of the flow of data and actions in the 2D
Platformer Game. They help ensure that users can easily understand how the
game works

2.2 Implementation

2.2.1 Godot Engine


Godot Engine is a popular open-source game engine that provides game developers
with a powerful and flexible platform for creating 2D and 3D games. It was first
released in 2014 and has gained popularity due to its ease of use, community
support, and versatility.
One of the key benefits of Godot Engine is its visual scripting system, which
allows developers to create complex game logic and behavior without writing code.
This feature is particularly useful for non-programmers and hobbyists who want
to create games but may not have extensive coding experience.
Another advantage of Godot Engine is its ability to export games to multiple
platforms, including Windows, macOS, Linux, iOS, Android, and web browsers.
This makes it an ideal choice for developers who want to reach a wide audience
with their games.
In addition to its technical features, Godot Engine has a strong and supportive
community of developers and contributors who provide regular updates, tutorials,
and resources to help users learn and improve their game development skills.

6
2.2.2 Godot Script
Godot Script is a programming language that is used to develop games using the
Godot Engine. It is a high-level, dynamically typed language that is easy to learn
and use, even for those who have little or no prior programming experience.
The syntax of Godot Script is similar to Python, making it familiar to many
programmers. It supports object-oriented programming concepts such as inher-
itance, polymorphism, and encapsulation, allowing developers to create complex
game logic and behaviors.
Godot Script also includes a built-in editor that provides code highlighting,
code completion, and error checking, making it easier to write code and identify
errors.

7
Chapter 3

TESTING

It is the process of evaluating a system or its components with the intent to find
whether it satisfies the related requirements. In computer hardware and software
development, testing is used at key checkpoints in it. It’s done by executing
the software’s overall process to identify whether objectives are being met. The
process or method of finding errors in a software application or program so that
the application functions according to the end user’s requirement is called software
testing. The test cases and results are given below in Table 4.1:

Table 3.1: Test Table for 2D Platformer Game


Test ID Test Description Expected Outcome Actual Outcome Pass/Fail
1 Game launch The game should The game launches Pass
launch successfully without any errors.
without any errors.
2 Main menu navigation Player can navigate The player can navi- Pass
through the main gate through the main
menu. menu successfully.
3 Player movement The player should be The player moves left, Pass
able to move left, right, and jumps suc-
right, and jump cessfully.
4 Environment collision The player should col- The player collides Pass
detection. lide with the environ- with the environment
ment and enemies and enemies.
5 Enemy movement Enemy should move Enemy moves and col- Pass
and collide with the lides with the player.
player.
6 Sound effects and mu- The game should have The game has appro- Pass
sic appropriate sound ef- priate sound effects
fects and music. and music.

8
Chapter 4

RESULTS

Figure 4.1: Main Menu

Figure 4.2: Main Game screen

9
Figure 4.3: Pause Menu

10
Chapter 5

CONCLUSION

In conclusion, the 2D platformer game provides a highly enjoyable and challenging


gaming experience for players. The game’s intuitive controls, engaging gameplay
mechanics, and visually stunning graphics create an immersive and entertaining
dungeon-themed environment for players to enjoy. Throughout the development
process, a range of testing scenarios was conducted to identify and rectify any bugs
or issues, ensuring that the game is stable and fully functional. Overall, the 2D
platformer game offers an exceptional gaming experience that is certain to keep
players engaged and eager to return for a more thrilling gameplay.

11
Bibliography

[1] Stack Overflow https://stackoverflow.com/

[2] Godot Engine Downloads https://godotengine.org/

12
Appendices

13
Appendix A

Code for Main Menu

extends Control

func on Start pressed ():


g e t t r e e ( ) . c h a n g e s c e n e ( ” r e s : / / World . t s c n ” )

func on Quit pressed ( ) :


get tree ( ) . quit ()

14
Appendix B

Code for Main Screen/Activity

e x t e n d s Node
onready var pause menu = $ I n t e r f a c e L a y e r /PauseMenu

func init ():


OS . m i n w i n d o w s i z e = OS . w i n d o w s i z e
OS . max window size = OS . g e t s c r e e n s i z e ( )

func n o t i f i c a t i o n ( what ) :
i f what == NOTIFICATION WM QUIT REQUEST :
# We need t o c l e a n up a l i t t l e b i t f i r s t
#t o a v o i d Viewport e r r o r s .
i f name == ” S p l i t s c r e e n ” :
$Black / S p l i t C o n t a i n e r / ViewportContainer1 . f r e e ( )
$Black . q u e u e f r e e ( )

func unhandled input ( event ) :


i f event . i s a c t i o n p r e s s e d ( ” t o g g l e f u l l s c r e e n ” ) :
OS . w i n d o w f u l l s c r e e n = not OS . w i n d o w f u l l s c r e e n
get tree ( ) . set input as handled ()
e l i f event . i s a c t i o n p r e s s e d ( ” toggle pause ” ) :
var t r e e = g e t t r e e ( )
t r e e . paused = not t r e e . paused
i f t r e e . paused :
pause menu . open ( )
else :
pause menu . c l o s e ( )
get tree ( ) . set input as handled ()
e l i f event . i s a c t i o n p r e s s e d ( ” s p l i t s c r e e n ” ) :
i f name == ” S p l i t s c r e e n ” :
$Black / S p l i t C o n t a i n e r / ViewportContainer1 . f r e e ( )
$Black . q u e u e f r e e ( )
g e t t r e e ( ) . change scene (
” r e s : / / s r c /Main/Game . t s c n ”
)
else :
g e t t r e e ( ) . change scene (
” r e s : / / s r c /Main/ S p l i t s c r e e n . t s c n ”
)

15
Appendix C

Code for Player

class name Player


e x t e n d s Actor

signal collect coin ()

c o n s t FLOOR DETECT DISTANCE = 2 0 . 0

e x p o r t ( S t r i n g ) var a c t i o n s u f f i x = ””

onready var platform detector = $PlatformDetector


onready var a n i m a t i o n p l a y e r = $AnimationPlayer
onready var s h o o t t i m e r = $ShootAnimation
onready var sprite = $Sprite
onready var sound jump = $Jump
onready var gun = s p r i t e . g e t n o d e (@”Gun” )

func ready ( ) :
var camera : Camera2D = $Camera
i f a c t i o n s u f f i x == ” p1 ” :
camera . c u s t o m v i e w p o r t = $” . . / . . ”
yield ( get tree () , ” idle frame ”)
camera . m a k e c u r r e n t ( )
e l i f a c t i o n s u f f i x == ” p2 ” :
var v i e w p o r t : Viewport
= $” . . / . . / . . / . . / ViewportContainer2000 / Viewport2 ”
v i e w p o r t . w o r l d 2 d = ( $” . . / . . ” as Viewport ) . w o r l d 2 d
camera . c u s t o m v i e w p o r t = v i e w p o r t
yield ( get tree () , ” idle frame ”)
camera . m a k e c u r r e n t ( )

func physics process ( delta ):


i f Input . i s a c t i o n j u s t p r e s s e d (
”jump” + a c t i o n s u f f i x
)

16
and i s o n f l o o r ( ) :
sound jump . p l a y ( )
var d i r e c t i o n = g e t d i r e c t i o n ( )
var i s j u m p i n t e r r u p t e d = Input . i s a c t i o n j u s t r e l e a s e d (
”jump” + a c t i o n s u f f i x
)
and v e l o c i t y . y < 0 . 0
velocity = calculate move velocity (
v e l o c i t y , d i r e c t i o n , speed , i s j u m p i n t e r r u p t e d
)
var s n a p v e c t o r = Vector2 .ZERO
i f d i r e c t i o n . y == 0 . 0 :
s n a p v e c t o r = Vector2 .DOWN ∗ FLOOR DETECT DISTANCE
var i s o n p l a t f o r m = p l a t f o r m d e t e c t o r . i s c o l l i d i n g ( )
v e l o c i t y = move and slide with snap (
velocity ,
snap vector ,
FLOOR NORMAL,
not i s o n p l a t f o r m ,
4,
0.9 ,
false
)
i f d i r e c t i o n . x != 0 :
if direction . x > 0:
sprite . scale .x = 1
else :
s p r i t e . s c a l e . x = −1
var i s s h o o t i n g = f a l s e
i f Input . i s a c t i o n j u s t p r e s s e d (
” shoot ” + a c t i o n s u f f i x
):
i s s h o o t i n g = gun . s h o o t ( s p r i t e . s c a l e . x )
var animation = g e t n e w a n i m a t i o n ( i s s h o o t i n g )
i f animation != a n i m a t i o n p l a y e r . c u r r e n t a n i m a t i o n
and s h o o t t i m e r . i s s t o p p e d ( ) :
if is shooting :
shoot timer . start ()
a n i m a t i o n p l a y e r . p l a y ( animation )

func g e t d i r e c t i o n ( ) :
return Vector2 (
Input . g e t a c t i o n s t r e n g t h (
” move right ” + a c t i o n s u f f i x
)
− Input . g e t a c t i o n s t r e n g t h (
” move left ” + a c t i o n s u f f i x
),

17
−1 i f i s o n f l o o r ( )
and Input . i s a c t i o n j u s t p r e s s e d (
”jump” + a c t i o n s u f f i x
)
else 0
)

func c a l c u l a t e m o v e v e l o c i t y (
linear velocity ,
direction ,
speed ,
is jump interrupted
):
var v e l o c i t y = l i n e a r v e l o c i t y
v e l o c i t y . x = speed . x ∗ d i r e c t i o n . x
i f d i r e c t i o n . y != 0 . 0 :
v e l o c i t y . y = speed . y ∗ d i r e c t i o n . y
if is jump interrupted :
v e l o c i t y . y ∗= 0 . 6
return v e l o c i t y

func get new animation ( i s s h o o t i n g = f a l s e ) :


var animation new = ””
if is on floor ():
i f abs ( v e l o c i t y . x ) > 0 . 1 :
animation new = ” run ”
else :
animation new = ” i d l e ”
else :
if velocity . y > 0:
animation new = ” f a l l i n g ”
else :
animation new = ” jumping ”
if is shooting :
animation new += ” weapon ”
return animation new

18

You might also like