Skip to content

Commit 1c577d3

Browse files
committed
Fixed RandomDataGenerator.sow
1 parent f5584bd commit 1c577d3

5 files changed

Lines changed: 54 additions & 7 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ Version 1.0.7 (in progress in the dev branch)
105105
* ArcadePhysics.moveTowardsMouse changed to ArcadePhysics.moveTowardsPointer and now lets you specify which pointer to move towards (defaults to Input.activePointer).
106106
* ArcadePhysics.angleBetweenMouse changed to ArcadePhysics.angleBetweenPointer and now lets you specify which pointer to get the angle to (defaults to Input.activePointer).
107107
* ArcadePhysics.velocityFromAngle and ArcadePhysics.velocityFromRotation added with examples created.
108+
* Fixed the RandomDataGenerator.sow method so if you give in the same seed you'll now get the same results (thanks Hsaka)
108109

109110

110111
* TODO: look at Sprite.crop (http://www.html5gamedevs.com/topic/1617-error-in-spritecrop/)

examples/misc/rnd.php

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<?php
2+
$title = "rnd";
3+
require('../head.php');
4+
?>
5+
6+
<script type="text/javascript">
7+
8+
var game = new Phaser.Game(800, 600, Phaser.CANVAS, '', { create: create, update: update, render: render });
9+
10+
function create() {
11+
12+
game.rnd.sow([123]);
13+
console.log('A');
14+
console.log(game.rnd.integer());
15+
console.log(game.rnd.integer());
16+
console.log(game.rnd.integer());
17+
console.log(game.rnd.integer());
18+
console.log(game.rnd.integer());
19+
20+
game.rnd.sow([0]);
21+
console.log('B');
22+
console.log(game.rnd.integer());
23+
console.log(game.rnd.integer());
24+
console.log(game.rnd.integer());
25+
console.log(game.rnd.integer());
26+
console.log(game.rnd.integer());
27+
28+
game.rnd.sow([123]);
29+
console.log('C');
30+
console.log(game.rnd.integer());
31+
console.log(game.rnd.integer());
32+
console.log(game.rnd.integer());
33+
console.log(game.rnd.integer());
34+
console.log(game.rnd.integer());
35+
}
36+
37+
function update() {
38+
}
39+
40+
function render() {
41+
}
42+
43+
</script>
44+
45+
<?php
46+
require('../foot.php');
47+
?>

examples/template.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55

66
<script type="text/javascript">
77

8-
9-
108
var game = new Phaser.Game(800, 600, Phaser.AUTO, '', { preload: preload, create: create, update: update, render: render });
119

1210
function preload() {
@@ -27,8 +25,6 @@ function update() {
2725
function render() {
2826
}
2927

30-
31-
3228
</script>
3329

3430
<?php

examples/world/move around world.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,11 @@ function create() {
3030

3131
for (var i = 0; i < 100; i++)
3232
{
33-
var s = game.add.sprite(game.world.randomX, game.world.randomY, 'mushroom');
34-
// console.log(s.x, s.y);
33+
game.add.sprite(game.world.randomX, game.world.randomY, 'mushroom');
3534
}
3635

36+
game.add.text(600, 800, "- phaser -", { font: "32px Arial", fill: "#330088", align: "center" });
37+
3738
d = game.add.sprite(0, 0, 'phaser');
3839
d.anchor.setTo(0.5, 0.5);
3940

src/math/RandomDataGenerator.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,12 @@ Phaser.RandomDataGenerator.prototype = {
8080
this.s0 = this.hash(' ');
8181
this.s1 = this.hash(this.s0);
8282
this.s2 = this.hash(this.s1);
83+
this.c = 1;
8384

8485
var seed;
8586

86-
for (var i = 0; seed = seeds[i++]; ) {
87+
for (var i = 0; seed = seeds[i++]; )
88+
{
8789
this.s0 -= this.hash(seed);
8890
this.s0 += ~~(this.s0 < 0);
8991
this.s1 -= this.hash(seed);

0 commit comments

Comments
 (0)