Tip:
Highlight text to annotate it
X
Howdy Howdy. This is Mr. Potter
I'd like to thank you for joining our Hour of Code 2013 project.
What we're going to do is we're going to be creating a game
using SharpDevelop
which is in the C# language. Now, what's really nice about
the C sharp language is that it's very easy to make a Windows program because
it uses something called
forms; the idea that I can drag a toolbar, or I can drag a text box or I can drag a button
onto this form, and make it look just like any other Windows applications.
It's one of the real powerful aspects of C# as an introductory
computer programming language so this is part of the "Hour of Code" program which is
done by
the Code organization, http://www.csedweek.org. The whole idea behind this that
anyone can put together code. Anyone
can write a program that does something, and
the whole purpose of this program is to introduce
youth, introduce people to knowing that they can produce
computer code. So what we're going to be doing today is we're going to be
creating a
real small video game, just a real simple video game so we can
have a pig that runs around and we have to try and capture
and we're going to be using a program called SharpDevelop to create this
program
now SharpDevelop is a free software program
the you can download and the website will be down the description.
It's http://www.icsharpcode.net and what's really nice about this is that it is free. You
don't have to pay any money for it.
Anyone can install it on their window system,
and if you're going to be using this for a Mac or Linux then you're going to be
doing this using something called
MonoDevelop, which has a lot of the same functionality and
I'm going to break right here to kind of show you how to install
the SharpDevelop program if you don't already have it on your desktop...
We're gonna start by opening up our browser
and there's two programs that we need to get
the first program that we need to get is on the
http://www.icsharpcode.net website
and so what we're going to do
is go to the http://www.icsharpcode.net we want to download SharpDevelop, so
I'm going to click on the website here.
and I want to go up here to download. Now, there are
two things that we would need to get at most:
the first thing we need to get is the download for SharpDevelop 3.2.
I'm going to go and click on this link it's going to take us to that part of the page
and what I want to do is I want to download the setup
program so this is actually going to set it up on a Windows program
and it should take a few minutes to save
and the other thing is something that you need to do
if you have an older version than Windows 7.
So if you have Windows Vista or Windows XP then you'll need to go ahead and download
the .NET framework. This is something that you need in order to
run and create the C#
programs, and so this is a link that you can get off the
Microsoft web page. So I'm going to
run this installer. Of course, Windows is going to ask for verification that I really want
to run this since it was downloaded from the Internet.
And here's my installation
setup screen. I'm going to click Next to go to the next screen.
Here's the license agreement which you'll need to take a look at, make sure you agree
and if you do agree you'll choose accept and choose next.
We're going to leave these default associations
as they come, so I'm going to click next here as well, and it should install everything
to the appropriate folders.
So, at this point we're just going to wait for the insulation to
finish.
And, of course anytime that we download something from the internet we need to
make sure that we
trust were getting it from. So I'm going to go ahead and click Yes to accept this
and it goes to the installation process fairly quickly
And now we're done.
So we want to run a click the Finish button to exit the setup window.
And now we have our SharpDevelop icon
on our desktop. So now that we have SharpDevelop
installed in our desktop we're going to go ahead and double click on it to run it.
We're gonna see the small Nemo fish and what SharpDevelop does is it creates
packages of programs that are called solutions. The main idea behind Computer
Science is that
when we're trying to write a program what we're really trying to do is solve
a problem and the whole idea behind using computer
code to solve problems is that any big problem can be broken up into a series
of steps, and if you know how to address each of those steps
the know how to solve the problem in total. So what we're going to do is we're
going to create a new solution
and our solution is going to be a Windows application
So I want to highlight Windows application
and it's going to be saving to a directory somewhere on my hard drive
I can change this to be on my desktop or in a different folder
but it's gonna put it in your My Documents folder and put it in a
folder that it creates call Sharp Develop Projects.
I'm just gonna call this program "Pig." It's going to automatically create a
directory for this so when I hit create
I'm staring at code. Now
this code is already written for you
and the purpose of this code is to create the windows form.
So what I'm going to do here is click on the small box here that says
Design
so you can see the form in its entirety.
So there's my form, just a real simple form and it says
Pig on it because Pig was the name of my project.
Now over here on the right you're going to see a whole bunch of data
about this form and this data has
a lot of parts to it. I see this text box here
the little line that says "Text" that says "Pig" and I can
click in this box to change it. I can back up
and type
"Catch the Pig", and when I hit enter, notice that
the title bar for my Windows application
has changed to say Catch the Pig. So this
Text property will actually change whatever shows up on the title bar
for this application. So, that's the first thing that I want to do.
The second thing that I want to do is I'm going to have a pig running around in here.
Now, you can choose to have your pig running around in slop but I'd like to
have my pig running around in a green field.
So under the same section of Appearance I'm going to change the background color.
Now, right now it's basically for a default Windows application which means
it's this Control Color
but if I click in this area and choose the down arrow
I can change to a different color. Now, I've got system colors
I can click here to choose web colors and there's lots of colors to choose from
but i want to go ahead and get a custom and I'm going to choose this nice green here.
Now this green is called Lime by the system but I think it makes a beautiful
grass color, don't you? So I've got this field for my pig to run around in
but it's not a very big field and so, what I want to do is I want to change
the size up the form and it's another property that I'm going to change
I'm gonna scroll down and under Layout
I'm going to see size and I want to change the size right now it's 300
pixels by 300 pixels.
So, I'm going to backup and I'm gonna make it
600, 600 because I want this to be
600 pixels by 600 pixels pixels, a nice wide
wide field for my pig around in
so I've set up the form the way that I like it
the next thing I want to do as I want to create Mike
hick and so what I'm going to do is on the left side of my screen
over here where it says tools I'm gonna choose Windows Forms
when I click on Windows Forms its gonna show me all of these different things
that I can
add to my form that I've created
I can create a pointer or special button but I'm really interested in is this
label because this label is going to be my pick
some in a quick and drag some holding the mouse button down I'm gonna track it
onto my form somewhere
near the middle of my for and when I let go
my mouse button their is my label
now if I want to I can click and drag to move it anywhere that I want on the
floor
there are several things that I want to do here with this label
first of it doesn't look like a lady it doesn't look like a pic
so I need to make sure if this thing looks like a pic
so I'm gonna open up an Internet browser and I'm gonna go to a website the
website's gonna be down in the description
but I'm going to go to preview dot
tiny URL dot com
and I've set up mister Papa
hyphen pic and
this is a really nice pic image that I've setup I've set up as a preview so
you're not going to
to be startled by anything this is going to take you to my Google Drive
wife specifically got a pic here it's a cute little pic
and its little because this is going to be part of my 600 by 600 for
so I'm gonna go to File
I'm going to go to download
and thus gonna download it to mine downloads folder
so I can click here to show all downloads or I can right click
and shoes show in folder and I'll see the pic he's right there
there's my beautiful pic
so what I want to do is I want to make sure that my pig
is on my label summer clothes these extra windows that I've open so I can
see my form
there's money not so picky label
I wanna at that picture that I just saved
to my label and it's gonna be one of these properties over here
so I'm gonna go up to my properties
Andrey here I see image right now there's no image in it
but affect click on to see the slip CC's more three dots
and when I click on those that's going to allow me to load
an image so this is a local resources on my hard drive
my clique that and I'm gonna select import
and I wanna go to that download folder that I had here now
you can do that by clicking on your downloads that's probably where it's
been saved
but I'm gonna choose the spigot image
am a click open
and so I C there is my pic and if I hit
okay that i'm gonna see my pic on this label
now my pic looks a little squished
so what I need to do is I need to change the signs that this label
so it matches my pic size is one of these properties
under way out right now the size is 100% calmer 23
I really wanna make it 64 and forty
8 these numbers are really nice for the computer because their powers
to the computer deals with information what's called
binary or based to notation
and having these nice round numbers round for the computer that is
is going to really help the computer to deal with it so I've set my
image to my file very close to the 64 by 48
so if I set my label 264 comma 48
I'm not to see very much distortion
so I sent my pic but if you look real close
I see the words label1 right here I
really don't wanna see those words I wanna see my pic
completely unblock by taxed so I need to take the text
of my label that's one of these properties over here
so I'm going to go over to taxed and see where label1 is currently the text on
their
and I'm going to backspace to completely get rid of it
and when I hit enter now the text is of my pig
my pic is a pretty pig uncovered by taxed
there's one last thing I want to do
the problem with sharp develops that has no idea what I'm going to be using this
stuff
for so said you wanna label here's a label
and ima call this label label1 I see over here in the properties that this
thing is called label1
but that's not really a good description a what's going on here
this is not just label1 this is Mike hick
in so what I'm going to do is go down to design
and change it from label1
to label
hick so that I know it's not just
any label this is my pics label this label
represents a pic the terror run around on my grass
so I've set up this label and this label represents my pic
so what I need to do is I need to set it up so that this label will move around
and that's our next step
in order to make this work I need to set up some type of timer
this is something that's going to make the computer program
go tech pic tick tick
and every time it hits one others tix that pic
is going to move that's what we need to do
and a timer is one of these tools that I see under Windows Forms
should be the very last one on my list IC timer
and just as before going to click and drag them into click on timer
in drag it onto my four nothing is
we normally see a pic we don't normally see a timer
a timer is normally something that tix in the background
and so I see it here in this kind have cream-colored
bar but if I run my program I'm not going to see it
all I'm gonna see is this beautiful Greenfield and a little pig running
around
so what I'm going to do is this is my timer
in the first thing I need to do is unable my timer
because right now my timer is not enable it's not gonna be doing that
kick kick kick that I needed to and it's one of the properties that I see over
here I see
my enable property currently is false so I can click on it
and i cant use the drop down menu to change true
and now when I run this program this program is
inside going to be doing take tick tick
not an audible sound but just some signal that the computer is going to
receive
to tell the pig to do something
and this is where we're gonna tell the pic what to do I'm gonna go down to
where this timer is
and I'm going to double click on it so this is where we're actually going to
write some code
in this code is what's going to happen every
time the timer tix
first thing they need to do is I need to figure out
where my knee pig here's may remember if I click on my design
my pic has a location buy click on my pic I see the current location on my
biggest
233 232 I've got in X&Y coordinate
so what I need to do is a need to figure out where those things are
and when I want to move my pic I'm gonna change that
axe and change that why so I'm gonna go to my software
may go to my software and I'm going to change the axe
and change the Y first thing I need to do is a need to get
the axe and why location
have my pic notice that I type that slash slash in front
this is something called a comment and the whole purpose of a comment
is to leave notes to the programmer he's the one who's currently writing the
software
or other programs we're going to look at the software
book comment is going to be completely ignored by the computer the computer
does not even
look at that comment and it turns a green so that I know
it's being ignored by the computer notice there's some
other comments that have already been put in here by default
that sharp developer 10 automatically but what I need to do
is I need to add some code here I need to get the X&Y coordinates my pic
and I need to store them in variables
now variables our little boxes that the computer keeps and memory
to put a little name on the outside the box and stores a value
inside the box so I get to choose
what the names on the outside of the boxes are so I'm gonna create a variable
called
axe now this variable X that I'm creating
is going to hold a number and integer
and the way I tell the computer that it's a perfect set with
I N T so I got I N T space axe
and I'm going to a sign it
the value my pic never member
I gave that label a very special name I said
label heck that was the name
up by pigs label and I wanna access its property
in order to access its property I'm gonna head
a topped and I wanna access its location
and remember that a location has an x-coordinate
and a white court met so I want to access the locations
X property someone to do dot
X
and in computer science this is something called
object oriented programming the whole idea is that this
object my label has properties has
attributes and has code that it can run and I want to
access what it happens one other properties that my pic has
is a location soda access said I'm gonna put the dot prefix here
to say that I'm accessing the pigs location
and that location hasn't X&Y quartet
someone hit the dot again to access that X quartet
and every line of code that I
type every command I tell the computer to do
past and with a semicolon which is one other
things about computer programming so I've done this for the
ex Corde I wanna do the same thing for the white cord that someone had
enter to go to the next line I'm gonna create another box
its gonna hold an integer and the name in my box is going to be
why and I want to assign it
from my label label pig
I want to get its location so dot location
and I want to access the y coordinate so dot
why so I've gotten the X&Y location
from my pic so I can manipulate it later
I can add 10 or subtract 10 to make the pic move right or left
or make the pic move up or down so that's the first thing that I D
do figure or my starting location is the second thing for me to do
is I need to determine where's my pic gotta go
I need to come up with a random number now therefore directions that my pic it
go my pic ago north
or South or East or west and because there's four possibilities
I need to get a number that has four possibilities
now the first thing I have to do is have to tow my computer to create
a random number generator now just like
if I wanted in integer I used int if I want a random number generator
I'm gonna put random an
this is the variable type
but I'm gonna create a generator and I need to assign it something
so I'm going to assign it and I want the computer to just give me a new
random number generator so new random so
just as I did before I'm declaring a variable
I'm telling type up box and the name
have the box I'm assigning a value
and the value in this case is a random number generator
so what I've done here is i've
created a random number
generator and what I need to do now
is a need to ask that random number generator for
a random number so I need to get a random number
someone asked my generator
to give me a random number but I need to store that random numbers on the college
int
direction and I'm going to assign it
the value from my random number generator Simon asked my generator
to give me the next number now I'm gonna tell it the next number from 0
24 in reality what's going to happen
is my random number generators going to give me a zero
or e1 or 82 or three its gonna give me numbers from 0
up to but not including for
so I've declared a variable called
direction and have asked my random number generator
to generate a number for me
so at this point I have a direction that it's going to go
now my directions right now are zero or one
or two or three they're not very hopeful directions
sorting it stole the computer next is what does 0
mean and so I need to actually
move my pic
and what I'm going to do is something called the
if command if something
his troops in other words if my direction is zero that I want my pic to
move
a certain way if my direction is one but I want my pic to move
a certain way if my direction is to that I want my pic to move a certain way
and so forth so I'm gonna say here
and I'm going to open print the seas because I need to know if something is
either true or false
and inside the print sees I'm gonna put my expression
if direction is equal to
0 and I want to draw attention to this because
when I was assigning when I want to actually change a value
I used a single equals site and notice I use the word
assign I said X gets the location or the generator
gets a new random object
but if I'm testing for equality I wanna know is direction
really and truly equal to 0 that really and truly is why I've got to equal signs
there
I use a single equal sign for assignment and I use
to equal signs to test if things are really equal
and if the direction is equal to 0
then I want my pic to do something
I want to move my pig a certain direction
so I'm gonna say label pigged out location
gets I wanna move it 21 new
point so I'm gonna tell it make and new
point and this new point is going happen X court met
in a white court so what I'm going to do is a minute take the ex cornuta varity
had
but I'm going to make why make my pic move
up 10 pixels so I'm going to increase the white
quarter net by 10
now in reality moving up actually
decreases because the Y actually increases from the top ago
rose zero then right below that rwandan right below that wrote to you
row 3 row for and so forth so this plus 10 is actually going to make my pig
moved South
if my direction is
equal to one
then I'm going to say label he start
location is assigned
and new point X comma
why minus 10
so this is going to make my pic move
North and I'm gonna do this for my other directions
remember that my random number generator has created a next
number between 0 and four in other words 0
one to or 3 so
I've got direction 0 move the pic 1 Way
direction is one move the pick a different way this is moving it up and
down based on the y coordinate
so my other two situations work if
the direction is equal to to
then label pig dot location
gets new point
we're going to take X plus 10 and why
notice here I'm just changing the x-coordinate just making it move to the
right
10 units 10 pixels thus going to make my pic move
East and then if the direction
equals 3 then label
pay dart location gets new
point X minus 10
why and this makes my pic move
West so this is what I've done so far with my pic
I figured out where was my pic
I found the X&Y coordinates a where my pic was
I created a random number generator and I asked for a random number
between 0 and force r0
or one or two or three
and then I said if the Directioners 0
move the pig South the direction is one move the pig North
if the directions to move the pic East if the directions
3 move the pic West so this takes care of my pics
movement and now in each do one final thing
this is every time the timer text this happens
well if my pic runs of the screen
then I want to stop by timer
so what I need to do is a need *** the computer
has my pic moved
of the screen
so what I'm going to do as I'm going to use in Figure
so here X is
last then 0 because I've access lists and 0
I'm off the left side of my screen or
now what I've done here's my views the vertical line some bullets
right below the backspace assemble it shift backslash
and then I'm going to say X is greater than
600 sis let me test for one or the other
soft X is less than 0 or axes
greater than 600 then my pics moved of the left to right into the screen
I also need to check if those pic has moved
of the top of the screen if Y is less than 0
or if Y is greater than 600
so what I've done is a check to see if my pics moved
too far left or too far right
or too far up
or too far down
and if this is true then I need to do a couple of things
and because I need to do a couple of things might if needs a little bit a
backup
and so we have these braces that we use
to tell whenever we have an if statement that needs to do more than one task
I need braces notice here if was only doing one task so it didn't need braces
but here my *** gonna do two things the first thing I'm going to do
is tell my timer to stop
so timer1 dot enabled
gets falls that's the first thing I'm going to do
because it might be cuz of the screen I don't want the program ticking anymore
and the second thing that I need to do is sign in to let the user know
that they've lost the game some going to do this in a message box I'm going to
tighten
message box dont show and insight here minute but in quotations
the pig escaped
so I got quotations and inside parentheses I got
the pig escaped
so a lot of stuff is happening every tech
now the way that we've got our tech setup if I go back to my design
the way that I got my text set up
i click on timer norris et sticking every 100
milliseconds I can change this number if I wanted to go
faster or slower I want to go faster I'm gonna make this number smaller
so there's going to be ticks every 50 milliseconds for ticks every
seventy five milliseconds and if I wanted to go slower than I'm gonna make
this a bigger number
I make this a ticket for two hundred milliseconds or take every 250
milliseconds
so that is
my timer notice in our timer code
we're doing for thinks the first thing I'm doing is a finding out where my pic
currently is the second thing that I'm doing
is I'm choosing a random direction the third thing that I'm doing
is I'm actually physically moving my pic by changing its location
i'm saying its location get a new point somewhere on my for
and in the fourth thing that I'm doing
is I'm checking to see if I've lost the game and if I've lost the game
the lime stopping the timer and letting the user now that the pic
escaped well that's kind of a downer
so let's talk about what happens if we win
going back to our Design I think that if I'm
able to click on my pic then I'm 1
so what I'm going to do is just like we double clicked on timer to add code for
our timer
working a double click on our label add code for a label
so this is actually gonna set up what happens
when we click the pic and if we click the pig
we've won soul if we've won the game there's two things that I want to do
one is if I've cut my pic my pic really should stop moving
and the timers what's making my pic move
so I need to stop the timer so the first thing I'm going to do is say timer1
doc enabled gets
balls and the second thing that I want to do
is I wanna let the user know that they've won the game so I'm gonna say
message box
top show you
caught the pic
so every time that the pic is clicked which should only happen once a game
I'm telling him two things one is I'm stopping the time
because Israel email nor reason for my pick to run around
and the second thing that I'm doing is I'm letting them know that they won the
game
you called the pic so
we've got all this action going on here I've got my design
this form that I created
notice that on my form a change the appearance tool I'm
a change the text to catch the pig and those are things that I
physically see on my for I had a label
and this label now has image
where's my sammich there's my image right here
it's an image that I've downloaded from the website description has the link
and it's got a location
which is very important to us this location is actually
how we track the pig and how we see if we've caught the pic
and it also has a size I created a timer object in this
timer object is really keeping track up a lot of stuff this
timer is really the mechanism that allows my program to run
because every time this timer ticks every 100 milliseconds
it's doing for things it's finding out where the pig ears
its choosing a place for the pic to go
it physically moves the pic and then it says
mmm is the game over did the pig escape
and that's where the timers doing the mechanism up the game
are win condition is by double clicking on the pic
and 18 double click on the pic I get this code
where the timer has stopped handle a message pops up that says
you got the pic now
it is very rare that when you run the program for the first time
they are going to have no mistakes and
I may have a few mistakes up here but I see a little play button right here the
small green triangle
and this is going to run my program now is he saw
earlier had your message box that popped up from my
anti-virus software and thus a new execute all file that my computers never
seen before because I just created
and so when I run it it's actually going to check that execute the file you see a
pop-up here
so in about 15 seconds or so will see our
running around little pic
no problems found so the application store in a few seconds and Nazi
and there's my little pic now remember that I'm only moving the pic
about 10 blocks at the time so my pic is moving around
very little and there's two ways that I can fix this
when I go ahead and click on the pic so I can't see that I did catch the pic
noticed the pic stops moving
as I mention there's two ways to fix this one way that I can fix this
is in this code for my timer instead of just moving it
10 pixels I can move it a little bit more
I can move it say 30 pixels but I need to make sure a change it
in all love these spots
now when I run it and by the way
now you see my pic is running around quite a bit more
it's moving more on each tech and
hopefully we'll see my pic run off the field in just a bit
one pic you can do it
can also see it's a lot harder for me to catch the pic
because it's moving around so much but another thing that i could do
let me go in close this is under my timer
I click on design and click on timer I can change this
interval to a smaller number a change the central to
say fifty and then I try and run it
that's gonna make my pic move twice as fast as you can see my pics moving quite
fast he's getting kinda close the edge
oh the pic escaped darn
let's try one last time to catch our pic
OPIC escaped again well
you can make this pic is faster slow as you want to buy changing
either those two locations just be careful if you change polls because
then your pic might be too fast for him nothing like a greased pig to escape
from you
but I hope you've enjoyed building this little game I've certainly enjoyed
helping you to create it
so let's talk about what we've learned from here
we've learned something about object-oriented programming
the ideas that we can build objects have these
objects interact with other objects and we had two main types have
objects in the program that we made we had form objects the actual
objects that we could physically see such as the window
or the label or objects that interacted with those things such as climbers these
are actually form objects objects that we got by placing
items directly onto the form and we also have
programming objects objects that we had to create through
hoed we had to physically create are random number generator
using the random object and we had to create
individual locations for our label to move to you
using the point object but
all love these are objects that we created objects that
interacted with each other to get the game to work the way the we want it
we also dealt with
objects having some properties to them some things that
made them useful in there were two main properties that we had
objects had attributes in other words there was data
about the objects that we had to get
and we had to change so for example the location
up a label where that pig years
we had to figure out its X&Y coordinates depending on what a random number
generator got us we had to change that X&Y location
and then we had to change its attributes so that my
label actually moved we also were able to change the background color
for our main form in order to make it look like that beautiful green grass
and we also had the enabled attribute the enabled actually we had to set at
the very beginning in order to get our time a two-run
but we also used it when our game was over popular because
the player one or because the player lost
so objects have these attributes but the
also have methods methods are little snippets of code to get
run under certain situations so for example
example for timer we have the timer tick
method they meant that every time are timer had a
tech it would do the code within the tech
so it would find our X&Y coordinate they would create a random number
it would move our pig appropriately and it would check to see if ur pic had
moved outta bounds
we also had the next method for random number generator
and the sole purpose of this was for the computer to give us a random number
which we then used to determine where a pic was going to head
and we also had the label pig clicked
method which allowed us to figure out okay when
is the pig actually being clicked because that was our winning
scenario that was our end-game scenario so when the label was clicked
we had to set are timer to be
no longer enabled and we had to send a message to the user letting them know
that they won the game
so these are some other methods that we talked about
and methods are a very important part up computer programming
we are often hear them called the functions or procedures in this language
and other languages and we had to user-defined methods these were methods
that we had to come work
with on the fly because the computer had no idea what to do
when the timer text the computer had no idea what to do
when the pic was clicked and so when we have these situations
the code was completely blank use a blank slate for us to put in what we
wanted to happen
to our pig when I got clicked to our timer when the timer tipped
and we assigned these methods to a particular
object through something called listeners and that's simple active
double clicking on the form object when we double clicked on the timer
or when we double clicked on the label this is what allowed us to connect
are timer with our timer tick method an hour
pig label with our label pig click method
it was this double clicking that allowed us to access the code
but the actor double-clicking also created a listener
for that label or listener for that timer
so that these objects and these methods were connected
so we have these user-defined methods
and we have these objects to interact with them but we also had some more
lower level things going on sometimes I didn't need an entire
object sometimes I just needed a number
and that was where variables came in so I had to create some variables in this
program I the variable called
axe had a variable called why these two variables kept track
where the pig was in a particular location
and then also I had mine integer direction
which was the random number generators selected number either zero or one or
two or three
determine if we're going to go north or south or east or west
but in reality timer1 and label paper also variables
these just happened to be variables that hold objects
another is the shizz happened to be instances a bar
classes of objects an instance up a timer
which we call timer 1 an instance up a label
which we called label pick for our purposes
the other thing that was really important was the idea of conditional
statements the ideas that we had some code that was only run
under Select conditions and the main way that we did that was with the
if statement NR if statement always had a parentheses that followed
and inside the Sprint to seize was a boolean expression
an expression that would either be true or balls
and inside these parentheses we tested for equality
to see if our random number generator direction variable
was equal to a0 or a1 or two or three
but we also check to see if our pic was in balance
we check to see if the location at the pig was between our 0 to 600 for axe
and r0 to 600 for what so we had to check to see if the location was less
than a certain value
or greater than a certain value and the code that follows is
only run under those select certain conditions so
only if the direction value was 0
was our pig going to move in that direction
and only if our pic was out a bath homes
was the timer going to be disabled and we're going to receive a little mention
it said
you lost the game so these are all different programming
aspects that we've talked about in this game and
we certainly could go into a lot more detail if we had more than just an hour
time
but I do appreciate you spending some time with us
learning some code I hope that this motivates you to
experiment because this is how truly
people learn is by experimenting with code
changing the variables just as we did we change to
take the variation in the tech from one hundred milliseconds 250 milliseconds to
make our pig move faster
or how we also change the amount that we added or subtracted to Wrexham
y values from 10 to 20 to make our pig mover farther distance
met allowed us to change the difficulty over the game
so I do appreciate you watching this video I hope you've learned something
I if you have any questions or comments please go ahead and leave them down
below
I'm I do appreciate it if you want more computer programming stuff please visit
my website missed the part I dot com
or visit my youtube channel edges missed par oooh us
I appreciate you watching have a great day