Archive for the ‘Game Design’ Category

Combinations: General Function to Get All Possible Combinations

Thursday, February 28th, 2008

Previously, we looked at how to calculate a binomial coefficient (to find the total number of possible combinations) and an example of how to generate a list of combinations with hard-coded loops.

A function would be much more useful to us if it was flexible - if it could generate a list of combinations for any size set of numbers. We can’t do this with the hard coded loop solution, so we need to come up with a better method.
(more…)

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…)

JS Game: Making a Real Game Board from a Concept

Wednesday, February 20th, 2008

In a recent post, I sketched out how to use Javascript to build a gameboard for a browser-based game - specifically Tic Tac Toe. After a little tweaking, I’ve worked this into a functioning Tic Tac Toe board.

In this post, we’ll explore the code used to set up this board. Once that’s done, the next step will be to create a php script to evaluate some of the game’s logic.
(more…)

JS Game: Creating a Simple Game Board in Javascript

Tuesday, February 19th, 2008

A thorough knowledge of Javascript can give you tremendous control over what happens on a website. Combined with PHP through an AJAX request, you can make some pretty nifty browser-based games.

This tutorial will focus on the first part of making a basic board game - creating a board. The end result will be a three by three game board suitable for use in developing a tic-tac-toe game.
(more…)