Hey guys this is Eddie the Magic Monk. Welcome to another programming lesson in
this series of videos what we're going to try to do is program flappy birds in
Visual Basic so if you haven't played the game flappy birds before feel free
to google it and have a go at it and then come back when you know what flappy
birds is so in the first tutorial what we're going to make sure that you can do
is basically in Visual Basic we're going to run a program where an object is
falling down the screen at the beginning so as soon as you run the program an
object appears on the screen and it's falling down at a certain gravity level
so if you're sure you can do that already then feel free to skip this
video otherwise I will walk you guys through how to do that okay the first
thing we're going to do is open up Visual Basic so let me just close down
everything so we're gonna start from the beginning of Visual Basic so you're
going to open up Visual Basic new projects and you can call give it a name
so I'm just going to call it flappy bird
okay so you create the program and at the beginning of the program you have a
form and in this form there's currently nothing right now so if you run this
program by clicking on start debugging
you can see that there is currently nothing in the form okay and you can
type or click whatever you want nothing's going to happen so let me just
change the start position of the form to center screen so it starts in the
middle of my screen when I click start
okay the next thing I'm going to do is create a picture box and put it in the
middle of my window okay and on the right hand side I'm going to go to the
properties panel and I'm going to change a color of my picture box to orange I'm
going to make it a little bit smaller and I'm also going to change the name of
my picture box so I go to the property the name property of picture box one and
I'm going to change it to bird okay so this is my bird I'm going to make the
window slightly bigger okay so if I run this program now still nothing happens
but you can see an orange box at the beginning okay now I'm gonna double our
actually let me drag one more object onto the screen and this object that I'm
dragging on to the screen is the timer object which is located
under components so drag the timer object onto the screen so I have timer
here and the timer interval I'm going to make it 40 milliseconds okay so if you
double-click in the forum you get to the coding section of the program and when
form1 loads what I want to do is I want to enable the timer so I'm going to type
timer1.enabled equals true and this enables the timer at the beginning of my
program so if I double click on timer whatever code that I type in here it's
going to be run automatically once every 40 milliseconds which is what I typed in
before okay so what am I going to run in my program
well the first thing I'm going to do is to clear some variables so let's go back
up to the top of the form of the coding section straight underneath public class
form 1 I'm going to declare a variable called Y speed and basically it's the
vertical speed and I'm going to make it zero so Dim Y speed as integer equals
zero okay so this creates a Y speed variable it's going to make it an
integer and it has the value of zero and the next thing I'm going to do is create
a variable called gravity and it's also an integer which holds a value of let's
say 2
okay you'll see what these variables do in a second
so when timer one ticks what I want to do is I want to increase the Y speed by
1 sorry by the gravity value okay so every time the timer ticks Y speed is going to
increase by two so basically it's going to go from zero to two to four to six
and so on and it's the speed of it is going to increase quite quickly and then
what I want to do is I want to change the position of the ball so ball dots so
the bird.top is equal plus equal to Y speed okay so what this is going to do
is it's going to increase the speed variable by the gravity so it's going to
go from zero to four six eight and the top position of the bird which means the
Y position it's going to increase by whatever the speed variable is so
initially let's say the ball right now is in a position of twenty-five it has a
y-value of twenty-five so it's going to originally increase by zero then it's
going to increase by two and then it's going to increase by four it's going to
increase by six and so on so if we run the program now we should see the bird
falling down pretty quickly okay and if you change the gravity value it can
either fall a bit slower or if you want to make it fall a bit quicker make it a
bigger number and it will fall a little bit quicker so now we have
done the first part of the flappy birds tutorial in Visual Basic see you guys
next time.