0% found this document useful (0 votes)
80 views63 pages

Unit - 4

The document discusses steps for 2D and 3D game development using Flash, DirectX, Java, Python and common game engines. It provides details on starting the development process, creating basic games, and learning advanced techniques for each technology. These include setting up projects, adding graphics, sound, physics and optimizing performance.

Uploaded by

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

Unit - 4

The document discusses steps for 2D and 3D game development using Flash, DirectX, Java, Python and common game engines. It provides details on starting the development process, creating basic games, and learning advanced techniques for each technology. These include setting up projects, adding graphics, sound, physics and optimizing performance.

Uploaded by

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

UNIT - 4

Syllabus:

 2D And 3D Game Development Using Flash,


 DirectX,
 Java,
 Python,
 Game Engines – DX Studio, Unity
2D And 3D Game Development Using
Flash
Introduction:

Flash is a popular format for browser-based video games seen on sites


such as Newgrounds and Kongregate. While the Flash format is slowly
becoming less-utilized in the face of growing mobile apps, many quality
games are still being made with it. Flash uses ActionScript, an easy-to-
learn language that gives you control over the objects on your screen.
Steps involved in creating Game are:
1.Starting the Process
2.Writing a Basic Game
3. Learning Advanced Techniques
1.Starting the Process:
1.Design your game: Before you start coding, it will help to have a rough idea
of what you want your game to do. Flash is best suited for simple games, so
focus on creating a game that has only a few mechanics for the player to worry
about. Try to have a basic genre and some mechanics in mind before you start
prototyping. Common Flash Games are Endless Runner, Brawlers, Puzzles,
RPGs.

2.Learn what Flash excels at: Flash is best-suited for 2D games. It is possible to
create 3D games in Flash, but it is very advanced and requires significant
knowledge of the language. Almost every successful Flash game has been 2D.
3.Familiarize yourself with the ActionScript3 (AS3) language: Flash games
are programmed in AS3, and you will need to have some basic
understanding of how it works in order to successfully create a game. You
can create a simple game with a rudimentary understanding of AS3.

4.Download Flash Professional: This program costs money, but is the best
way to create Flash programs quickly. There are other options available,
including open-source options, but they often lack compatibility or take
longer to accomplish the same tasks.
2.Writing a Basic Game:

1.Understand the basic building blocks of AS3 code: When you are creating a
basic game, there are several different code structures that you will be using.
There are three main parts of any AS3 code:
• Variables - This is how your data is stored. Data can be numbers, words
(strings), objects, and more. Variables are defined by the code var and must
be one word.
Eg: var playerHealth:Number = 100;
• Event Handlers - Event handlers look for specific things to occur, and then
tells the rest of the program. This is essential for player input and repeating
code. Event handlers typically call upon functions.
Eg: addEventListener(MouseEvent.CLICK, swingSword);
• Function - Sections of code assigned to a keyword that can be called
upon later. Functions handle the bulk of your game's programming, and
complex games can have hundreds of functions while simpler games may
only have a few.
Eg: function swingSword (e:MouseEvent):void; { //Your code goes
here }

2.Create an object: ActionScript is used to affect objects in Flash. In order to


make a game, you will need to create objects that the player will interact
with. Depending on the guides you are reading, objects may be referred to
as sprites, actors, or movie clips.
3.Assign properties to the object: With your newly-created rectangle
selected, open the Modify menu and select "Convert to Symbol". In the
"Convert to Symbol" window, give the object an easily recognizable
name, such as "enemy“.

4.Learn how you can change the properties of an instance: Once you have
an instance made, you can adjust the properties through AS3. This can let
you move the object around the screen, resize it, and so on. You can
adjust properties by typing the instance, followed by a period ".",
followed by the property, followed by the value.

5.Examine the trace() command: This command will return the current
values for specific objects, and is useful for determining if everything is
running as it should. You may not want to include the Trace command in
your final code, but it is useful for debugging.
6.Build a basic game using the above information: Now that you have a
basic understanding of the core functions, you can create a game where
the enemy changes size every time you click on it, until it runs out of
health.

7.Try it out: Once you've created the code, you can test your new game.
Click the Control menu and select Test Movie. Your game will begin,
and you can click the enemy object to change its size. Your Trace
outputs will be displayed in the Output window.
3. Learning Advanced Techniques:

1.Learn how packages work: ActionScript is based off Java, and uses a very
similar package system. Packages allow you to store variables, constants,
functions, and other information in separate files, and then import these files
into your program.

2.Build your project folders: If you're creating a game with multiple images
and sound clips, you'll want to create a folder structure for your game. This
will allow you to easily store your different elements, as well as store
different packages to call on.
3.Add sound to your game: A game without sound or music will quickly become
boring to the player. You can add sound to objects to Flash using the Layers tool.

4.Create a Constants file: If your game has a lot of values that will remain the same
throughout the game, you can create a Constants file to store all of them in one
place so that you can easily call on them. Constants can include values such as
gravity, player speed, and any other value that you may need to call on repeatedly.

5. Look at other people's games: While many developers won't reveal the code for
their games, there are a variety of project tutorials and other open projects that will
allow you to see the code and how it interacts with game objects. This is a great
way to learn some advanced techniques that can help your game stand out.
2D And 3D Game Development Using
DirectX
Introduction:
DirectX is a collection of APIs that are used for creating games on the Windows
platform. It provides low-level access to hardware, making it ideal for creating high-
performance games. The tools and frameworks for creating games with DirectX:
1. DirectX Tool Kit: The DirectX Tool Kit is a collection of helper classes and functions
for creating games with DirectX.
2. XNA Game Studio: It is a set of tools for creating games for Windows and Xbox 360
using C# and DirectX.
3. Unity: It is a popular game engine that provides built-in support for DirectX graphics.
4. Unreal Engine: It is another popular game engine that provides support for DirectX
graphics.
5. DirectX 11: It is the latest version of DirectX, and it provides support for advanced
graphics features.
Steps involved in Game Development:
1.Familiarize yourself with DirectX APIs: DirectX provides a wide range of
APIs for creating games, including Direct3D for 3D graphics, Direct2D for
2D graphics, DirectSound for audio, and DirectInput for input handling.
Familiarize yourself with these APIs to understand how to use them to create
your game.

2.Choose a game engine: While it is possible to create a game using DirectX


APIs directly, it can be a complex and time-consuming process. Consider
using a game engine built on top of DirectX, such as Unity or Unreal
Engine, to simplify the development process and provide built-in support for
graphics, audio, and input.
3.Use a shader language: DirectX provides support for shader languages such as
HLSL (High-Level Shading Language) for creating complex visual effects in your
game. Learn how to use these shader languages to create advanced graphics
effects in your game.

4.Optimize for performance: DirectX provides low-level access to hardware,


which means that it is important to optimize your game for performance to ensure
smooth gameplay. This can involve techniques such as reducing the number of
draw calls, minimizing texture memory usage, and optimizing your game loop.

5.Test on multiple hardware configurations: DirectX can behave differently on


different hardware configurations, so it is important to test your game on multiple
systems to ensure that it runs smoothly on a wide range of hardware.
2D And 3D Game Development Using
Java
Introduction:

Java is a popular programming language for game development, and it


can be used for both 2D and 3D game development. Here are some
popular tools and frameworks for creating games with Java:
1. Lightweight Java Game Library (LWJGL)
2. jMonkeyEngine
3. libGDX
4. JavaFX
5. Slick2D
Steps involved in Game Development:

The steps involved in Game Development using Java:


1.Desktop Launcher
2. Screens
3. The Menu Screen & Scene2D
4. Creating the Game
5. Adding a camera
6. Adding physics
7. GameLogic
1.Desktop Launcher:

Launching the game is


done through the Desktop
Launcher. Set the height of
the screen to required
number of pixels to get it
fullscreen, and start the
game fullscreen.
2. Screens:
The generated class BadConnection extends ApplicationAdapter. To support
screens, it needs to extend from Game. In LibGDX a Game supports screens and
will defer rendering to the current screen. I’ve added a menu screen and a game
screen. When the game is created it should immediately enter the menu screen.

The game will be using system resources not controlled by the JVM. An example
of this is a texture currently rendered to the screen. This texture will be loaded into
the memory of the graphics card. To correctly release these resources you can’t put
your trust in the Java garbage collector. Before the game exits it will call the
dispose method. This call must be propagated to all assets that implement the
Disposable interface.
3. The Menu Screen & Scene2D:
Scene2D is one of the supporting libraries in LibGDX. Scene2D operates on a
Stage which binds to the default viewport of the game. The Stage is a container
holding all objects currently in the scene. The UI elements of Scene2D need a
Skin to render the components.
The skin can be found in the assets directory and contains images and json files
describing how to render UI elements. Scene2D offers an HTML-like approach to
create and layout a UI. I used a table the size of the screen and added two buttons,
one to start the game, and one to exit it. I assigned the stage as InputProcessor to
GDX, so the UI receives all input events. In the render method use two OpenGL
methods to clear the screen to a certain color before drawing the stage. In the
dispose method, dispose of all disposables is created.
4. Creating the Game:
The Game World is the root of the game itself. It will contain all the objects and
systems in the Game. I’ve created an abstract Game Object class to hold some
shared functionality and utility for the objects. The Game Object has an abstract
update- and render method making the implementation responsible for what
happens during these steps.

The Game World manages the complete game state. I added just the player, but
the number of Game Objects will increase. I also added a Sprite Batch. A sprite
batch can be used to draw images to the screen. Only one Sprite Batch can be
active at any given moment, because the Sprite Batch loads the textures it draws
to the graphics card.
5. Adding a camera:

The game is rendering the texture directly on the pane which is our screen. To
navigate the world let’s add a Camera. When given to the Sprite Batch, the
sprite batch can render textures as if it were looking through the camera. It
does this by transforming positions using a set of matrices in the camera.

Generally speaking, there are two types of cameras. An Orthographic Camera


and a Perspective Camera. I’ll be using an Orthographic Camera, which does
not account for distance. When using a Perspective Camera (mostly used in 3D
games) objects further from the camera will be rendered smaller. The camera
needs a size for the viewport.
6. Adding physics:
The physics engine creates a World parallel to the world you see on the screen.
The physics world deals with bodies with certain attributes and polygons
defining their shape. The physics world is instantiated with the gravity vector.
For example, let’s use earth’s gravity. In the update method, add a call to update
the physics world. Don’t forget the physics world needs to be disposed. And add
the physics world as a constructor parameter to the player.

Because every Game Object in the scene will create a body for itself and add it to
the world, the Player will pass the World to its super constructor. For debug
purposes use a Box2DDebugRenderer. This object can render the polygons
describing the physics bodies. The physics world calculates everything in "units".
The maximum number of units anything can move in the physics world is 2.
7. GameLogic:
Game logic refers to the set of rules and behaviors that govern how a game
works. In Java, game logic can be implemented using object-oriented
programming concepts. Steps for implementing game logic in Java:
1. Define classes for game objects
2. Use a game loop
3. Implement collision detection
4. Use event-driven programming
5. Use game development frameworks such as LWJGL and jMonkeyEngine
2D And 3D Game Development Using
Python
Introduction:
Python is a popular programming language for game development due to its
simplicity, ease of use, and powerful libraries. Steps for developing 2D and 3D
games using Python:

1.Choose a game engine: By using a game engine built on Python, such as


Pygame or PyOpenGL, to simplify the development process and provide built-
in support for graphics, audio, and input.

2.Use a graphics library: Pygame and PyOpenGL both provide support for
graphics in Python. Pygame is specifically designed for 2D game development,
while PyOpenGL provides support for 3D graphics.
3.Use a physics engine: Use a physics engine such as PyBullet or PyODE. These
libraries provide support for physics simulations in Python, allowing you to
create realistic physics-based gameplay.

4.Use a sound library: Pygame provides built-in support for audio in Python,
making it a popular choice for game development. Other sound libraries, such as
PyAudio or PyOgg, provide additional functionality and support for different
audio formats.

5.Optimize for performance: Optimizing for performance in game development


involves techniques such as minimizing function calls, reducing object creation,
and using built-in Python functions for faster execution.
Steps involved in Game Development using
Python:
1.Plan and Design: Determine the game concept, gameplay mechanics,
storyline, graphics, sound effects, and user interface. You can create a
storyboard, flowchart, or wireframe to visualize the game.

2.Choose a Game Engine or Library: Choose a game engine or library that


fits your requirements and skills. Some popular game engines and libraries
for Python are Pygame, PyOpenGL, Panda3D, and PyOgre.
3.Setup and Configuration: Install and configure the necessary software
tools and dependencies, such as Python, the game engine or library, a text
editor or IDE, and any external modules or libraries.

4.Programming: Write code for the game logic, graphics, sound effects,
user interface, input handling, and game physics. Use object-oriented
programming (OOP) techniques to organize the code and make it reusable
and modular.
5.Testing and Debugging: Test the game for bugs, errors, glitches, and performance
issues. Use debugging tools and techniques to identify and fix any problems in the code.

6.Optimization and Refactoring: Optimize the game for better performance, stability,
and user experience. Refactor the code to improve readability, maintainability, and
scalability.

7.Publishing and Distribution: Publish the game on game distribution platforms, such as
Steam, Itch.io, or Google Play Store, or distribute it through your own website or social
media channels. Create marketing materials, such as screenshots, trailers, and gameplay
videos, to promote the game.
Game Engines:
The different Game Engines can be used for Game Development using Python:

1.Crystal Space: It is a free cross-platform software development kit for real-time


3D graphics, with particular focus on games.

2. Blender: It is an impressive 3D tool with a fully integrated 3D graphics creation


suite allowing modeling, animation, rendering, post-production, real-time
interactive 3D and game creation and playback with cross-platform compatibility.

3. Pygame: It is a cross platform Python library which wraps SDL. It provides many
features like Sprite groups and sound/image loading and easy changing of an objects
position.
4. Panda3D: It is a 3D game engine. It's a library written in C++ with Python
bindings. Panda3D is designed in order to support a short learning curve and rapid
development.

5. Pyglet: It is a cross-platform windowing and multimedia library for Python with


no external dependencies or installation requirements. Pyglet provides an object-
oriented programming interface.

6. Rabbyt: A fast Sprite library for Python with game development in mind. With
Rabbyt Anims, even old graphics cards can produce very fast animations.

7. Kivy: Kivy is a library for developing multi-touch applications. It is completely


cross-platform. It comes with native support for many multi-touch input devices.
The Reasons for Python being ideal choice for game development:
1.Clean Syntax
2. Flexible Object Orientation
3. Gaming-based Libraries and Frameworks
4. Dynamic Typing
5. Massive Community Support
6. Compatible with AI Integration
7. Robust Performance
8. Inherently Scalable
2D And 3D Game Development Using
Game Engines
Introduction:
Game engines are powerful software frameworks designed for developing
games quickly and efficiently. They provide developers with a variety of
tools and features to create games in both 2D and 3D environments. The
most popular game engines for both types of game development:

 2D Game Engines: In 2D game development, game engines provide tools


for creating 2D graphics, designing levels, implementing game
mechanics, and handling user input. Developers can use visual scripting
languages or traditional programming languages to create 2D games.
1.Unity: Unity is one of the most popular game engines for developing 2D
games. It has a simple interface and supports a wide range of platforms,
including Windows, macOS, Android, and iOS.

2.Construct 3: Construct 3 is a web-based game engine that allows


developers to create 2D games using a visual programming language. It
supports exporting games to various platforms, including HTML5, Windows,
macOS, and Linux.

3.GameMaker Studio 2: GameMaker Studio 2 is a popular game engine for


creating 2D games. It has a drag-and-drop interface and supports exporting
games to multiple platforms, including Windows, macOS, Android, and iOS.
 3D Game Engines: In 3D game development, game engines provide
tools for creating 3D models, designing levels, implementing physics,
and handling user input. Developers can use visual scripting languages
or traditional programming languages to create 3D games.

1. Unity: Unity is also a popular game engine for developing 3D games. It


has powerful tools and features for creating 3D environments, including
physics simulations, lighting, and animation.
2.Unreal Engine 4: Unreal Engine 4 is a powerful game engine for creating 3D
games. It has advanced tools and features, including a robust physics engine,
advanced lighting, and cinematic tools.

3.CryEngine: CryEngine is a game engine designed for creating high-quality


3D games. It has powerful tools and features for creating realistic
environments, including dynamic weather, advanced lighting, and terrain
creation.

4. DX Studio: DX Studio is a game engine that allows developers to create 3D


games and interactive applications. It provides a range of tools and features for
creating games, including a visual scripting system, physics engine, animation
tools, and support for multiple platforms.
Game Development using Unity:
The Steps involved in game development using Unity:
1.Scripting: All games need scripts. Scripts respond to input from the player
and arrange for events in the gameplay to happen when they should. Scripts
are attached to Game Objects, and any script you create inherits from the
MonoBehaviour class.

2.Sprites: Sprites are 2D graphic objects. You use Sprites for all types of
games. For example, you can import an image of your main character as a
Sprite. You can also use a collection of Sprites to build a character. This
allows you greater control over the movement and animation of your
characters.
3.Building in-game environments: Environment design refers to the
process of building your game’s levels and environments. You can
combine the environment design tools in this section in whichever way
makes the most sense for your game; for example, you can make a top-
down game using only 9-slice, or you can make a side on platformer with
Tilemap and SpriteShape.

4.Character animation: There are three ways to animate the characters


are;
a. Frame-by-frame: Artistic reasons, if you want your game to have a
classic animation art style. Frame-by-frame animation is relatively
resource-intensive, both to make and to run.
b. Cutout: Smooth skeletal animation, when the characters don’t require
realistic articulation.

c. Skeletal: Smooth skeletal animation where Sprites bend according to the


bone structure. Use this when the characters need a more organic feel.

5.Graphics:
a. Lighting: Because you’re using URP with the 2D Renderer, you can use the
Light 2D component to apply optimized 2D lighting to Sprites.

b. Shadows: To define the shape and properties that a Light uses to determine
the shadows it casts, use the Shadow Caster 2D component. Increase the
Light’s Shadow Intensity above zero.
c. Enhanced look and feel: Particle systems and post-processing are
optional tools that you can use to add polish to your game.

i. Particle systems: You can use particle systems to create dynamic


objects like fire, smoke or liquids, as an alternative to using a Sprite.
Sprites are more suited to physical objects.

ii. Post-processing You can use post-processing effects and full-screen


effects to significantly improve the appearance of your game. For
example, you can use these effects to simulate physical camera or film
properties, or to create stylized visuals.
6. Physics 2D: The Physics 2D settings define limits on the accuracy of
the physical simulation in your 2D game.The following 2D physics tools
are useful for 2D games are: a. Rigidbody, b. 2D Collider, c. 2D Triggers,
d. 2D Joints, e. 2D Effectors.

7. Audio: You can add background music and sound effects to your game
in Unity; see Audio Overview. Use third-party software to create your
audio and import it into Unity with the recommended settings.

8. User interface: If you want to add a menu or help to your game, you
need to set up a user interface. To set up a user interface, use Unity UI.
9. Profiling, optimizing and testing a build:
a. Profiling: Profiling allows you to see how resource intensive the
different parts of your game are. You should always profile your game on its
target release platform.

b. Optimizing After profiling, you can use the results to make


performance improvements and optimizations.

c. Testing: Test your game and your code with the Unity Test
Framework.

10. Publishing: When you’ve finished your game, you’re ready to publish it.
References:
1. https://www.wikihow.com/Make-a-Flash-Game
2. https://blog.jdriven.com/2020/10/gamedevelopment-in-java/
3. https://www.pangea.ai/resources/java-game-development/#resource-article-3
4. https://wiki.python.org/moin/GameProgramming
5. https://opensource.com/article/18/4/easy-2d-game-creation-python-and-arcade
6. https://enlear.academy/python-for-game-development-why-is-it-a-good-choice-a4845
832cfc2
7. https://www.studytonight.com/3d-game-engineering-with-unity/introduction
8. https://docs.unity3d.com/Manual/Quickstart2DCreate.html
T h a n k Yo u

You might also like