File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -33,16 +33,24 @@ Phaser.Math = {
3333 * @return {number } A floating point number between min (inclusive) and max (exclusive).
3434 */
3535 random : function ( min , max ) {
36+
3637 if ( min === undefined ) { min = 0 ; }
3738 if ( max === undefined ) { max = 1 ; }
3839
39- if ( min < max ) {
40+ if ( min === max )
41+ {
42+ return min ;
43+ }
44+
45+ if ( min < max )
46+ {
4047 var temp = min ;
4148 min = max ;
4249 max = temp ;
4350 }
4451
45- return Math . random ( ) * ( max - min ) + min ;
52+ return ( Math . random ( ) * ( max - min ) + min ) ;
53+
4654 } ,
4755
4856 /**
@@ -55,18 +63,27 @@ Phaser.Math = {
5563 * @return {number } An integer between min (inclusive) and max (inclusive).
5664 */
5765 between : function ( min , max ) {
66+
5867 if ( min === undefined ) { min = 0 ; }
5968 if ( max === undefined ) { max = 1 ; }
6069
61- if ( min < max ) {
70+ if ( min === max )
71+ {
72+ return min ;
73+ }
74+
75+ if ( min < max )
76+ {
6277 var temp = min ;
6378 min = max ;
6479 max = temp ;
6580 }
6681
6782 min = Math . ceil ( min ) ;
6883 max = Math . floor ( max ) ;
84+
6985 return Math . floor ( Math . random ( ) * ( max - min + 1 ) ) + min ;
86+
7087 } ,
7188
7289 /**
You can’t perform that action at this time.
0 commit comments