How To Program A Game For MS-DOS In QBasic


Ladies and gentlemen the reason you are seeing smoke coming out my ears
is simply because for the past 2 weeks i have been programming.
But why have I been programming ?
Let’s go back a few weeks and find out.
[Rewinding..]
Several weeks ago I was sitting on my computer killing time in one of the very few
facebook groups that i follow because it reminds me of my childhood.
MS DOS gaming.
While I was dawdling I read a comment saying:
“Nobody does MS-DOS games anymore except for the 8-bit guy”.
I was familiar with the 8 bit guy.
I have watched many videos of him restoring old computers
but I was not aware that he is building a game.
Anyway the comment triggered one of those
switches in my brain
and placed me a self-challenging situation where I questioned myself if i could do a similar project.
WARNING: Don’t ever ask your self such questions because the answers are incredibly time consuming.
It took me 2 weeks and a huge brain cell loss in order to find the answer, which is
“yes i can do it”.
So the first thing i did was to look up, which
programming languages were used
during the ERA of the DOS which was approximately the 80s and the 90s.
So the most popular languages that were dominating
the computer world back then were:
Fortran, GW-basic, Basica, C, Pascal and Assembly.
That woke up some memories of mine.
I remember when I was a teenager, more like a 12 or 13 years old kid,
I enjoyed experimenting with GW basic.
So since i had some kind of experience with
the basic language I decided to try out my project
on the latest version of basic (for DOS) which was quickbasic or else qbasic.
And the project started..
The 1st thing that I realized is that Quick
basic is a language with no graphics designing environment
where I could draw my graphics.
Modern languages are fully compatible with
graphic files like *.jpg or *.bmp
and all standard image files.
But with qbasic you can’t use the typical
image files of our times
because those image compression algorithms were written for windows long after the era of dos.
The jpg compression was initially written in 1992.
So at that point i thought:
Shit. I am screwed.
If i have to draw everything pixel by pixel,
using codelines
in order for graphics to appear on my screen, i am in deep trouble.
So I had to find some way to design the graphics
of the game, by for example using photoshop
instead of making everything pixel by pixel.
And I found one pretty good solution.
There is this guy called Graham Downey who
wrote a script that can convert images
to BSV files which was the standard image file
for basic.
So I didn’t have to design everything pixel
by pixel any longer.
I could do it in a graphical software like paint shop pro and then convert with this script into bsv.
His script is an add-on for the paint.net
which seems to be a graphical design software
that I was not aware of.
But when i opened it, i realized why I was
not aware of it, it’s pretty amaturish.
A bit better than ms paint but nothing you
could do professional work with.
In the meanwhile i was thinking about the
game plan, the story of my game
designing the idea in my head.
So i decided to create an action fighting
game similar to street fighter or mortal kombat
which i used to play a lot as a kid.
So the initial idea was to create 8 fighters
but after I saw how much time consuming it was
I said to myself OK in the 1st version
of the game you can do just 4 characters.
Then i faced some problems with lack of memory
and i couldn’t add too many fighters or graphics.
You see the thing with dos based programs
is that have one megabyte of accesible memory.
The QB environment needs to fit in there,
as well as your code, arrays and all the graphics memory.
Your program receives one 64K code segment
for each module that it contains.
In order to overcome this limitation, you
can add multiple modules.
And that is the reason, the fourth character
Cliff Booth cannot be selected.
I had no time to create more module so i decided
to keep the program below the limits.
Anyway, the way you can create your graphics
instead of encoding them line by line
or pixel by pixel is this:
You can open a video file or even youtube
and freeze it in the frame that you wanna capture.
Press the prtsc button on your keybord
and then paste the image
which is saved in cache memory in a graphical software program
and from there on you can cut off the unnecessary
area and keep only what you want to use as your graphics.
Don’t care so much about the details because
the largest screen mode compatible with bsv
convertional tool is screen 13 which is 320
by 200 pixels.
So your graphics quality will be reduced when convertin into *.bsv file.
And when displayed it will be scretched, blurred
and the details will go away.
After you finish drawing your characters,
your terrain or whatever graphics will be,
you can save them and open them with paint.net
and “Save as BSV file” which is DOS readable.
Now it’s time to program the actual code.
For that matter you might need to read a few
books or go to a university.
Youtube is a fantastic tool which we all love
and you can find tutorials on how to make an omelete
or masturbate but you can’t learn
how to program.
So, since i am the biggest genius ever laid
foot on planet earth after Einstein,
I read a book about qbasic
and I did it in 2 weeks.
It took me only 2 weeks because I was working from my 8 o’clock in the morning till 8 o’clock at night.
Before we proceed to the actual programming
I must give you some tips
on how to keep your eyes low in radiation.
You have to change your desktop’s Theme to
a contrast mode where the background is black
Otherwise if you watch a white screen for
a long time while programming
your brain will become an omelete.
Quick basic is not running on windows so you
have to download a DOS emulator
and probably the best one is Dos box.
After you download and install DOS Box You
need to set some automations otherwise
you have to do the same things every time you load dos box.
Mount and skip to the drive where your program
is located and then run quick basic
are a few comments that will spear some of your
time.
And then each time you open your dos box it
will start maximized and qbasic will be already running.
Here are some helpful images that you should
get before you start.
The codes of the colors
And the codes of the keybord buttons which
you can also find in the help content of Qbasic.
So let’s proceed now to the actual programming.
Programmers are kind of inhuman.
It must look crazy in the average person’s
eyes
but in a programmer’s eyes it looks like a peace of cake.
It’s his everyday view.
Crazy..

[Youtube’s algorithm could be checking for bad words in subtitles instead of comparing waveforms for all i know.]
Now the most peculiar thing is this command here which it’s supposed to come up with a random number.
And I ask you: What is random ?
There is no such thing as “random”.
“Random” is nothing but a made up word.
It does not really exist in nature.
Call me cynic but i believe in a deterministic
universe where all events are determined
completely by previously existing causes.
Every result is the reaction of some kind
of initial action that triggered it.
There is no such thing as “random”
so how does a computer comes up with a random
number ?
I don’t know but i can guess a few ways to
do that.
One way is that the computer could for example
get our current time.
Let’s say that at the moment of the computing
the time was 12:01:45
and then puts those numbers into an equation and then makes some weird calculations
and comes up with a “random” number.
Its time we ask of the computer to give a
new random number because the seconds are different
in the given time that we ask, the
result of the equation is different.
So it gives us a new random number which we
think that is random but it isn’t.
Computers do only what we tell them to do.
They can’t come up with a random number.
Humans can’t come up with a random number
either.
When someones asks you to tell him a random
number from 1 to 10 and you choose for example 3,
there is a very reasonable explanation
why you chose with this number
which which is based on the processing data of your brain
and a chain reaction of electromagnetic signals within your brain.
Ok so i will try to explain a few things.
Some declaration in the beginning and then
we have the graphics with BLOAD command,
a very popular command.
Those are the starting values of the variables.
And let’s see “SUB AI Zero”.
This is the artificial intelligence of the
computer opponent.
It gives us a random number from 1 to 31 and based on that random number it acts.
So if the random number is 1 and the bad guy (opponent) is Bruce Lee
and the distance between the bad guy and the good guy is less than 50 pixels
when the characters are near which means that the punch is effective
Because if the characters are distant the punch is not effective (it does not count).
Here for example it deducts from the score
5 points, from the one received the punch.
And those limits here are so the characters
don’t fall on each other.
And that is because when a character receives
a punch he gets a bit at the back.
When somebody is hit he goes a bit backwards.
In another case when the random number is 2, here we have a larger instance because the kicks
could be applied on a larger distance.
Because it is a kick not a punch.
Our leg goes further than our hand.
And then deduct 10 points because the kick
is stronger (than the punch).
And then play a sound and some limiters and
get the character back that took the kick.
On some other random cases the computer opponent
just moves
or
here if difficulty is 1 do nothing
but if difficulty is 2 which means that the
game is set on HARD mode then BLOCK.
Do some blocking.
In some other cases the characters just move
or hit or punch.
Here we have the loop that is responsible
for awaiting input keys.
It just loops and awaits until you press a
button.
In the meanwhile it generates that random
number that i told you earlier
which makes the opponent act (commonly the AI).
And then those are the buttons (input keys).
The block, the kick, the punch, the left and
the right.
Here we have what the block does.
For example, if character is Bruce.. block
Bruce, if character is Chuck..
load up the Chuck image. And so on.
And here it calculates how many rounds are
won by a player
and if 2 rounds are won by one of the two players go to the next match and bring up a new opponent.
Here for example we have the SUB of the main
menu.
Here we have the victory, what happens when
you eliminate all your enemies.
CLS=Clears the screen
And then colorize and locate where the text will be on your screen.
And then “delay 10” is a routine to hold on
a little bit before proceeding on the next command.
This is one of the latest things i did, the
melody.
I converted the melody of my original song
into Basic mode.
Those are notes here.
A lot of coding.
I am surprized with myself.
How did i manage to do that in only two weeks
but it can be done.
If your will is strong enough
you can do it.
OK enough with the explanations.
Let’s run and see the actual game.
(The game has less FPS here. I also skipped some rounds.)
You can download the latest version of the
game in the link in the description.
And you can also find the link to Spotify
to stream the original version
of “Legeds Never Die” which is a track that i wrote.
So a few conclussion about programming:
I am certainly not going to be a programmer.
This project burned and lot of my brain cells.
During the days that there was programming
I was not able to think of anything else.
The amount of energy that a person needs to
consume in order to find solutions to the
problems that occur during programming is
enormous.
And in combination with the many memory problems
that i experienced with Qbasic and the limitations
i would not consider making another Qbasic
program ever again.
But it is a good excersize for your mind.
So my next project related to programming
will be based on a language supported by windows
and will have a graphical design compatibility.
So now I can go back on Facebook and comment that MS-DOS games are still in development
NOT only by the 8-bit guy.
Thanks for watching.

5 Replies to “How To Program A Game For MS-DOS In QBasic”

  1. Qbasic is my favorite programming language. I have made many games in Qbasic, including many in the past few years. I'd love to compare notes.

  2. LOL – nice work! That game looks hilarious! 😉
    By the way, are you going to release the source code? You know… because of your name and all

Leave a Reply

Your email address will not be published. Required fields are marked *