Monday 21 July 2008

Updated Mr Ball!!

Now, if you're thinking, why am I still updating it after 3 months from it's last update already? It's kinda old news already isn't it? Well, old news to you lah. But to me, Mr Ball's the product of my 1.5 months of planning and programming. I'm not just gonna leave it there and catch dust inside my computer. It's one of my biggest achievements in Game Maker. That's the first ever 3D game I have made, so I wouldn't just let it go rot away in my Hard Disk. Haha.

Anyway, I was bored just now, and played a bit of Mr Ball to entertain myself. But I found 1 very bad flaw in Level 6, the Spear Diamond thingie. If you keep shooting it, even if it has reached its Counter-Attack Threshold, it won't counter you until it stops receiving hits from your water gun. That is not good, since it'll make the level end incredibly fast. Because of that, I just tweaked it, so, regardless of how long you can manage to keep shooting him, as long as the Counter Attack Threshold bar is filled up, it'll counter you. If the boss's HP is like 1000+ HP, I wouldn't even care about this problem, but this boss only has like 500HP, the lowest amount of HP for a boss in this game.

I got so bored, I decided to record my battle with that boss, and here it is!!



Now, let's talk Maths!! I just got nothing better to do anyway. OK, this math-mojo is actually related to the video above. How? Okay, if you've watched the video, and if you played other games, a lot of them has objects going around another object in a circle (Circular motion around an object in err... shorter terms).

If you hate maths, i suggest that you look away now. This is just to let time pass by me. So, here goes:

Now, this is just a method on how to make things move in a circle in a game.



As you can see, that's a circle, right? Cool isn't it? I drew that in Microsoft Paint!! Haha. Yeah, I know, anyone can do better than that!! So, other than a circle, you should also be able to see the radius, marked "r". I hope you know trigonometry, because, I'm gonna go into trigs soon.

Right, the centre of the circle represents the position of Object A in a Cartesian Plane and the circle represents the series of points that Object B will move on. How do we make Object B move along those points on the circle? Haha, this is where Trigonometry comes in to play.

First, draw a line from the centre (O) to a point on a circle (P). When that line (OP) meets the circle, draw another line from the intersection point down to the radius, such that it intersects the radius perpendicularly, which will represent the y-coordinate of Point P relative to O. This is easier shown in graphics. Bring out Microsoft Paint again!!




There you go!! You can also see how the x-thingie is formed. So, OP is the same as r because OP is also the radius. Now, the angle subtended at the centre is abbreviated a. Using trigonometry, we know that:



Okay, now, a is the direction of Point P from the centre. Yup, the direction. How do we find the x and y values of the Point P given the direction from centre O. Remember, a direction of 0° is pointing to the right. What do I mean by that? Erm... shit, how do I explain this?? Anyway, just keep in mind, 0° is right. Then, as the angle goes higher, the rotating point goes counter-clockwise around the centre O. So, 90° will be at the top, 180° will be to the left and 270° will be pointing towards the bottom.

Yeah, so, we have the centre O with points (xo, yo). We are also given an angle a, which is the direction of P from O and the radius. The radius is just the distance of point P from O. To find Point P's coordinates relative to O, we use the above trigonometric formulas.

The coordinates of Point P, relative to O, given the direction and distance of that point from O can be calculated using:
xp=r cos a
yp=r sin a

Now, keep in mind that those are coordinates of P relative to O. To convert xp and yp into "world" coordinates, ie, coordinates that are relative to the origin of the Cartesian plane (0,0), you must add both coordinates with the coordinates of point O.

So, the x-value of Point P on the Cartesian Plane is: x=xo+r cos a
and the y value of Point P on the Cartesian Plane is: y=yo+r sin a

So, that's some math to ponder your brain!!

1 comments:

Anonymous said...

um......where's d defination4 a straight line?