[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: kdenonbeta/daleks
From: Ian Reinhart Geiser <geiseri () kde ! org>
Date: 2004-04-25 16:41:10
Message-ID: 20040425164110.AF65F9A66 () office ! kde ! org
[Download RAW message or body]
CVS commit by geiseri:
simplify random numbers
M +11 -6 daleks.js 1.6
--- kdenonbeta/daleks/daleks.js #1.5:1.6
@@ -320,6 +320,6 @@
this.placeDalek = function( idx )
{
- var X = Math.round( (size - 1) * Math.random() );
- var Y = Math.round( (size - 1) * Math.random() );
+ var X = this.random( size - 1 );
+ var Y = this.random( size - 1 );
if( this.gameBoard[X][Y].name == 'tile' )
{
@@ -333,6 +333,6 @@
this.placePlayer = function( )
{
- this.playerX = Math.round( (size - 1) * Math.random() );
- this.playerY = Math.round( (size - 1) * Math.random() );
+ this.playerX = this.random( size - 1 );
+ this.playerY = this.random( size - 1 );
if( this.gameBoard[this.playerX][this.playerY].name == 'tile')
{
@@ -345,6 +345,6 @@
this.placeRubble = function( )
{
- var X = Math.round( (size - 1) * Math.random() );
- var Y = Math.round( (size - 1) * Math.random() );
+ var X = this.random( size - 1 );
+ var Y = this.random( size - 1 );
if( this.gameBoard[X][Y].name == 'tile')
{
@@ -355,4 +355,9 @@
}
+ this.random = function( max )
+ {
+ return Math.round( max * Math.random() );
+ }
+
// Ctor
this.enemies = 0;
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic