Tuesday, June 24, 2008

Browser Based Games II

I am back with the second edition of how to develop browser based games. If you haven't read the first volume, please do it before reading this one. It will help you to understand this one.

Alright, so as I told in my previous post that there are several types of browser based games. But like last time I'll be talking about the Javascript games which are visually appealing and help you understand on how to build a game.

To start with, we first need the structure of the game. I would broadly classify the games into three categories: board games (very less animations required but high AI requirements), minor animation games (these are games like frogger, bricks, tetris where we have minor animations and have static backgrounds) and complex games (like pinball, snooker, tanks where we need to apply the collision mechanisms, trace the paths of the objects and can also have moving backgrounds plus these might require a lot of AI too).

The board games are like casino games(blackjack, slots, roulette, etc) where the main aim is to develop a proper game play mechanism, defined on a set of rules which are hard coded into the program. For instance if we are to develop the blackjack game, we know certain rules that blackjack pays 3 to 2, insurance pays 2 to 1, etc. These rules can be laid down in form of JavaScript functions which calculate the final value of a variable (Score) based on these parameters and these functions are trigger when the respective conditions occur.

AI part might be required in a multiplayer game where the opponents are all bots. For instance a game like texas hold'em poker, where we need to figure out certain parameters based the values of which the bot makes his move. These rules can be designed by carefully observing a real game play. You can figure out certain limits which define the responses of a player, and code them to create a bot player for your game.

Oh and yes, the random part like finding a card out of the deck can be done in this fashion:
function Shuffle(max){
var num=Math.random()*max;
return Math.round(num);
}
This Shuffle function would return a no. lying between 0 and max inclusive. So if you have to pick a card use the following to obtain the suit as well as cardno.:
funtion getCard()
{
var cardno=Shuffle(12)+1;
var suit=Shuffle(3)+1;
}
Where each no. from 1 to 4 can represent a suit for the card. Also for the minor animations I use this function, though it was specifically made for movement in right to left direction, but with minor tweaks, one can adjust it to work both ways:
function Animate()
{
the_style=Img.style;
the_style.left = parseFloat(the_style.left) + movLeft;
the_style.top = parseFloat(the_style.top) + movTop;
if(parseInt(the_style.top)>=lastTop&&parseInt(the_style.left)<=lastLeft&&splitting==0) { the_style.left=lastLeft; the_style.top=lastTop; animating=0; eval(afterAnim); return; } if(parseInt(the_style.top)<=lastTop&&parseInt(the_style.left)<=lastLeft&&splitting==1) { the_style.left=lastLeft; the_style.top=lastTop; animating=0; eval(afterAnim); return; } if(parseInt(the_style.top)<=lastTop&&parseInt(the_style.left)>=lastLeft&&splitting==2)
{
the_style.left=lastLeft; the_style.top=lastTop; animating=0; eval(afterAnim);
return;
}
setTimeout("Animate()",10);
}
Well that's it for this time, I'll dicuss the other 2 types of games next time.

Saturday, June 7, 2008

IT is sinking, or is it?

Hello folks, you might be reading daily in the newspapers that the IT (Information Technology) sector is sinking, big losses, job cutoffs, layoffs and no recruitment. Well that might be true, infact it is, but sometimes I wonder, why doesn't it bother a few people, the elite group!

My point of writing this blog entry is to give a clear picture of what is going on in the IT sector and why. Like I said, the IT is sinking, but despite of this fact, I have got 4 job offers (2 from in-campus placement and 2 PPO offers). Why is it so, that a few people get so many jobs and a few don't land up with one god job? One might feel that I am trying to boast myself, but that's not true and the fact remains there. My cousins, engineer from reputed colleges, are still searching for job. Why is it so?

Well the reason lies in the fact that due to the fall in IT, the companies has shifted from hiring quantity of employees to hiring quality employees. So instead of hiring bulk of people they are hiring a few good and experienced people and treating them well. So despite the fall in IT, job of many people has not been affected while majority of people are into the search of jobs. This trend has let to lay-offs, cutoffs and everything. This paradigm shift has made life miserable for many people. Also the hired employees have to work for longer hours as they are doing the work which was one by 3-4 people earlier. Therefore, the employees and the unemployed are both affected in a bad way, due to this shift.

Redifining the post from the conclusion, I would say "Yes, IT is falling, and the employers are trying to compensate that . At the losing end are the employees and the people looking for jobs".