Posts Tagged ‘js’

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

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

Fixing a WP Plugin: Per-Post CSS and JS

Sunday, February 17th, 2008

A few weeks ago, I installed the “Per Post CSS and JS” plugin for Wordpress. This allows you to add a custom field to your post and include extra .css or .js files to link to that individual page.

I only realized today – while testing something else – that the plugin had been firing off warning messages because of an oversight in the code. Warning messages annoy me, so I decided to fix it up.
(more…)