Posts Tagged ‘Game Design’

Getting Combinations: Calculating a Binomial Coefficient

Sunday, February 24th, 2008

I came across this problem on the DigitalPoint forums the other day. How can we write a script to calculate the total number of random combinations in a set (i.e. the binomial coefficient), and how can we generate a list of these combinations?

Today, we’ll tackle the first part. We’ll start with a quick primer on math - what is a binomial coefficient? Then, we’ll look into the most efficient way to calculate that and get the total number of possible combinations.
(more…)

Javascript Function: Random Number Generator

Sunday, February 24th, 2008

Yesterday, I wrote a short article on generating random numbers in Javascript. The Javascript random number generator is similar to C/++ - it gives you a random number from 0 to 1 and you need to make it useful.

At the suggestion of a reader (thanks Justin), I decided to go ahead and turn the general formula for this into a short helper function to generate a random number.
(more…)

How to Create a Random Number in Javascript

Saturday, February 23rd, 2008

I’ve been working with PHP for some time now, and I’ve become spoiled with the rand() function for generating random numbers. It’s so simple - pass a min, pass a max, and get the number you want.

While I was working on various game-related scripts this weekend, I was left wondering how to create a random number in Javascript. It’s not quite as simple as the rand() function - we’ll have to go back to the old C-style random number generation.
(more…)

Javascript Game Spotlight: 3d Worm

Saturday, February 23rd, 2008

Screenshot of a 3d Worm game written in Javascript.I was browsing the Frihost forums this morning, and I stumbled on a cool Javascript game.

One of the Frihost users and his friend made a 3d Worm game. Although the directions are in Spanish (as is the source code), the game is pretty cool. It’s a good example of what you can accomplish with some Javascript/DOM trickery.
(more…)