Writing an incremental game with Python

Day 5,759, 09:28 Published in Turkey United Kingdom by eerte


This article is purely written for 25 comment purposes. Still to be interesting, I am proposing a small tutorial for those interested in learning programming. No excuses, let's begin coding right now, right here!

Update: Read and comment these articles as well:

https://www.erepublik.com/fr/article/redefining-erepublik-towards-a-global-nation-2771679

https://www.erepublik.com/fr/article/yeni-d-nya-d-zeni-yeni-strateji-a-new-world-order-a-new-strategy--2771677/1/20

Please comment for the 25 mission and subscribe


I assume you have already installed python
If not, you may go to www.python.org and follow instructions there. In programming, we use a developer environment to code. It's like a text editor for writing (think of microsoft word for writing an essay. If you have never coded before, you may begin with python IDLE which comes with the original installation of python.


We will use a "library". Which is a bunch of code that is already written by others and that you may use by just calling it out in your own code. To do so, open command by typing "cmd" on windows search bar, and type "pip install tkinter" and wait for the installation. If you're using linux, follow this guide.

Plan Your Game

Decide on the concept and mechanics of your incremental game. In an incremental game, players typically click on something to earn points or resources, which can then be used to automate the process or buy upgrades. Plan what your game will look like and how it will function.


Basic script to begin

Let's set up a basic script to create a tkinter window with a score label and a button to earn points when clicked (you may copy paste it on your script):

import tkinter as tk

# Create the main game window
window = tk.Tk()
window.title("Incremental Game")

# Define variables to keep track of resources
score = 0

# Create a label to display the score
score_label = tk.Label(window, text="Score: 0")
score_label.pack()

# Create a button to earn points
def earn_points():
global score
score += 1
score_label.config(text=f"Score: {score}")

earn_button = tk.Button(window, text="Earn Points", command=earn_points)
earn_button.pack()

# Run the tkinter main loop
window.mainloop()


What's left to do:



From there, you may expand your game by adding more buttons, upgrades, and automation features. You can create functions to handle these actions and update the score accordingly. It's up to you! By starting such a trivial project, you can increase your programming skills incrementally (sorry I couldn't resist).



Here's another interesting project: Simple cookie clicker in just 22 lines of code, credit goes to youtuber TokyoEdtech