 Hey everyone, so I'm just going to very briefly go over question 4 and 5 because we ran out of time to go into too much detail in the class, so I'll just quickly go over it. So question 4, we introduce variables such as mouse x and mouse y. So mouse x and mouse y are inbuilt variables inside processing which track the current position of your mouse in the processing window. So you can have a look at it at the processing.org slash reference page if you want more information but I'll just show you quickly. And I'm going to print my mouse x location, so you guys can have a look, my mouse y screen a bit bigger as well. So when I run this here we'll see inside the console I've got my mouse x and mouse y current position so I'm off the processing window at the moment so it's 0 0 and as soon as I enter this corner here I should be around 0 0 so I've got 6 and 8 for mouse x and mouse y so that's to be expected because that's where it would lie on the x and y axis and if I increase my position to the right hand side then we're increasing along the x axis so my mouse x value should increase which it is. So increase over the y so this can be really handy if you want to create a processing during that is dependent on the location of the mouse which is what a question 4 is asking you to do. So question 4 asks you to use the system variables mouse x and mouse y to write a processing program that draws a line from the origin 0 0 to the location of the mouse whenever the mouse is pressed so we've introduced mouse x and mouse y but we've also introduced this other element where the lines should draw every time we click the mouse so there's two ways of doing this I'll show you both firstly I'll show you so this introduces conditionals which we talk about next week but say if you were to say if the mouse is pressed this might also be helpful for the assignment instead of mouse pressed looking at key pressed so if the mouse is pressed then I want to draw a line from the origin to the mouse x mouse y position so for the people that had a go at this question I saw a lot of you did it this way but I'll show you some errors that come up with that so here I'm going to click my mouse and yeah that works fine we've got a line from 0 0 to the mouse x mouse y position but one bug that we'll find is that when I click down at this point and I drag my mouse lots more lines start to follow it and that's because we've got this condition inside draw and we know that draw keeps looping around so what's happening is every time we loop through draw it checks the condition says is the mouse pressed yes okay draw another line if we keep holding down our mouse the next time that draw loops it says okay is the mouse still pressed yes it's still pressed okay I'll draw another line so when you drag it that's just like this condition looping around many many times and it's drawing many many lines which is okay if that's the effect that you want but for this question that isn't the effect we want we want it to draw just a single line when the mouse is pressed so what I'm going to introduce is the mouse pressed function which again you can see on processing org slash reference and I'll show you the buggy way of doing it first so we've got our void mouse pressed function we draw a line from mouse X to mouse Y and this isn't going to work so in theory this should be working but the reason why it isn't is that we're not looking out for this event so if you remember from week two notes which is the conversation between the compiler and processing and the user what happens that setup runs once and then draw runs and draw loops forever but because there's no draw function here we're just running setup and then processing goes okay there's no more code to run I'm done and that doesn't look out for any more events such as the mouse pressed event or it wouldn't look out for the key pressed event as well so even if our draw function is empty in this situation it's important to have it here because it's going to keep looping around so processing is still active and so it's listening out to see if any of these events are triggered so now because it's still looping around when I do press the mouse processing is listening and it will run my code so now that's working fine and if I click and drag so I'm going to click and drag it doesn't do anything because it's just looking for that single event okay so it's really important to understand the different effects that a condition versus a mouse pressed function will have so that's how you do question four and we have a look at question five we've got practicing with mouse events so so this continues on maybe I'll cut