02Geek HTML5 and JavaScript, TypeScript, React, Flash, ActionScript online School
Previous VideoNext Video

Every Line Has an End

Well actually that really isn't true... not every line has an end but our getLine function has an end as we finally get the last things we where missing to get it to be functional.

Video Transcript

00:00So right now we've been tracing. Tracing is not good enough.
00:03What we want to do is we want to kind of take the information that we have.
00:07We want to store it into an object. So I'm going to create here a nice little line.
00:11Far O line, which is an object.
00:14And that object is really just going to contain this information.
00:17So it's going to contain our direction, our opposite direction.
00:20So that way we could play with the information.
00:24And it's also going to contain the starting point and the ending point.
00:29So first of all, we're going to store our direction, which is going to be that deer.
00:33And we're going to store our opposite direction, which is going to be our OPZ.
00:38Even though we probably know what it is, it's good that we could store it.
00:42Then we want to have point A and point B, which is basically just going to be one of our points
00:47between the two dots that we're going to be at, between those two and three.
00:50All right, so first of all, we got those two dots that worked for us.
00:54Next step is, now that we're in this if statement where we actually know what our range is,
01:00we could add to our line a point A, which is I.
01:03And we could add to our O line a point B, which is I plus one.
01:10All right, so we're storing more information. Now we're getting even closer.
01:15Now at this stage, because we already got the information we need,
01:18we could already return our value. We want to return that line.
01:23What that would do, it's basically we're breaking out of the for loop.
01:26Not only are we breaking out, we're returning.
01:28So as soon as we've got what we wanted, bam, we're out.
01:31Only the last thing that's left is to make sure that our get line is returning really an object.
01:37And we could go back to our get line, our first line.
01:41We could go back to that variable that we created a really long time ago, O line,
01:47and save that information so we're ready for round two.
01:50And here we go, get line.
01:53We just saved ourselves our initial line, and we're ready to call line two,
01:58which is basically going to happen inside of our add save to bg,
02:02because that's where we want to add those extra points that we've been working on so hard to create.

Ready to Level Up Your Skills?

Join thousands of learners on 02GEEK and start your journey to becoming a coding expert today!

Enroll Now for Free!