0% found this document useful (0 votes)
155 views56 pages

CCS347 - Game Development Lab Manual - Page

The document outlines the installation procedures for Unity and Unreal Engine, including steps for familiarizing with Unity's GUI and conceptualizing a 2D game theme. It also details character design, sprite creation, movement mechanics, and control implementation for game development. The result confirms successful execution of the installation and design processes using various software tools.

Uploaded by

jerry
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)
155 views56 pages

CCS347 - Game Development Lab Manual - Page

The document outlines the installation procedures for Unity and Unreal Engine, including steps for familiarizing with Unity's GUI and conceptualizing a 2D game theme. It also details character design, sprite creation, movement mechanics, and control implementation for game development. The result confirms successful execution of the installation and design processes using various software tools.

Uploaded by

jerry
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/ 56

Page |1

Ex. No : 1 Installation of a Game Engines Unity and Unreal Engine.


Date: Familiarization of the GUI in Unity.
Conceptualize the theme for a 2D game.

Aim:
To install the game engines, Unity and Unreal Engine. Also to familiarize the GUI in Unity
and Conceptualize the theme for a 2D game.

1. Installation of Unity
Procedure:
Step1:Download Unity Hub website(https://unity.com/)or(www.unityhub.com)
• Unity Hub is a management tool that allows you to install and manage different versions of
Unity, as well as access tutorials, projects, and assets.
• Go to the Unity website and download Unity Hub from the "Downloads" page.

Step2: Install Unity Hub


• Open Unity Hub after installation.
• Go to the "Installs" tab.
• Click on the "Add" button to add a new Unity version.
• Select the version of Unity you want to install from the list of available versions.
• Click "Next" and follow the prompts to complete the installation process.
Page |2

Step3: Create or Sign in to Unity ID:


• If you haven't already, create a Unity ID by clicking on "Sign in" or" Create one" in the Unity
Hub.
• A UnityID is required to download and activate Unity licenses.

Step4: Activate Unity License(Optional):


• Unity offers both free and paid licenses. Depending on your needs, you may choose the
appropriate license.
Page |3

Step5 Start Using Unity:


• Once Unity is installed and activated, you can start using it to create games and other
interactive experiences.

Step6.Explore Resources and Documentation:


• Unity offers a wealth of resources, tutorials, and documentation to help you get started
with game development.
• You can access tutorials and resources directly from Unity Hub or from the Unity website.
Page |4

2. Installation of Unreal Engine


Procedure:
Step1:Install Unreal Engine
1. Access the website at https://www.unrealengine.com.
2. Register and download the Epic Games Launcher.
3. Install and start the launcher.
4. Click the Unreal Engine tab on the left-hand side.
5. Click on the Library tab that appears at the top of the screen.
6. Click the +button next to ENGINE VERSIONS to add a version of Unreal Engine to the
launcher. You can use the newest version available.
7. Click the Install button. The launcher will start downloading the files needed for
installation and may take a long time to complete.
8. Click the Launch button to start an already installed version. It is possible to have multiple
versions of Unreal Engine installed on the same machine – you simply set one of them as
the current version. The Launch button at the top right of the launcher will start the
current version.

Step2:Creating new projects and using templates:


`After starting up Unreal Engine Editor, the Unreal Project Browser will appear. The
Recent Projects box on the top left is used to open existing projects and the other boxes on the
left are categories of templates used to create a new project. The following screenshot shows the
templates of the Games category.
Page |5

Select the Third Person template, choose a location folder, and fill in the Name field for the
project. Select the Project Defaults mentioned in the previous list and then click the Create
button. After the projectloads, the Unreal Engine Level Editor wil be displayed, as shown in the
following screenshot:

Step3:The Unreal Engine Level Editor


The seare the key panels of the Level Editor:
1. Toolbar
2. Viewport
3. Content Browser
4. Outliner
5. Details.
Step4:Blueprints Visual Scripting
The Toolbar Panel

TheToolbar panel is located at the top of the Blue print Class Editor and contains some essential
buttons for editing Blue prints:

The buttons are described as follows:


The Components panel
The Components panel shows all the Components that are part of the current Blueprint.

3. Familiarization of Unity GUI


Procedure:
Step1:Scene View:
• The Scene View is where you design and build your game world.
Step2: Toolbar:
• The Toolbar provides quick access to common actions and tools.
Step3:Unity Editor Layout
Page |6

Step4:Navigation and Manipulation

Step5:Asset Management

Step6:Scripting and Components


Page |7

4. Conceptualize the Theme for a 2DGame

Procedure:
Step1:Define the Theme and Story

Step2.Theme:This 2D game combines the charm of a whimsical bakery with the underwater world.

Step3:Story(Optional):You are a friendly seahorse who has opened a unique bakery on the ocean
floor.

Step4:Game play:
• Players collecting redients by completing mini-games or tasks.

Step5:Art Style

Step6:Target Audience
• This game is perfect for casual gamers and families who enjoy relaxing and creative
experiences.
Step7.Create Art Style and Assets
Step8.Iterate and Refine

Result:
Thus the installation of a game engine, Unity, Unreal Engine, familiarization of the GUI was
verified and installed successfully.
Page |8

Ex.No:2a) Character Design


Date:

Aim:
To conceptualize and finalize a character design for a game.

Algorithm:

Step:1 Brain storm character concepts considering the game's theme, setting, and requirements.
Step:2 Sketch multiple rough designs exploring different characteristics and visual styles.
Step:3 Select one concept and refine it based on feedback and artistic vision.
Create detailed art work for the finalized character design, including ront,side, and backviews.
Programs for game character design:3D modeling
• Autodesk Maya.
• 3DSMax.
• Zbrush.
• Blender.
• Make human.
• Unity.
• Game Maker Studio.
• Unreal Engine

Autodesk Maya:
• Developed for interactive 3D rendering in video games, animated features, television, and
movies, Maya has been used in multiple successful projects, from Game of Thrones and
Spider-Manto Halo and numerous Pixar movies.
Zbrush:
• One of the great alternatives to Autodesk software, it is also widely used for modeling,
texturing, and painting high-resolution 3D video game character models
Blender:
• Just like the previous tools, this software isused for modeling, designing, and animating 3D
characters.
Make human:
• Just like Blender, Make Human is an open source 3D graphics tool that can help you
create realistic human beings.
Unity:
• Unity is a game design engine that you can access for free. It presents different ways to
customize game character design and settings, building from predefined elements.
Game Maker Studio:
• Game Maker Studio is a game development tool with its own programming system.
Unreal Engine:
• Finally, let’s talk about Unreal Engine. This is a development engine that, for its next
version, will present a fully customizable character creator.
Page |9

Output:

Result:
Thus the character design using blender verified and executed successfully.
P a g e | 10

Ex.No:2b) Character Sprites


Date:

Aim:
To create sprite animations for the designed character.
Algorithm:
Step1:Break down the finalized character design into individual sprite frames for various
actions(e.g.,walking, jumping, attacking).
Step2:Use graphics software to create sprite sheets, ensuring consistency and clarity in sprite
design.
Step3:Animate the sprite frames to create smooth transitions between different actions.
Create Character Sprites:
Step1–Create a new project in Scratch. To get started, create a new project in Scratch....
Step1:Goto MIT Scratch.

Step2:Click on Create.

Step3:Choose a Backdrop.
How to use a backdrop in Scratch?
To use a back drop in Scratch, you must follow the following steps:
• Step1:Open Scratch and click on the “Choose a Backdrop” option which is in blue color in
the shape of a circle available at the extreme bottom left corner of the Scratch user
interface.
• Step2:Once you click on the blue button, the following options will appear on the screen.
You can choose, paint, surprise, and upload a backdrop using these options.
P a g e | 11

• Step3:To choose a particular backdrop, click on the first option that says, “Choose a
Backdrop”.

• Step4:To paint a backdrop, click on the second option that says, “Paint”.
• Step5:To upload a particular backdrop, click on the last option that says,“Upload
Backdrop”.

How to edit the backdrop in Scratch?


To edit a backdrop in Scratch, the user must follow the following steps:
• Step1:Click on the “Costumes” option available in the navigation bar at the top of the
screen.
• Step2:Once the user clicks on the “Costume” option, the following screen will appear.

• Step3:Click on the “Backdrops” box available at the extreme right of the screen under the
Stage.
P a g e | 12

• Step4:Now the user can easily edit the back drop using the available tools present on the
leftside of the editing screen.
Step4:Choose a Sprite.

Step5:Write the script for the project.

Step6:Run.
Step7:Conclusion.

Step2–Select the “Paint” option to create a sprite....


P a g e | 13

Step3–Draw a sprite using the brush and shapes tools....


1. Select the tool and the fill color

2. Click on the canvas and drag your mouse to draw.

3. Create an outline of the sprite.

Step4–Fill in the sprite colors using the fill tool....


1. Click on the fill tool

2. Select the fill color

3. Click on the object to fill in.

Step5–Export the sprite.


1. Right-click on the sprite in the sprite menu

Click export.
P a g e | 14

If we want to save it as a .pngfile. Click on “Convert to Bitmap” then export.

OUTPUT:

Result:
Thus the Character sprites using blender verified and executed successfully.
P a g e | 15

Ex. No: 2 c) Character Movement


Date:

Aim:
To implement basic movement mechanics for the character.
Algorithm:
Step1:To implement basic movement mechanics for the character.
Step2:Implement logic to handle player input(e.g.,arrow keys for movement).
Step3:Update the character's position based on input, considering collision detection with obstacles.
Step4:Apply gravity or other physics principles to simulate realistic movement.
Creating Character Mavement:
• Inside your Player Character_AB Animation Blueprint, navigate to the AnimGraph.

• The Anim Graph is used to evaluate a final pose for the skeletal mesh.
• Right-click on the AnimGraph and from the Actions drop down menu, search for and
select Add New State Machine.

• Rename your State Machine node to Locomotion, then double-click the node to open its
graph. Drag off from the Entry pin, and from the Actions drop down menu, select Add
State.
P a g e | 16

• Name the new state Movement,t hen double-click to open the Movement State Node.
Navigate to the Asset browser, and search for Locomotion_BS, then click and drag it in to
the graph.

• From the My Blue print tab, click and drag your Speed float variable into the Blend
Space's Speed vertical axis.

• Navigate back to the My Blue print tab, then click and drag your Direction float variable
into the Blend Space's Direction horizontal axis.
P a g e | 17

• Connect the Animation Pose output pin to the Animation Pose Result pin of the Output
Animation Pose node.

• Compile and Save.

• Navigate back to the Locomotion state machine, then click and drag the Movement state
node to create a new Animation state named Crouch Movement.

• Double click the Transition rule node to open its Anim Graph.
P a g e | 18

• From the My Blueprint Tab, navigate to the variables category and drag your Is
Crouched boolean onto the Can Enter Transition input pin from the Result node.

• From the My Blueprint Tab, navigate to the variables category and drag your Speed and
Direction float variables into their respective pins on the Locomotion Crouch_BS, then
connect your Locomotion Crouch_BS AnimationPose into your Output
Animation Pose Result pin

• Compile and Save your Animation Blue print.


P a g e | 19

• Navigate back to the Locomotion Anim Graph then click and drag off the Crouch
Movement Animation state and connect it to the Movement Animation State.

• Double click the Transition rule node to open it's AnimGraph.

• From the My Blue prints tab, click and drag the Is Crouched Boolean variable onto the
Anim Graph, select Get Is Crouched, then drag off from its output pin and in the drop
down actions menu search for and select NOT Boolean.

• Next, connect the NOT Boolean's return pin to the Can Enter Transition input pin.

• Compile and Save.


P a g e | 20

• Navigate back to the Anim Graph, then click and drag off from the Movement Animation
state and select Add State.

• Rename this Animation State to Jump,then double-click to open its animation graph.
Navigate to the Asset Browser and search for Jump_From_Jog, then drag it into the graph.

• Finish your Jump Animation State by connecting your Play Jump_From_Jog Animation
Pose to your Output Animation Pose Result pin.

• Navigate back to the Locomotion Anim Graph, then double-click the Movement to Jump
Transition rule node to open its Anim Graph.
P a g e | 21

• Inside the Transition Rule Anim Graph, navigate to the My Blueprint stab, and drag
your IsJumping Boolean variable on to the Result node's Can Enter Transition input
pin.

• Navigate back to the Locomotion Anim Graph, then click and drag off the Jump anim
node and create a transition to the Movement Anim Graph node.

• Double-click the Jump to Movement Transition rule node to open it's Anim Graph.

• From the My Blue prints tab, click and drag the Is Crouched, and Is Jumping Boolean
variable on to the Anim Graph, then drag off each of their output pins and from the drop
down actions menu search for and select NOT Boolean.
P a g e | 22

• Drag off the NOT Boolean output pin and search for and select for the AND Boolean.

• Connect both the Is Crouched, and Is Jumping NOT Boolean node output pins into the
AND Boolean node's input pins, then connect the AND boolean's output pin into the
Result node's Can Enter Transition Input pin.

• Navigate back to the Locomotion Anim Graph, then click and drag off the Crouch node
and create a transition to the Jumpnode.

• Inside the Crouch Movement to Jump transition rule Anim Graph, navigate to the My
Blue print tab, then click and drag your Is Jumping bool variable on to the Result node's
Can Enter Transition input pin.
P a g e | 23

• Navigate back to theLocomotion Anim Graph, then drag off from the Jump
node to create a transition to the Crouch Movement node.

• Double- click the Jump to Crouch Movement Transition rule node to open it's Anim
Graph.
• From the My Blueprints tab, click and drag the Is Crouched and Is Jumping Boolean
variables onto the AnimGraph.

• Your completed Locomotion Anim Graph will resemble the image below.
P a g e | 24

• Navigate to the AnimGraph and connect the Locomotion Pose Output pin into
the Output Pose Result pin.

• Compile and Save.

OUTPUT:

Result:
Thus the character movement using blender verified and executed successfully.
P a g e | 25

Ex.No:2d) Character Control


Date:

Aim:
To design and implement controls for the player to interact with the character.
Algorithm:
Step1: Map player inputs(e.g., keyboard keys, controller buttons)to character actions(e.g., moving,
jumping, attacking).
Step2:Provide options for customizing controls to accommodate player preferences.
Step3:Implement special abilities or skills for the character, along with corresponding control
schemes.
1. Concepting. 5. UV unwrapping.
2. Blocking. 6. Baking.
3. Sculpting. 7. Texturing.
4. Retopology. 8. Rigging S Skinning.
Using Blueprint to Control the Character:
STEP1:
1. In the Content Browser expand the Sources panel and create a folder called Movies.Then,
right-click on the new folder and select Show in Explorer.
In Explorer.

2. Drag the Sample Video (or your supported video) into theContent>Moviesfolder of your
project on your computer.
3. Inside your project, create a Media Player and associated Media Textureasset
called MediaPlayer and MediaPlayer_Video respectively.
P a g e | 26

4. Create a File Media Source as set called Video and inside it, point the File Path to the
video added in Step 2.

5. Open your Media Player as set and disable the Play on Open option.

6. In the Place Actors panel under Shapes, drag a Plane into the level and resize as desired
(Place Actors can be found under the Window tab if it's not already enabled).
P a g e | 27

7. Drag the MediaPlayer_Video texture onto the Plane, then in the Details pane for the
Plane, add a Media Sound Component set to use your Media Player asset.

Blue print Setup:


Next, we want to set up our initial Blueprint, so later we can add functions to it.
1. From the Main Toolbar, click the Blue prints button then select Open Level Blue print.

2. In the Level Blueprint, create a variable called Media Player(of the Media Player Object
Reference type) and set it to point to your Media Player asset.
3. Hold Ctrl and drag the Media Player variable into the graph and use Open
Source and Event Begin Play to open your Video File Media Source asset.
P a g e | 28

Play/Pause–Up:
Add an Up keyboard event connected to a Flip Flop and off your Media Player variable, use Play
and Pause as shown below.

When the Player presses the Up arrow keyboard key, the Media Source will start playing while
pressing a second time will pause the video.
1. Add Left and Right keyboard events, then off your Media Player variable use Set Rate
with the left key at -2 and the right key at 2.

2. This will enable the Player to press the left arrow keyboard key to set the Play Rate of the
video to -2(playing the video in reverse at double speed as a value of 1.0isnormal forward
playback).
3. You could add additional Blueprint logic to determine the number of times the Player
presses the rewind or fast-forward keys and increase or decrease the Play Rate from 2x to
4x or 6x speeds or higher.
P a g e | 29

Keep in mind there is a distinction between Thinned and Unthinned rates. Thinned means that
some frames will be skipped at this rate, while Unthinned means that all frames will be decoded at
this rate.
Close/Resume–Down:
1. Add aDown keyboard event connected to a Flip Flop, then off a Media Player reference,
use the Get Time function call.

2. Right-click on the ReturnValue of the GetTime node and promote it to a variable called
Stop Time, then connect all nodes to a Close function call as shown.
This will close the Media Player when pressing the down arrow keyboard key, but store the
current time in which the Media Player was stopped.

.
3. Off the Bpin of the FlipFlop use the Open Source node and set the MediaSource to your
Video Media Source.
4. Drag off the MediaPlayer reference and use the AssignOnMediaOpened Event Dispatcher
and connect as shown.
P a g e | 30

5. Off your Media Player reference, call the Seek function followed by the Play function.
6. Create a Stop Time variable and connect it to the Time pin on the Seek node. Then
connect the Seek and Play nodes to the OnMediaOpened event as shown.

7. Close the LevelBlueprint and click the Play button from the Main Toolbar to play in the
Editor.
OUTPUT:
P a g e | 31

Result:
Thus the character control using unreal engine in blender verified and executed successfully.
P a g e | 32

Ex.No:3 Level Design: Design of the world in the form of tilesa long
Date: with interactive and collectible objects

Aim:
To Level design of the world in the form of tiles along with interactive and collectible objects.
Algorithm:
Step1:Create a New Project
Step2:Understand the Unreal Engine Interface.
Step3:Modify and Add Assets
Step4:Blueprint Visual Scripting
Step5:Level Design.
Step6:Test and Iterate.
Step7:Package and Share.
The View port panel

• The View port panel shows the visual representation of a Blueprint and its
Components. The View port panel has controls similar to the Level Editor,which you
can use to manipulate the location, rotation, and scale of the Components.
P a g e | 33

You can move around the Event Graph by right-clicking and dragging it to see the other Events.
STEP1: Adding Components to a Blueprint
• Now,let's create our first Blueprint. It will be a very simple Blue print that will only contain
Components. For now, we will not use Events or Actions:
• Double-click this Blue print to open the Blue print Editor.

• On the Details panel, there is a property named Static Mesh, which has a drop-down input.
Click on the dropdown and select the Static Mesh property named SM_Chair. This Static
Mesh is part of the starter content. The following screenshot shows the selected SM_Chair:
P a g e | 34

STEP2: Create a New Level


1. Inside the Unreal Editor, click the FileMenu option then select New Level....

This will open the New Level dialog window:

2. Click the EmptyLevel to select it. Finished Step

• Placing Actors in the Level In the Place Actors panel on the left, click
the Geometry category and select the Box.

• Left-click and drag the Box into the Level View port.
P a g e | 35

• When you release the Left Mouse Button, the Box is added to the level.

• In the Detail spanel(lower-right window of the editor), with the Box still selected, set
Location and Rotation all to 0.
• Set the Scale to 4x4x0.1.

• We will use this as the floor on which the player can walk around.
• In the Place Actors panel select the Lights tab, then drag-and-drop a Directional Light
into the level on top of the floor.
P a g e | 36

• On the Translation Tool,click and drag the Z-Axis(blue) on the gizmo up, away from the
surface of the floor.

• If the Directional Light becomes unselected, you can re-select it by Left-clicking on it in


the Level View port.
• In the PlaceActors panel,select the Visual Effects tab and drag-and-drop an Atmospheric
Fog into the level.

• The AtmosphericFog Actor will add a basic sky to the level and the level will become
illuminated instead of dark.

• In the Place Actors panel, select the Volumes tab and drag-and-drop a Light mass
Importance Volume into the level.
P a g e | 37

• Inside the Level View port, press R to switch to the Scale Tool.
• Click and drag the white box in the center of the ScaleTool so that the Light mass
Importance Volume encapsulates the floor.

• Inside the Content Browser under Content>StarterContent>Props, drag-and-drop the


SM_TableRound into the level.

• Try to place the table in the center of the floor using the MoveTool
(pressWifitisnotselected).
• Also under Content>StarterContent>Props, drag-and-drop the SM_Chair in to thelevel.
P a g e | 38

• With the SM_Chair selected inside the LevelViewport, press E to access the Rotation Tool.

• Left-click and drag the blue axis arc(the gizmo will update to show degrees)and rotate the
chair to face the table.

• Using the placement methods above, create a small scene by adding more Actors from the
ModesPanel and ContentBrowser.

• Try adding some lights, props, walls and a roof (found under
the Content>StarterContent>Architecture folder
P a g e | 39

STEP3:Test and iteration:

Result:
Thus the Level design of the world in the form of tiles along with interactive and collectible
objects using unreal engine is verified and executed successfully.
P a g e | 40

Ex. No : 4 Design of interaction between the player and the World


Date:

Aim:
To design of interaction between the player and the world.
Algorithm:
1. Initialize the Game Environment
2. Create the Player
3. Define the World
4. Handle User Input
5. Update Player Position
6. Detect Collisions
7. Update Game State
8. Render the Scene
9. Repeat
10. End the Game Loop
Program:
Import pygame
From pygame.localsimport*
pygame.init()
screen=pygame.display.set_mode((800,600))
clock = pygame.time.Clock()
player_x,player_y=400,300
player_speed=5
running = True
while running:
for event in pygame.event.get():
if event.type == QUIT:
running=False
keys=pygame.key.get_pressed() if
keys[K_LEFT]:
player_x-=player_speed if
keys[K_RIGHT]:
player_x+=player_speed
if keys[K_UP]:
player_y-=player_speed
P a g e | 41

if keys[K_DOWN]:
player_y+=player_speed
player_x=max(0,min(player_x,800))
player_y=max(0,min(player_y,600))
screen.fill((0, 0, 0))
pygame.draw.circle(screen,(255,255,255),(player_x,player_y),20)
pygame.display.flip()
clock.tick(60)
pygame.quit()
Output:

Result:
Thus the design of interaction between the player and the world, optionally using the physics
engine is written verified and executed successfully.
P a g e | 42

Ex. No : 5 Developing a 2D Interactive Game using Pygame

Date:

Aim:
To develop a 2D Interactive Game using Pygame.
Algorithm:
1. Initialize Pygame
2. SetUp the Screen
3. Load Assets
4. Define Game Objects
5. Handle User Input
6. Update Game State
7. Render Graphics
8. Repeat
9. Handle Game Over Conditions
10. Display Game Over Screen
11. Clean Up
Program:
importpygame
importrandom
pygame.init()
WIDTH,HEIGHT=800,600
screen=pygame.display.set_mode((WIDTH,HEIGHT))
pygame.display.set_caption("Simple Game")
WHITE= (255,255,255)
BLACK= (0,0,0)
player_width= 50
player_height=50
player_x=WIDTH//2-player_width//2 player_y
= HEIGHT -player_height -20 player_speed = 5
obstacle_width=50
obstacle_height=50
obstacle_speed=3
obstacles = []
clock=pygame.time.Clock()
P a g e | 43

spawn_obstacle_event = pygame.USEREVENT + 1
pygame.time.set_timer(spawn_obstacle_event,1500)
running = True
whilerunning:
for event in pygame.event.get():
if event.type==pygame.QUIT:
running=False
elif event.type== spawn_obstacle_event:
obstacle_x=random.randint(0,WIDTH-obstacle_width)
obstacle_y = -obstacle_height
obstacles.append(pygame.Rect(obstacle_x, obstacle_y, obstacle_width,
obstacle_height))
keys=pygame.key.get_pressed()
if keys[pygame.K_LEFT]andplayer_x>0:
player_x -= player_speed
if keys[pygame.K_RIGHT]andplayer_x<WIDTH-player_width:
player_x += player_speed
for obstacle in obstacles:
obstacle.y+=obstacle_speed if
obstacle.y > HEIGHT:
obstacles.remove(obstacle)
player_rect=pygame.Rect(player_x,player_y,player_width,player_height) for
obstacle in obstacles:
if player_rect.colliderect(obstacle):
running = False
screen.fill(WHITE)
pygame.draw.rect(screen,BLACK,player_rect)
for obstacle in obstacles:
pygame.draw.rect(screen,BLACK,obstacle)
pygame.display.flip()
clock.tick(60)
pygame.quit()
P a g e | 44

Output:

Result:
Thus the development of 2D interactive using pygame is written verified and executed
successfully.
P a g e | 45

Ex.No: 6 Developing a Puzzle game using Pygame

Date:

Aim:
To develop a Puzzle game using pygame.
Algorithm:
1. Initialize Pygame
2. SetUp the Screen
3. Load Assets.
4. Split Image into Tiles.
5. Shuffle Tiles.
6. Draw the Puzzle
7. Handle User Input.
8. Move Tiles.
9. Check for Win Condition
10. Display Win Screen
11. Repeat
12. Clean Up
Program:
import
pygame
import random
pygame.init()
WIDTH,HEIGHT=480,480
TILE_SIZE= 120
ROWS,COLS=4,4
screen=pygame.display.set_mode((WIDTH,HEIGHT))
pygame.display.set_caption("Sliding Puzzle")
WHITE= (255,255,255)
BLACK= (0,0,0)
image= pygame.image.load("puzzle_image.jpg")
image=pygame.transform.scale(image,(WIDTH,HEIGHT))
tiles = []
for y in range(ROWS):
for x in range(COLS):
rect=pygame.Rect(x*TILE_SIZE,y*TILE_SIZE,TILE_SIZE,TILE_SIZE) tile =
image.subsurface(rect)
P a g e | 46

tiles.append(tile)
shuffled_tiles = tiles[:]
random.shuffle(shuffled_tiles)
def draw_tiles():
fori,tileinenumerate(shuffled_tiles): x
= (i % COLS) * TILE_SIZE
y =(i // ROWS)* TILE_SIZE
screen.blit(tile,(x,y))
running = True
while running:
screen.fill(WHITE)
draw_tiles()
pygame.display.flip()
for event in pygame.event.get():
if event.type==pygame.QUIT:
running=False
elif event.type==pygame.MOUSEBUTTONDOWN: if
event.button == 1:
mouse_x,mouse_y=pygame.mouse.get_pos()
clicked_tile=(mouse_x//TILE_SIZE)+(mouse_y//TILE_SIZE)*
COLS

blank_tile= shuffled_tiles.index(None)
ifclicked_tile-1==blank_tileorclicked_tile+1==blank_tileor
clicked_tile -COLS == blank_tile or clicked_tile + COLS == blank_tile:
shuffled_tiles[clicked_tile], shuffled_tiles[blank_tile] =
shuffled_tiles[blank_tile],shuffled_tiles[clicked_tile]
pygame.quit()
P a g e | 47

Output:

Result:
Thus the development of a puzzle game using pygame is written, verified and executed
successfully.
P a g e | 48

Ex. No : 7 Design of menus and user interaction in mobile platforms


Date:

Aim:
To Design of menus and user interaction in mobile platforms and user interaction in mobile
Game development
Algorithm:
Step1:Introduction to common omponents like buttons, sliders, discussing functions for user
interaction.
Step2:Teaching wireframe/prototypecreation,vital for iterating and refining UIdesigns.
Step 3: Provide game dev environment (e.g., Unity) guiding scene creation and linkage for menus.
Step4:Introduce scripting concepts,offer codes nippets for common interactions(e.g.,button clicks,
transitions).
Step5:Encourage testing on mobile devices,gathering feedback for iterative improvements.
Program:
using Unity Engine;
usingUnity Engine.UI;
public class MenuController:Mono Behaviour
{
public GameObject main MenuPanel;
public GameObject options MenuPanel;

void Start()
{
//Show the main menu panel and hide other panels

Show MainMenu();
}

Public void Show MainMenu()


{
Main MenuPanel.SetActive(true);

options MenuPanel.SetActive(false);
}
P a g e | 49

Public void Show OptionsMenu()


{
Main MenuPanel.SetActive(false);

options MenuPanel.SetActive(true);
}

Public void StartGame()


{
// Add code to start the game
Debug.Log("Starting the game...");
//For simplicity,let's load a new scene for the game
// Replace "GameScene" with the name of your game scene
UnityEngine.SceneManagement.SceneManager.LoadScene("GameScene");
}

Public void QuitGame()


{
// Add code to quit the game
Debug.Log("Quitting the game...");
Application.Quit();
}
}

Output:
P a g e | 50

Result:
Thus design of menus and user interaction in mobile platforms verified and executed
successfully.
P a g e | 51

Ex. No : 8 Developing a 3D Game using Unreal

Date:

Aim:
To develop a 3D multiplayer game using Unreal Engine, focusing on implementing basic
Player movement.
Algorithm:
Step1:Understand the basics of Unreal Engine and its capabilities for developing 3Dgames.
Step2:Launch Unreal Engine and create a new project.
Step3:Design a simple 3D environment using Unreal Engine's built-in tools or assets from the
market place.
Step4:Import or create a 3D character model to serve as the player character.
Step5:Write code to handle character movement using Unreal Engine's built-in character movement
component such as walking, running, jumping, and crouching.
Step6:Test the game to ensure character movement behaves as expected.
Program:
Headerfile (.h)
#pragma once
#include "CoreMinimal.h"
#include"GameFramework/
Character.h"#include
"MyCharacter.generated.h"UCLASS()
Class YOURPROJECT_APIAMyCharacter:public ACharacter
{
GENERATED_BODY()
public:
// Constructor
AMyCharacter();
protected:
//Called when the game starts or when spawned
virtual void Begin Play() override;
public:
//Called every frame
Virtual voidTick(floatDeltaTime)override;
//Called to bind functionality to input
P a g e | 52

Virtual void SetupP layerInputComponent(classUInputComponent*


PlayerInputComponent) override;

//Function for moving the character forward/backward


void MoveForward(float Value);

//Function for moving the character right/left


void MoveRight(float Value);
private:
//Speed for character movement
UPROPERTY(EditAnywhere)
floatMoveSpeed= 500.f;
};
Sourcefile (.cpp)
// Source file (.cpp)
#include"MyCharacter.h"
// Sets default values
AMyCharacter::AMyCharacter()
{//Set this character to callTick()everyframe
Primary ActorTick.bCanEverTick = true;
}
//Called when the game starts or when spawned
void AMyCharacter::BeginPlay()
{
Super::BeginPlay();
}
//Called to bind functionality to input
voidAMyCharacter::SetupPlayerInputComponent(UInputComponent*
PlayerInputComponent)
{
Super::SetupPlayerInputComponent(PlayerInputComponent);
// Bind movement functions to input axes
PlayerInputComponent->BindAxis("MoveForward",this,
&AMyCharacter::MoveForward);
P a g e | 53

PlayerInputComponent->BindAxis("MoveRight",this,
&AMyCharacter::MoveRight);
}
//Functionformovingthecharacterright/left void
AMyCharacter::MoveRight(float Value)
{
// Move the character right based on input value
AddMovementInput(GetActorRightVector(),Value*MoveSpeed*GetWorld()-
>GetDeltaSeconds());
}
Output:

Result:
Thus the Developing a 3D Game using Unrealis, verified and executed successfully.
P a g e | 54

Ex. No : 9 Developing a Multiplayer game using unity


Date:

Aim:
To develop a real-time multiplayer game in Unity using the NetCode for Game Objects
framework, aiming to synchronize player data, optimize network serialization, and test multiplayer
functionality across multiple clients.
Algorithm:
Step 1: Understand Unity's NetCode for GameObjects framework for real-time multiplayer games
and recognize the importance of synchronized player data and efficient network transmission.
Step 2: Launch Unity, create a new project, and install required packages: NetCode for
GameObjects, Multiplayer Samples Utility, andParallel Sync Helper via the Package Manager.
Step 3: Create a new GameObject named 'Network Manager', add the NetworkManager
component to it, and grasp the NetworkManager's role in managing connections.
Step 4: Design a player GameObject with PlayerController script and Rigidbody component, add
NetworkObject component to make it networked, and assign the player prefab to
NetworkManager for automatic spawning.
Step 5: Explore two methods for syncing player data: use Unity's ClientNetworkTransform for
basic synchronization.
Step 6: Test multiplayer functionality across multiple clients by starting a host server and
connecting as clients to observe synchronized player data.
Program:
Sample code for Player Controller script
Using UnityEngine;
Public class PlayerController:MonoBehaviour
{
Rigidbody rb;
void Start()
{
rb= GetComponent<Rigidbody>();
}
Void Update()
{
//Add player movement controls here
}
}
P a g e | 55

Sample code for Player Networkscript


Using MLAPI;
usingMLAPI.NetworkVariable;
using UnityEngine;

public class PlayerNetwork:NetworkBehaviour


{
public NetworkVariable<Vector3> position = new
NetworkVariable<Vector3>(new NetworkVariableSettings{WritePermission =
NetworkVariablePermission.Everyone});
public NetworkVariable<Quaternion> rotation = new
NetworkVariable<Quaternion>(newNetworkVariableSettings{WritePermission=
NetworkVariablePermission.Everyone});

voidFixedUpdate()
{
if (IsLocalPlayer)
{//Updatepositionandrotationvariablesbasedonlocalplayerinput position.Value =
transform.position;
rotation.Value=transform.rotation;
}
}
}
P a g e | 56

Output:

Result:
Thus the Developing a Multiplayer game using unity is verified and executed successfully.

You might also like