Close

How to develop a basic game in 15 minutes. My tutorial will surprise you how easy it is!

Lucas WalkerLucas Walker wrote 03/16/2020 at 17:30 • 8 min read • Like

Every player has been stuck with an idea of developing its own game at least once. Let me introduce you to what is needed from your side. Once you capped some patience and willingness to create something new, be sure to install Microsoft Visual Studio.

Step 1: Install an app in order to Develop a Game

First things first, you should install Microsoft Visual Studio, which is one of the most convenient integrated development environments that can be used for beginners. For your first steps with app development, remember that this application can also be used for  development of web services, standalone applications, and mobile tools.

I would recommend heading directly to the website of Visual Studio, which has direct download links for either Windows or macOS. You should choose the Community version of Visual Studio.

Once you have successfully installed Visual Studio, you should also be ready to encounter the basics of C#. This programming language is definitely complex, yet if you heard about Kerbal Space Program, a game that was entirely developed with exclusive use of C#, you would know that this general-purpose language can easily be called multifunctional one. If you’re looking for examples of widely used apps developed on C# (also known as C Sharp), just take a look at the following list:

*         Visual Studio

*         Paint.NET

*         Open Dental

*         Beagle

*         HandBrake


Step 2: Create a project in Visual Studio

Now, I’ll show you how to create a project and further develop it within functionality of Visual Studio. First off, once opening an application, head to File and click on a New Project tab.

A pop-up menu will appeal with lots of tools and tabs to open. There, you’ll have to choose Windows Forms Application on Visual C#, which will work on the basis of .NET framework 4.5.2.

Be sure to put a name to your first project, followed by opening its first Form.

I know, that might be a bit confusing to start a new project straight away. Believe me, you’re already on your track towards creating a full-scale game on your own.

Step 3: Add the code of the Game to the Visual Studio

What if I tell you that you can create your own game without a proficient use of C#? Community of developers often operate with open-source projects. These open-source libraries allow taking a look at one’s C# code, eventually making specific changes to customize  y

 For your comfort, I am also inserting code right below for you to add it to a new project straight away:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System. Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace SlotMachine
{
    public partial class Form1 : Form
    {
        public Form1()
     {
         InitializeComponent();
     }
      // DECLARING TOTAL, BET AND CREDITS
     public static long credits = 100;
     public static long total = 0;
     public static int bet = 5;
 
     // DECLARING EACH ITEM
     public static int p1;
     public static int p2;
     public static int p3;
 
     private void Form1_Load(object sender, EventArgs e)
     {
         pictureBox1.Image = Image.FromFile("2.png");
        pictureBox2.Image = Image.FromFile("3.png");
         pictureBox3.Image = Image.FromFile("1.png");
     }
 
     // GENERATES RANDOM NUMBERS
     public static class IntUtil
     {
         private static Random random;
 
         private static void Init()
         {
             if (random == null) random = new Random();
         }
         public static int Random(int min, int max)
         {
             Init();
             return random. Next (min, max);
         }
     }
 
     private void button1_Click(object sender, EventArgs e)
     {
         if (credits >= bet)
         {
             credits = credits - bet;
             label1.Text = "Credits: " + credits.ToString();
 
                for (var i = 0; i < 10; i++)
             {
                 p1 = IntUtil.Random(1, 4);
                 p2 = IntUtil.Random(1, 4);
                 p3 = IntUtil.Random(1, 4);
             }
 
             if (pictureBox1.Image != null) pictureBox1.Image.Dispose();
             pictureBox1.Image = Image.FromFile(p1.ToString() + ".png");
 
             if (pictureBox2.Image != null) pictureBox2.Image.Dispose();
             pictureBox2.Image = Image.FromFile(p2.ToString() + ".png");
 
             if (pictureBox3.Image != null) pictureBox3.Image.Dispose();
             pictureBox3.Image = Image.FromFile(p3.ToString() + ".png");
 
             total = 0;
 
             // GET RESULTS FROM PAYTABLE
             // CHECK IF 1, 2 OR 3 OCCURANCES
             if (p1 == 3) total = total + 5;
                                           
             if (p1 == 2 & p2 == 2) total = total + 10;
             if (p1 == 3 & p2 == 3) total = total + 10;
                                           
             if (p1 == 1 & p2 == 1 & p3 == 1) total = total + 20;
             if (p1 == 2 & p2 == 2 & p3 == 2) total = total + 30;
             if (p1 == 3 & p2 == 3 & p3 == 3) total = total + 50;
 
             credits = credits + total;
             label3.Text = "Win: " + total.ToString();
             label1.Text = "Credits: " + credits.ToString();
         }
     }
    }
}

By inserting these lines of code, you will also need to insert images to your Project file’s destination. This step is needed to ensure that your reels and icons would include actual images for your game to look like a real one.

Once you’ve inserted all those code lines to a new project, alongside inserting images, you might want to personalize your game a little bit. You might start by changing system of betting and credits, which is written in a code in the form of:

public static long credits = 100;
public static long total = 0;
public static int bet = 5;

         By changing those configurations, you might change the size of bet as well as play a little bit with the overall number of credits.

         As you can see, the results of paytable payouts operate with an if function, which states the following numbers:

if (p1 == 3) total = total + 5;
if (p1 == 2 & p2 == 2) total = total + 10;
if (p1 == 3 & p2 == 3) total = total + 10;   
if (p1 == 1 & p2 == 1 & p3 == 1) total = total + 20;
if (p1 == 2 & p2 == 2 & p3 == 2) total = total + 30;
if (p1 == 3 & p2 == 3 & p3 == 3) total = total + 50;

Don’t be afraid to play with these numbers to change payout system of your slot. Since the original code is intended to create a slot machine with a total of three symbols, changing their payout configuration might be an option.

Once you’re up for adding even more symbols, you’ll have to declare each item in the code. In the original form, only three items are declared, including:

public static int p1;
public static int p2;
public static int p3;

Don’t be shy playing with these configurations by adding more symbols, which is needed to personalize your own game.


Step 4: Play New Slot Game

Upon trying to play a new slot game, you will see a picture like this.

 

As you can see, a combination of three golden pieces allows winning a total of 40 credits, as indicated by the function:  if (p1 == 2 & p2 == 2 & p3 == 2) total = total + 30;

Since my guide is aimed at newbies in programming and Visual Studio basics, such a simple slot machine can be created by you in less than 15 minutes. Once you are interested in a topic a little bit more, go ahead with playing with payout functions, images, and the number of declared symbols.

Considering that no real difficulties can be encountered on the stage of including code and personalizing it, my only suggestion is to pay attention to images and folders. If you forget to include them in a folder with your project, no images of symbols will appear while playing your slot machine.

My recommendation is not to forget that the process of development with C# is not the only one. Although this programming language is a smooth one for a production of games via Visual Studio, the latter one is usually used for actual stages of development with the use of C++, whereas C# is used for creation of tools and other external features.

In contrast, Visual Studio supports both these languages, meaning that your baby steps in developing your own game should rather be done in course of leading Visual Studio.


Other Popular Tools to Create the Simple Game Online

If you find previous guidelines to be too complex for game development, you might as well as think about other game development tools, such as:

 

Regarding the average time for creating your own games using the mentioned above tools, I would recommend GameMaker Studio as the fastest one. With its use, you can develop a game in less than an hour. Stencyl and Twine are more complex since they require more comprehensive technological knowledge. The average time of creating the same game we just developed in Visual Studio for those apps equals a few hours.

When it comes to popularity, GameMaker Studio is a famous tool for learning more about cycles of game development, alongside progressing in designing games from easy to hard levels. Twine is more complex than a GameMaker Studio, whereas its use in browsers makes it one of the most popular devices. I would recommend Stencyl only for those who are fluent with MIT Scratch, a tool for learning how to program. In my mind, Stencyl is popular among developers with already acquired pieces of knowledge in development, Flash technologies, and mobile transfers.

Drawing conclusions, I would recommend you to experiment with the mentioned above tools, instead of creating another project in Visual Studio. Regardless of what you’ll choose, good luck with that!

Like

Discussions