2d Platformer
2d Platformer
Submitted by
Vaishnav V
Affiliated to
CERTIFICATE
Place:
Date:
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
Vaishnav V
Contents
List of Figures iv
List of Tables v
1 INTRODUCTION 1
1.1 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
3 TESTING 8
4 RESULTS 9
5 CONCLUSION 11
Appendices 13
iii
List of Figures
iv
List of Tables
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
2.1 Design
• 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.
2
Figure 2.1: Use-case Symbols
The use-case diagram for this project is given below in Figure 3.3:
3
In the above use-case diagram, there is only one user : Player .
The player has the following process
• 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.
• Do not become bogged down with details. Defer error conditions and error
handling until the end of the analysis
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.
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
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:
8
Chapter 4
RESULTS
9
Figure 4.3: Pause Menu
10
Chapter 5
CONCLUSION
11
Bibliography
12
Appendices
13
Appendix A
extends Control
14
Appendix B
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 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 ( )
15
Appendix C
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 = ””
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 ( )
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
18