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

Corners

As we established in our last video: we need to know what our corners are and keep track of them from now on. In this video we start the long task into knowing always what corners have been created. In this video we start with collecting the points we created as soon as we start the game and store them into a Vector.

Video Transcript

00:00Alright, so the next step now that we got our basic understanding of what we're planning
00:04on doing is we should probably visit our code and start changing things.
00:08So first of all, if I go back into my main class, and I just want to go back way to the
00:13beginning where we're actually creating the frame where currently we're creating the frame
00:16and we're not storing the dot information, which is really, really critical for us.
00:21To store this dot information, it probably makes sense to start changing names because
00:25vpoints is not enough now, because vpoints, we need another vector with points, so calling
00:31a vpoints is probably a bad idea, so I'm just going to copy that name and I'm going to search
00:35using the find and replace command, which I use my command f, or you could find it right
00:41here.
00:42And I'm going to change vpoints, and let's just call it vpath, because that's the path
00:45of the active thing that's going on.
00:48So replace all, now we have a nice name for our points, and we don't have to worry about
00:52points anymore having a generic name.
00:55The next step is we want to create a variable that is going to be our solid corner, so we
00:59could call this corners, vcorners, which is going to have the exact same definition
01:05as our points, it's going to have the same type, it's going to be a vector, which is
01:10a type of array that only stores specific types of information, which are points in
01:15our scenario, because we define it to only store points, it's exactly like an array,
01:18it's only an array that could only store points.
01:21Alright, so we have our vcorners.
01:24The next step is actually when we're, after we add the information and create this rectangle,
01:30we have to actually start storing the dots that were created.
01:33And to do that in our create frame, we want to add a few lines here.
01:36Basically, we want to create a new vector point, so a new vector dot point, we want
01:46to make sure that we have our new vector point.
01:48And then we could just start pushing in points, so we could push in, the first
01:54dot that we want to take is our beginning spot.
01:56And what is our beginning point?
01:58Our beginning point is probably zero, zero.
02:01Even though it's not exactly zero, it's not exactly zero, zero, because if we look,
02:05and let me just comment this out for a second, if we look at our application,
02:08we'll see that we have this blue area that's safe already, we got here a little
02:11bit of space here, so we have to make sure that we really put the right point.
02:16So to do that, what we're going to have to do is probably be a little bit smarter
02:20with our logic, but instead of being smarter in advance, what we're going to do
02:25is we're first going to let it happen.
02:27We know that we might have issues as we're touching corners, and we're going
02:31to ignore it for now, and then when we hit those issues, we're going to visit
02:34back and remember that, oh, OK, we might have some sort of calculation issues
02:38where things won't match 100%.
02:40And that's fine, because we know it now as we're building it out.
02:43So first of all, our first point is our zero, zero, which is our beginning point,
02:47which is our top corner, our top corner.
02:50Our next corner is going to be our width corner.
02:53So to do that, we're going to create another, oh, we want to make sure
02:56that it's a point, so point, new point, zero, zero, not just push to that.
03:01And we want to make sure that we have your four points.
03:03So first point was at zero, zero.
03:05Second point would be probably our stage, stage, width,
03:09because that's the size of our rectangle.
03:13And the next one is going to be our stage, width, stage, height,
03:17which is going to give us the bottom left point.
03:28And our last point is zero and height, making sure we get our bottom left corner
03:33as well.
03:35All right, so we set up our new push.
03:37We set up our V corners.
03:38Now we have our beginning spot as great.

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!