Develop a game that is currently not on the Google Play Store — Part 2

SHRINATH BHAT
5 min readJan 26, 2023

--

Image Credits: https://www.activestate.com

Note: Click on the link to read part 1 where I cover the basics!

Adding more functionalities to the game

Adding more functionalities to the basic example I provided earlier:

  • Add more levels or scenes to the game, each with its own background image and set of choices.
  • Add items that the player can pick up and use, such as a flashlight or a map. You could also add a inventory system where the player can view and use the items they have collected.
  • Add NPCs that the player can interact with, such as a guide or a shopkeeper. You could also add a dialogue system where the player can choose what to say to the NPCs.
  • Add enemies that the player must defeat, such as monsters or traps. You could also add a combat system where the player can choose what actions to take during a fight.
  • Add a scoring system where the player can earn points for making good choices and completing tasks, and lose points for making bad choices or failing tasks.
  • Add a save system where the player can save their progress and continue playing later.
  • Add sound and music to the game to create a more immersive experience.
  • Add animations to the game to make it more visually interesting.
  • Add a menu system where the player can access options such as saving, loading, and quitting the game.

Keep in mind that building a robust game can take a lot of time and effort, but it’s a rewarding experience. You can also use existing libraries such as Pygame Zero or Arcade to make the development process easier.

It’s important to start by creating a design document that outlines the game’s story, characters, mechanics, and functionality, this will help you to organize your thoughts and plan the development process. Also, it’s important to test the game regularly and get feedback from players to make sure that it’s fun and engaging.

To add all the functionality that I mentioned earlier, you would need to use various Pygame functions and modules to create the different elements of the game. Here’s an example of how you could implement some of the functionality:

  • To add more levels or scenes, you could create a dictionary that maps the names of the scenes to their corresponding background images and set of choices. For example:
scenes = {
"forest": {
"image": "forest.jpg",
"choices": ["Go left", "Go right"]
},
"cave": {
"image": "cave.jpg",
"choices": ["Go deeper", "Turn back"]
}
}
  • To add items that the player can pick up and use, you could create a list of dictionaries that contain information about the items, such as their name, description, and effects. For example:
items = [
{
"name": "flashlight",
"description": "A handy flashlight that can light up dark places.",
"effect": "increase_visibility"
},
{
"name": "map",
"description": "A map of the area that can help you find your way.",
"effect": "show_location"
}
]
  • To add NPCs that the player can interact with, you could create a list of dictionaries that contain information about the NPCs, such as their name, description, and dialogue. For example:
npcs = [
{
"name": "guide",
"description": "An experienced guide who can help you on your journey.",
"dialogue": {
"greeting": "Welcome traveler! I can help you navigate these treacherous lands.",
"quest": "I've heard of an ancient treasure hidden deep in the cave. Will you help me find it?",
"farewell": "Farewell, and good luck on your journey!"
}
},
{
"name": "shopkeeper",
"description": "A friendly shopkeeper who sells useful items.",
"dialogue": {
"greeting": "Welcome to my shop! What can I do for you?",
"items": "I have a flashlight and a map for sale. They can be very useful on your journey.",
"farewell": "Thank you for your business! Come back soon."
}
}
]
  • To add enemies that the player must defeat, you could create a list of dictionaries that contain information about the enemies, such as their name, description, and stats. For example:
enemies = [
{
"name": "goblin",
"description": "A small and cunning goblin who likes to steal from travelers.",
"stats": {
"health": 10,
"attack": 5,
"defense": 2
}
},
{
"name": "troll",
"description": "A large and strong troll who guards a valuable treasure.",
"stats": {
"health": 20,
"attack": 10,
"defense": 5
}
}
]
  • To add a scoring system, you could create a variable that keeps track of the player’s score, and increment or decrement it based on their choices and actions. For example:
score = 0

def increment_score(points):
global score
score += points
def decrement_score(points):
global score
score -= points
  • To add a save system, you could use the pickle module to save the player's progress to a file, and load it when the player wants to continue playing. For example:
import pickle

def save_game(player_name, score, items, location):
data = {
"player_name": player_name,
"score": score,
"items": items,
"location": location
}
with open("save.dat", "wb") as file:
pickle.dump(data, file)
def load_game():
with open("save.dat", "rb") as file:
data = pickle.load(file)
return data
  • To add sound and music, you could use the pygame.mixer module to play sound effects and background music during the game. For example:
import pygame.mixer

pygame.mixer.init()
footsteps_sound = pygame.mixer.Sound("footsteps.wav")
footsteps_sound.play()
background_music = pygame.mixer.music.load("background_music.mp3")
pygame.mixer.music.play(-1) # -1 means the music will loop indefinitely
#To stop the music: pygame.mixer.music.stop()
  • To add animations, you could use the pygame.Surface and pygame.Rect classes to create and move sprites on the screen. You could also use the pygame.time module to control the frame rate and animation speed. For example:
import pygame

player_image = pygame.image.load("player.png")
player_rect = player_image.get_rect()
player_rect.x = 100
player_rect.y = 100
speed = 5
while True:
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
sys.exit()
keys = pygame.key.get_pressed()
if keys[pygame.K_LEFT]:
player_rect.x -= speed
if keys[pygame.K_RIGHT]:
player_rect.x += speed
if keys[pygame.K_UP]:
player_rect.y -= speed
if keys[pygame.K_DOWN]:
player_rect.y += speed
screen.blit(player_image, player_rect)
pygame.display.update()
pygame.time.Clock().tick(60) # 60 fps

To bring all of these elements together you could create a main game loop that handles all of the different elements of the game and updates the screen accordingly. You could also create functions to handle the different actions and choices that the player can make, such as moving between scenes, interacting with NPCs, picking up and using items, and defeating enemies.

Reference: This article is written with the help of ChatGPT Open AI

--

--

SHRINATH BHAT

IIT Madras 2020 graduate. Senior Data Scientist at AB Inbev with 3 years of versatile experience in Machine Learning, Advanced Analytics & Al