I've been asked many times
"Do games need add math?"
Actually, some of my friends wanna try learning programming. So, yeah, I gave them the link to Microsoft's Visual Studio Express programs, if they are really interested in it. Then suddenly, they ask that question.
The answer, of course would be yes. You may not know it when you play games like DOTA, or Red Alert 3 or Maple, but behind the scenes, a lot of Math is going on. Mathematic is the driving force behind computer games.
There are simple math, like deducting the player's HP, and super-complicated math like path finding (for AI).
And in 3D games, selecting a unit by clicking on them is also quite complicated. Sure, you can just click on the screen, but in 3D environment, the game must perform a lot of calculations just to get what object you're trying to click.
So, remember, the next time you play computer games, don't ever forget the efforts the game developers had to put in to give you the best entertaining experience.
If you want to know an example of how math is applied in a game, you can check out the Circle-Line Intersection. How is that helpful in the gaming world? Well, let's say you have a circular object, and you fired a bullet at it. Assuming that the bullet will travel in a straight line, the question is, will the bullet hit the object? Yeah, so, as you can see, game development isn't just "code typing", it is also a gigantic mathematical problem, that you have to solve. Well, sort of. Ok, fine, my analogy isn't that good, but you get the idea, right?
But don't let that bring your hopes down on becoming a professional game developer. It's a very fun thing to do, seeing people play the game that you made. Some more, you can see them and laugh as they suffer from the hard levels you give them. Playing computer games is a fun hobby, but creating them is even more fun. I mean, you are like a God, planning what you want to do in your very own universe, and controlling everything. You want the player to suffer, well, why not fill the whole world with boiling hot lava? Ok, that'll just be plain evil. Anyway, all I want to say is, creativity is another important aspect in creating a game. Go wild! It's your world after all.
So, if you aspire to be a pro game programmer, I wish you Ganbatte! Trust me, game programming is fun, if you have the passion for it.
Saturday, 28 February 2009
Thursday, 26 February 2009
Triangle, 3 angles of despair
Oh, sorry for the weird title. Anyway, the other day when I was walking back home with David Mosiun after the can rings hunt, he suggested to me about making the triangle a little bit more complicated. Yeah, so I wondered, why not?
Here's what I've done.
WARNING: If you an uncontrollable hatred towards Maths, I suggest you should look away.
First, let's place a triangle in the cartesian plane:
Simple enough? It's important that the labels for the vertices are in clockwise order. I'm gonna use vectors here, since vectors are so fun! No trigonometry will be involved (well, except for Pythagoras' Theorem)
First, run a line from point C down to line AB so that it is perpendicular to line AB.
That line (h) will divide line AB into 2 sections, a and b. What I'm gonna do now is find a, b and h. From there, I will be able to get the area of the triangle. Remember, I'm gonna do this without the help of trigo, since I'm on a trigo-hiatus. Hahaha.
We'll need the vector for line AB, so, it'll be
A-B.
Then, we'll need to normalize it.
W=(A-B)/(|A-B|)
Right, now, that'll be called W. To get the length of section a, we're gonna have to project line AC onto W. That's where dot product comes in handy. Because dot products can give negative numbers, which we don't really need, let's get the absolute value of it.
a=|(A-C) ּ W|
Same goes for section b, instead, it'll involve line BC.
b=|(B-C) ּ W|
Now for h. Since we know b. And c is just equal to |B-C|, we can get h:
h=sqrt(c²-b²)
h=sqrt[ (|B-C|)² - ((B-C) ּ W)² ]
Actually, since we are squaring those numbers, the absolute value sign is actually quite redundant, since squares are always positive. That's why I took out the absolute value sign. But note that I didn't touch the modulus sign for B-C in the (|B-C|) because that sign there represents the magnitude of vector (B-C).
Now we have a,b and h, let's put them together:
Area of triangle=1/2 x base x height
so,
Area of triangle
=1/2 (a+b) h
=1/2 (|(A-C) ּ W| + |(B-C) ּ W|) sqrt[ (|B-C|)² - ((B-C) ּ W)² ]
or, if you like a better view of this equation:
where,
Ok, so there's your "area of triangle" being turned into a garbled mess! Now, I don't guarantee that the equation above will be 100% accurate. There may be errors in there which I may have overlooked. You won't be seeing that equation in your textbooks anytime soon, so don't worry too much about it and blah. It's just for fun.
Here's what I've done.
WARNING: If you an uncontrollable hatred towards Maths, I suggest you should look away.
First, let's place a triangle in the cartesian plane:
Simple enough? It's important that the labels for the vertices are in clockwise order. I'm gonna use vectors here, since vectors are so fun! No trigonometry will be involved (well, except for Pythagoras' Theorem)
First, run a line from point C down to line AB so that it is perpendicular to line AB.
That line (h) will divide line AB into 2 sections, a and b. What I'm gonna do now is find a, b and h. From there, I will be able to get the area of the triangle. Remember, I'm gonna do this without the help of trigo, since I'm on a trigo-hiatus. Hahaha.
We'll need the vector for line AB, so, it'll be
A-B.
Then, we'll need to normalize it.
W=(A-B)/(|A-B|)
Right, now, that'll be called W. To get the length of section a, we're gonna have to project line AC onto W. That's where dot product comes in handy. Because dot products can give negative numbers, which we don't really need, let's get the absolute value of it.
a=|(A-C) ּ W|
Same goes for section b, instead, it'll involve line BC.
b=|(B-C) ּ W|
Now for h. Since we know b. And c is just equal to |B-C|, we can get h:
h=sqrt(c²-b²)
h=sqrt[ (|B-C|)² - ((B-C) ּ W)² ]
Actually, since we are squaring those numbers, the absolute value sign is actually quite redundant, since squares are always positive. That's why I took out the absolute value sign. But note that I didn't touch the modulus sign for B-C in the (|B-C|) because that sign there represents the magnitude of vector (B-C).
Now we have a,b and h, let's put them together:
Area of triangle=1/2 x base x height
so,
Area of triangle
=1/2 (a+b) h
=1/2 (|(A-C) ּ W| + |(B-C) ּ W|) sqrt[ (|B-C|)² - ((B-C) ּ W)² ]
or, if you like a better view of this equation:
where,
Ok, so there's your "area of triangle" being turned into a garbled mess! Now, I don't guarantee that the equation above will be 100% accurate. There may be errors in there which I may have overlooked. You won't be seeing that equation in your textbooks anytime soon, so don't worry too much about it and blah. It's just for fun.
Labels:
math
Wednesday, 25 February 2009
Gayness!!
In The Sims series, your options for true love are not limited to only the opposite sex. Yesterday, I made a guy sim love my sim (who is also a guy).OMG! I MADE THEM KISS!!
Well, anyway, proposing to him was not very successful though. He rejected my sim a couple of times. That bastard!!
Anyway, I'm gonna play a bit more The Sims 2 now before I start doing my homework. Sigh... Form 4 life is tough.
Right, here are a few videos:
My sim (who is the guy. I'll call him Bilsa from now, since I named him Bilsa) wanted to leap into the girl's (Jan) arms, but because the chemistry between them isn't that good, the girl refused to hold him. Lol!
Then here, Bilsa is proposing to Jan, but due to poor chemistry, she declined it. Poor Bilsa.
So, off with Jan and on to a new girlfriend. Yeah, here, you can see Bilsa's second wife knocking over a snow man. Yes, they got married.
Well, anyway, proposing to him was not very successful though. He rejected my sim a couple of times. That bastard!!
Anyway, I'm gonna play a bit more The Sims 2 now before I start doing my homework. Sigh... Form 4 life is tough.
Right, here are a few videos:
My sim (who is the guy. I'll call him Bilsa from now, since I named him Bilsa) wanted to leap into the girl's (Jan) arms, but because the chemistry between them isn't that good, the girl refused to hold him. Lol!
Then here, Bilsa is proposing to Jan, but due to poor chemistry, she declined it. Poor Bilsa.
So, off with Jan and on to a new girlfriend. Yeah, here, you can see Bilsa's second wife knocking over a snow man. Yes, they got married.
Tuesday, 24 February 2009
...
Once I'm satisfied with learning gesture recognition, I shall get on to making Mr Ball. I think I might start making it next month or so.
But for now, I should continue Red Alert 3. hahaha!
But for now, I should continue Red Alert 3. hahaha!
Monday, 23 February 2009
The Sims 2!!
I'm replaying The Sims 2 again, and I've got to say, I'm too pro at managing my own shop already (in The Sims 2), hahaha! Ok, ok, I shouldn't be bragging.
It's freaking amusing, especially when I made my Sim to propose to another Sim. He got rejected twice, lol! Then the third time's the charm! Hahaha!
In the end, I made the couples argue with each other until they slap each other (lol!) and finally they broke up. I just hate managing two Sims. Hahaha! Me gonna play some more.
It's freaking amusing, especially when I made my Sim to propose to another Sim. He got rejected twice, lol! Then the third time's the charm! Hahaha!
In the end, I made the couples argue with each other until they slap each other (lol!) and finally they broke up. I just hate managing two Sims. Hahaha! Me gonna play some more.
Saturday, 21 February 2009
Blah!
Tracking an object is another difficult task to do. I tried to do that, but my program failed miserably. All because of bad lighting. See, my calculator is slightly reflective, because of the smooth surface. So, at some angle, it reflects a little more of the ambient light into the camera. Because of that, it picks up different colour values. If these values do not lie in the range of colour values that I want, the program will discard that particular pixel.
The usual colour space that we use everyday is the RGB (Red Green Blue) colour space. Different amount of these 3 colours can create a variety of colours. The bad thing is, different lighting can change these values significantly. Not good for my program, so I didn't use it. Instead, I tried with YCbCr colour space, which is actually quite a new thing for me. It's better than RGB actually. But then again, lighting 1, program 0.
I'm currently searching for better colour spaces, which aren't really influenced by lighting conditions.
The usual colour space that we use everyday is the RGB (Red Green Blue) colour space. Different amount of these 3 colours can create a variety of colours. The bad thing is, different lighting can change these values significantly. Not good for my program, so I didn't use it. Instead, I tried with YCbCr colour space, which is actually quite a new thing for me. It's better than RGB actually. But then again, lighting 1, program 0.
I'm currently searching for better colour spaces, which aren't really influenced by lighting conditions.
Friday, 20 February 2009
Yesh! Finally!
At last! I successfully connected to my webcam through programming! It wasn't an easy task. Right, now I have to think of a way to track objects. I'm not going to use my hand because it's kinda hard for my level.
Oh, Founders' Day!
Yup, today we (scouts and girl guides) celebrated Founders' Day in school. Founders' Day is actually the birthday of Lord Baden Powell and Olave Baden Powell (if I'm not mistaken). Unfortunately, 22 February (real Founders' Day) is a Sunday, so instead, we celebrated today.
Anyway, I think 2 weeks ago, yeah, that's it, 2 weeks ago, my uncle invited me to go to the National Science Centre with him, along with my cousin. I don't have the photos with me, but I do have a couple of photos of me posing in front of the camera, well, sort of.
As you can see, behind me is a big aquarium (in the second picture). This aquarium is situated at the entrance, before reaching the mock version of Malaysia's rainforest. Actually, the aquarium forms an archway, so you can see fish above your head as well. It's very cool.
Anyway, I think 2 weeks ago, yeah, that's it, 2 weeks ago, my uncle invited me to go to the National Science Centre with him, along with my cousin. I don't have the photos with me, but I do have a couple of photos of me posing in front of the camera, well, sort of.
As you can see, behind me is a big aquarium (in the second picture). This aquarium is situated at the entrance, before reaching the mock version of Malaysia's rainforest. Actually, the aquarium forms an archway, so you can see fish above your head as well. It's very cool.
Thursday, 19 February 2009
Looking for something??
It's hard enough to think up a good way to recognise gestures from moving objects or hands. Now, I need to look for a way to utilise the webcam in C#??? Wth? I always thought it was easy to look for it in the net, but most of it isn't what I wanted. Blah man!
In the end, I had to translate web cam capture program from one language to C#. That language is, fortunately, VB.NET, something that I have used a few years ago. Sigh...
Anyway, I'll continue "translating" later. Now, I wanna relax and continue Red Alert 3. Hahaha!
In the end, I had to translate web cam capture program from one language to C#. That language is, fortunately, VB.NET, something that I have used a few years ago. Sigh...
Anyway, I'll continue "translating" later. Now, I wanna relax and continue Red Alert 3. Hahaha!
Wednesday, 18 February 2009
Hand gesture recognition
That is one topic that I can never get tired of researching. I have always dreamed of controlling my computer by just moving my hand in front of the web cam. The thing is, I can never understand the Math behind it.
I have been doing quite a lot of googling and researching lately, but the sad thing is, all of these sites gave me all these crap. Do I need to know all those weird and scary looking formulas just to detect a hand? Come on, all I want is to extract the hand from the picture, that's all I want to know from now.
Image processing is not my favourite thing, but to recognise hand gestures, I'm gonna have to use it. Still, even if I can extract out the parts of the images with my skin colour, I still don't know how to identify which "skin pixels" belong to the hand, and which belong to the head, and so on. Sigh... anyway, I'm going back to googling some more.
I have been doing quite a lot of googling and researching lately, but the sad thing is, all of these sites gave me all these crap. Do I need to know all those weird and scary looking formulas just to detect a hand? Come on, all I want is to extract the hand from the picture, that's all I want to know from now.
Image processing is not my favourite thing, but to recognise hand gestures, I'm gonna have to use it. Still, even if I can extract out the parts of the images with my skin colour, I still don't know how to identify which "skin pixels" belong to the hand, and which belong to the head, and so on. Sigh... anyway, I'm going back to googling some more.
Tuesday, 17 February 2009
Eww!!
Today, there was a talk on drug addiction and the effects. Seriously, the pictures showing the dead people and people who were so skinny, like they never ever eaten in their lifetime, horrified me. Drugs are horrible stuff if abused. Why do people abuse drugs? Well, there can be many factors but the most common ones are influence from friends, the desire to try something new and to relief stress. But why do people look towards drugs as a way to relief stress? As you can see, some drugs have chemicals that can stimulate the body to produce hormones that give pleasure. And it is this "pleasure" that actually lifts up the mood.
Anyway, what I want to say is, don't ever abuse drugs. It's bad for health. Now, don't get too afraid of drugs. Drugs can be helpful too, under the supervision of a specialist, like a doctor or a physician for example. As long as you listen to your doctor, you should be fine.
But, but, like any other drugs, medicine still can cause problems if abused. And one more thing, even though you buy a medicine that has the word "Natural" printed on its label, you should still be cautious. Normally, manufacturers use nice names to entice the consumers to buy their products. Most of the time, a "Natural medicine" or "medicine made from natural sources like ... herbs and ..." doesn't mean it has no drugs. Remember that! It's still a medicine, and since it is a medicine, it is not good to abuse it.
Drugs, once you regret it, it may already be too late.
Monday, 16 February 2009
Omg! Bee Lee's dancing?
Did he knock himself in the head or something? No, he didn't. Thank god!
Anyway, dancing is fun. I suddenly had the interest to learn how to dance to High School Musical 2 All For One. Well, I'm no avid dancer, so it was quite a challenge, but it was fun! I'm glad they made a dance-along. God, I'm sweating now!! Really a good way to release stress and burn fat! Hahaha!
Anyway, my server is finally up and running, but I haven't registered a domain name yet. I might consider starting a whole new blog there. But I won't neglect this blog. Hahaha.
Sunday, 15 February 2009
Ooh? New logo?
So, what do you think of my new logo? I just only found out how to utilise the alpha-channel in PNG images. So, yeah, the glowy effect was made possible through transparency.
Anyway, now, I'm researching about detecting hand gestures. I've been interested in it ever since I know how to use the webcam through C#. Well, it's been a long time already, so I don't really know how to do it already.
Someday, I really want to control my comp just by moving my hand. I know there are already-made hand gesture recognition programs out there in the wild, but I prefer learning how to make it myself. I just want to know the secrets and mostly, the math.
Sigh... school starts again. Some more, 2 of my SPBT books had mysteriously disappeared. I wonder why. It's not in my house. I think someone in school took it. Well, someone in my class to be precise. Dang it, I need to get the ID for those two books, and then check everyone's books. Not going to be an easy task, but I have to do it. Sigh...
Saturday, 14 February 2009
No, no way!
I don't think I should continue Mr Ball 2. Just don't have the mood. I don't know why, but I suddenly lost my interest. I guess I miss programming in C#. Yeah, I'm going back to C# programming environment and leave Game Maker for the time being.
So, if you are expecting Mr Ball 2, I'm terribly sorry. Trust me, it's not that simple to create a game.
My friends are so sweet
Tomorrow is my birthday, but since tomorrow is a holiday, everyone wished me today. Wow, news about my birthday spreads fast. A lot of my friends were signing their wishes on a piece of very nice looking cardboard behind my back. Frankly, I was very surprised when I was presented the cardboard today. I'm also quite touched. Thanks guys! You guys are the best!
Well, anyway, I can't wait until 12am tonight. There's one mysterious envelope that Miu Yinn gave me and I'm not allowed to open it until the next day. And also, I'm awaiting the arrival of Li Ching's SMS. I've got to say, this is one of my best birthdays ever. I rarely take my birthdays seriously but this time, it's like OMG!
Well, I love all the efforts my friends had put in to making such a wonderful birthday card. Before this, I thought my 16th birthday will be wasted away like any other birthdays I had. Ok, not really "wasted" lah. Most of the time, my family just have a small celebration. Buy cake, sing song, cut cake, makan, habis. Nothing else. No party or whatever. Not that I do not appreciate it or anything. I love it. I also rarely ask my parents to get stuff for me on my birthday. Well, I guess I just want to berjimat-cermat. And also, I think I have enough barang already. Actually, since I'm getting an acoustic piano soon, I'm gonna treat it like my own birthday present.
Again, thank you to all my friends! I love you all!
Friday, 13 February 2009
Time to make something more complicated
x²... Very innocent looking thing. But let's say you want to jazz it up a little. Make it more, I don't know, long?? Here's what I think: x² is too short.
As you can see, the pattern emerges sooner or later. Values of g(x) represents the difference between f(x+1)-f(x)
This keeps going on until
Now, writing that out is incredibly messy, so, I'm gonna use the Greek letter, sigma!! It's the very-cool-looking letter that looks like an E. So, summing it up, you'll get:
But,Therefore,
And because,
Then,Some more,
So, it is possible to write it out as:
And with that, we have finally made x² a little bit more complicated. Hahaha! Have a nice day!
First, we need a function:
Next, here's a table of values (ignore g(x) for now):
x | f(x) | g(x) |
1 | 1 | 3 |
2 | 4 | 5 |
3 | 9 | 7 |
4 | 16 | 9 |
5 | 25 | 11 |
6 | 36 | 13 |
7 | 49 | 15 |
8 | 64 | 17 |
9 | 81 | 19 |
10 | 100 | 21 |
From the table, we can conclude that
Now, writing that out is incredibly messy, so, I'm gonna use the Greek letter, sigma!! It's the very-cool-looking letter that looks like an E. So, summing it up, you'll get:
And because,
Then,Some more,
So, it is possible to write it out as:
And with that, we have finally made x² a little bit more complicated. Hahaha! Have a nice day!
Plans for Mr Ball 2
So far, I made a list of stuff I need to create before I can start with the level designing. This list is a list of objects and their variables which will determine how they behave and everything. So, it is vital I get this stage right or else I will scrap my project later on. It always happen and I don't want it to happen again.
Here's a preview of it. Currently, it is not really done yet. I'm still missing some very important objects.
If you don't understand it, you don't need to. Don't force yourself to decipher all those things. Just remember, what you see are objects and their associated variables.
My fatal flaw
Lack of sleep is very bad for me. It gives me stress. Ok, fine, a lot of people will also get stress from sleep deprivation, not only me. But seriously, I wasn't myself at all today. Yew Leung volunteered me to mendeklamasikan sajak but I said NOOO! Ok, that's fine so far. Then suddenly I threw my pencil box at him, but it missed and hit Kai Leong instead. I would never do that actually unless I'm really desperate. Sigh... stress can really make me go nuts.
So, that's why I always need a lot of sleep. I can get seriously mad whenever I get disturbed during my sleep. Well, who doesn't? One moment you're dreaming of your fantasy life, then the next, you see reality.
Anyway, I'm currently doing my Mod Maths work. Dang it! I lost my Add Maths Text Book! Sigh... I shall wait for it to come back.
Thursday, 12 February 2009
...
Whoa! Me too obsessed with this BGM already! (It should be playing in the background) It's from Persona 4. Anyway, I've altered my plans and the maze will be in First Person view.
I wonder if I should make cutscenes at all. The cutscene system in my currently-gone Mr Ball 2 was quite complicated, but in the end it works out. I don't think I should be placing cutscenes.
But but, I HAVE to make something which can aid me in planning the camera movements. Before this, I had to visualise how I want the camera to move, and then code it. Very mafan.
Another thing is, I'm gonna have to make a Maze creation program. I'm gonna place a lot of mazes in this game and I can't do all of it on my own. Maybe some other people out there (my friends in particular) have nice and creative ideas on how to position all the elements that make up a maze. Some more, this will ensure the mazes will be different.
Right, I'm gonna start planning the Maze system first, then start building the battle system. These two will be separate so there won't be any conflict or whatever.
Wednesday, 11 February 2009
Hmm... I miss Mr Ball 2
I don't know why, but I find 3D easier compared to 2D in terms of graphics. So I think I should stick to 3D.
I'm gonna start planning, right after I finish all my homeworks. I have a lot of ideas, inspired by game BGMs. I don't know why, but whenever I hear a nice BGM, my brain starts thinking what kind of situation the BGM is trying to tell. Here are some of my ideas:
- Maze, in Third Person view, inspired by Persona 3 and 4
- Probably placing a character with my name in the game. I just want to be part of my own game, that's all! Lol!
- Puzzles are a must! A game needs a little bit of challenge right? Not just battles and yada yada. Maybe puzzles to unlock different locations in a maze.
- More hi-Ougi/Special Spells. In addition to that, I'm thinking of giving Mr Ball some mercy by allowing him to use a spell that reflects all damage to all enemies (Damage depends on distance and Mr Ball attack points). Sounds cool eh?
- Ability to upgrade stats.
A lot of stuff from the old Battle System will remain. Most of the ideas were taken from my Mr Ball 2 project before this.
Right, this is gonna be one huge project. I doubt I can finish it in 3 months because of all my homeworks. Sad. Anyway, I got to go eat my lunch. Yes, I know, it's 3.45pm now. It's a very late lunch, actually can call it tea already. Well, I just didn't have the apetite to eat it just now.
Wednesday, 4 February 2009
Yay yay yay! My first post from my new desktop!!!!
My old desktop overheated and died. Now, I got an even better one. A new desktop to be precise! Yay!!! 2 gigs of RAM baby! That's the most I have ever had in my life! I love you daddy!
Gonna start Mr Ball soon. It's gonna be a 2D game. I lazy to create 3D games already. But the gameplay will be very similar. Run, shoot, run, dodge. I'll probably add more magic spells since 2D is so much easier than 3D.
Expect the game to be out around 2 to 3 months later, because I got a lot of work to do these few days. Sigh... Form 4 life is so much harder.
Gonna start Mr Ball soon. It's gonna be a 2D game. I lazy to create 3D games already. But the gameplay will be very similar. Run, shoot, run, dodge. I'll probably add more magic spells since 2D is so much easier than 3D.
Expect the game to be out around 2 to 3 months later, because I got a lot of work to do these few days. Sigh... Form 4 life is so much harder.
Subscribe to:
Posts (Atom)