So you can see something, and here we have it: weve got two balls bouncing around theres, one green ones already escaped and its into the other box. One ball two now lets run this and see its nearly there lets switch over. We have a tunnel being drawn with this code and the tunnel is suitably sized that it does link the two boxes together and then we have location, detecting code for ball, one location, detecting code for ball, two that helps us work out where we are the bounds Of the box that were in and then we have our weve just hit, the wall lets reverse direction in whatever axis of whatever wall weve hit ball. So summarize, the code again weve got two boxes getting drawn with this code. Therefore, sometimes you see the bottle its radius coming through the wall, but it still bounces and, more importantly, until i get my head around the alloying escape code, when the ball does have a radius. It does mean when it bounces off a wall, its the center of the ball of bounces. Now there is a side effect of not having a radius of the ball. But we are allowing jailbreak so thats when the logic starts to fall apart until i decided try it without having a radius. Theres, a big assumption were making in this code and the assumption is theres no jailbreaks. And unfortunately, i still havent got my head around exactly how to do that: sort of adding and subtracting when its moving from one box to another, because the code is all assumed. What i want to do, i want it to escape and thats when things start getting difficult, because, depending upon whether what the direction of the ball is, when you take into account the radius, you need to add it or subtract it from whatever youre doing. But what i found was that all this code is effectively trying to keep the ball from escaping a box now to get into another box its just effectively. Actually the ball did have one, because i had to make it a certain size to make it so that we could see it. Now why have i talked about this radius so much yet the ball doesnt have one well. One starts at the bottom, and theyve got a connecting tunnel and they can move between them. I do the same for both two, so weve got two balls each moving independently. So when it goes there, we already know where it is and its in bounds, wherever whatever we worked out, bounds to be, and then this is simply the the perimeter finding code which reverses the direction of the ball again im ignoring radius.įor the moment very important. Next thing we do is we want to move the ball, so weve already worked out where its going to be going to because thats what this is doing, its working out where the ball is going to go to. Instead note these things we will get to that in a moment. Two extreme code is just talking about ball. What i do is i work out where ball, one is: is it still in box one? Is it actually in in the box two or is it in the tunnel now, depending on where i work it out and the working out is simply where is it compared to the perimeter of the shape that its supposed to be in now, depending where i work It out, i set a single bounds, basically making it equal to arena one arena two or the tunnel depending upon where i find ball one to be. What we need to know is where the ball is so this case its ball, one which starts in box one. What are we doing? Well, weve got two boxes and we want a ball to move between them. I will get to that in a minute, because this is a cheat i had to cheat now. They have to have a joint perimeter where they share basically a wall, in my case, its a wall of infinite thinness theres, no wall, really its just a point in space. You will see it in a minute, its very important that its all parameterized, because the size of the tunnel has to be so that it actually touches the two boxes or cant have a space between them. ![]() So this is the box, the box code and its what we saw last week, its uh ive only changed it to well height width and depth was started to confuse me so ive converted it all to x, y and z, made far more sense, so thats that Weve got a very similar function, drawing this tunnel and effectively its a box without a top and a bottom, because the top and bottom is going to be the bottom and top of the other two boxes. In its own right, so ive got a top box and a bottom box and a box linking the boxes excellent. So what have i done this week? Well, i still have boxes and i still have moving marbles, but what i am doing is im having two boxes and im linking them with effectively another box, but im calling it a tunnel to emphasize that its not a box in its own right with a marble. Now i did that last week, so this week, ive done something different lets have a look at some code. ![]() ![]() With python series, we had to model a moving marble in a room using parameters.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |