The Tech Edvocate

Top Menu

  • Advertisement
  • Apps
  • Home Page
  • Home Page Five (No Sidebar)
  • Home Page Four
  • Home Page Three
  • Home Page Two
  • Home Tech2
  • Icons [No Sidebar]
  • Left Sidbear Page
  • Lynch Educational Consulting
  • My Account
  • My Speaking Page
  • Newsletter Sign Up Confirmation
  • Newsletter Unsubscription
  • Our Brands
  • Page Example
  • Privacy Policy
  • Protected Content
  • Register
  • Request a Product Review
  • Shop
  • Shortcodes Examples
  • Signup
  • Start Here
    • Governance
    • Careers
    • Contact Us
  • Terms and Conditions
  • The Edvocate
  • The Tech Edvocate Product Guide
  • Topics
  • Write For Us
  • Advertise

Main Menu

  • Start Here
    • Our Brands
    • Governance
      • Lynch Educational Consulting, LLC.
      • Dr. Lynch’s Personal Website
      • Careers
    • Write For Us
    • The Tech Edvocate Product Guide
    • Contact Us
    • Books
    • Edupedia
    • Post a Job
    • The Edvocate Podcast
    • Terms and Conditions
    • Privacy Policy
  • Topics
    • Assistive Technology
    • Child Development Tech
    • Early Childhood & K-12 EdTech
    • EdTech Futures
    • EdTech News
    • EdTech Policy & Reform
    • EdTech Startups & Businesses
    • Higher Education EdTech
    • Online Learning & eLearning
    • Parent & Family Tech
    • Personalized Learning
    • Product Reviews
  • Advertise
  • Tech Edvocate Awards
  • The Edvocate
  • Pedagogue
  • School Ratings

logo

The Tech Edvocate

  • Start Here
    • Our Brands
    • Governance
      • Lynch Educational Consulting, LLC.
      • Dr. Lynch’s Personal Website
        • My Speaking Page
      • Careers
    • Write For Us
    • The Tech Edvocate Product Guide
    • Contact Us
    • Books
    • Edupedia
    • Post a Job
    • The Edvocate Podcast
    • Terms and Conditions
    • Privacy Policy
  • Topics
    • Assistive Technology
    • Child Development Tech
    • Early Childhood & K-12 EdTech
    • EdTech Futures
    • EdTech News
    • EdTech Policy & Reform
    • EdTech Startups & Businesses
    • Higher Education EdTech
    • Online Learning & eLearning
    • Parent & Family Tech
    • Personalized Learning
    • Product Reviews
  • Advertise
  • Tech Edvocate Awards
  • The Edvocate
  • Pedagogue
  • School Ratings
  • iClever Q950 Kids Headphones Review: Premium Sound and Safety for Young Listeners

  • The Reckless Ben Controversy: An Outrageous Fight for Justice

  • Outrageous: The Sydney Sweeney Ad Controversy You Didn’t See Coming — And Why It’s Working

  • The AI CRM War: Why Salesforce Just Made a $2 Billion Bid for a Startup

  • OpenAI’s Navier-Stokes ‘Solution’ Ignites Firestorm: Did They Steal It?

  • Blizzard’s Boldest Bet: Why a StarCraft Shooter in 2030 Could Redefine Gaming

  • Volatile: Why Top AI Bosses Just Triggered a Massive AI Stocks Decline

  • ‘Godfather of AI’ backs Anthropic chief’s call to slow down development

  • Why Millions Are Flocking to Trade Schools as AI Reshapes the Job Market

  • Unmasking the Bizarre ‘Cat in the Hat’ Trend: Why Schools Are Sounding the Alarm

How To
Home›How To›How to Build a Simple Computer Game Using Batch Script

How to Build a Simple Computer Game Using Batch Script

By Matthew Lynch
February 28, 2024
0
Spread the love

Introduction

Building a simple computer game can be an entertaining and educational experience, even for those with little or no programming knowledge. One way to accomplish this is by using Batch Script, which is a scripting language used to automate tasks on the Windows operating system. In this article, we will guide you through the process of creating a simple text-based game using Batch Script.

Getting Started

To build your game, first, open up Notepad or any other text editor you prefer. We will use this text editor to write our batch script. Save the file with a .bat extension (for instance, game.bat) to ensure that it can be executed as a batch script.

Creating the Main Menu

Begin by setting up the main menu of your game. This will be the first thing a player sees upon launching your script.

@echo off

echo Welcome to our Simple Batch Game!

echo.

echo Please choose an option:

echo 1. Start Game

echo 2. Exit Game

set /p input=”Enter your choice (1-2): ”

if %input%==1 goto startGame

if %input%==2 goto exitGame

This script segment sets up a basic menu that allows users to start or exit the game. The `set /p` command allows for user input, and then compares it against specific values. If user inputs ‘1,’ they are directed to start the game (startGame); if ‘2,’ they are directed to exit (exitGame).

Designing the Game

Now it’s time to define the gameplay itself. For simplicity’s sake, we’ll create a basic “guess-the-number” game.

:startGame

cls

set /a randomNumber=%random% %% 10 + 1

echo Guess a number between 1 and 10.

set /p guessedNumber=”Enter your guess: ”

if %guessedNumber%==%randomNumber% goto win

goto lose

In this section, we first clear the screen using the `cls` command before generating a random number between 1 and 10. We then prompt the user to guess the number and store their input in the “guessedNumber” variable. If their guess matches the generated number, they win, otherwise they lose.

Winning and Losing Screens

Now let’s create winning and losing screens:

:win

cls

echo Congratulations! You guessed correctly!

echo The correct number was %randomNumber%.

goto endGame

:lose

cls

echo Sorry, that was incorrect.

echo The correct number was %randomNumber%.

goto endGame

Here we create separate sections for winning and losing scenarios, each showing a tailored message and revealing the correct number. After displaying the outcome, they both lead to “endGame”.

Exiting the Game

Finally, create a function to exit the game as chosen by the user from the main menu, as well as after completing a game.

:endGame

timeout /t 5

exit

:exitGame

exit

The `timeout /t 5` command pauses script execution for five seconds before proceeding to exit. This gives players enough time to read their results before closing.

Conclusion

And there you have it – a simple text-based guessing game created with Batch Script! This article serves as an introduction to building simple games using this language. You can expand your knowledge and creativity by exploring more advanced commands and concepts in Batch Scripting as you develop more complex games. Happy gaming!

Previous Article

4 Simple Ways to Style Layered Shoulder ...

Next Article

How to Get a Boyfriend on Animal ...

Matthew Lynch

Related articles More from author

  • How To

    3 Ways to Pick up a Guy at a Bar

    February 13, 2024
    By Matthew Lynch
  • How To

    How to Clean a Candle Jar

    November 13, 2023
    By Matthew Lynch
  • How To

    15 Ways to Wear a Haori Coat

    November 14, 2023
    By Matthew Lynch
  • How To

    How to Make 3D Photos

    January 5, 2024
    By Matthew Lynch
  • How To

    3 Ways to Know When Your Hermit Crab Is Dead

    October 13, 2023
    By Matthew Lynch
  • How To

    How to Build a LEGO House: 12 Steps

    January 7, 2024
    By Matthew Lynch

Search

Login & Registration

  • Log in
  • Entries feed
  • Comments feed
  • WordPress.org

Newsletter

Signup for The Tech Edvocate Newsletter and have the latest in EdTech news and opinion delivered to your email address!

About Us

Since technology is not going anywhere and does more good than harm, adapting is the best course of action. That is where The Tech Edvocate comes in. We plan to cover the PreK-12 and Higher Education EdTech sectors and provide our readers with the latest news and opinion on the subject. From time to time, I will invite other voices to weigh in on important issues in EdTech. We hope to provide a well-rounded, multi-faceted look at the past, present, the future of EdTech in the US and internationally.

We started this journey back in June 2016, and we plan to continue it for many more years to come. I hope that you will join us in this discussion of the past, present and future of EdTech and lend your own insight to the issues that are discussed.

Newsletter

Signup for The Tech Edvocate Newsletter and have the latest in EdTech news and opinion delivered to your email address!

Contact Us

The Tech Edvocate
910 Goddin Street
Richmond, VA 23231
(601) 630-5238
[email protected]

Copyright © 2026 Matthew Lynch. All rights reserved.