mirror of
https://github.com/wassname/phaser.git
synced 2026-06-27 16:10:15 +08:00
Fixed RandomDataGenerator.sow
This commit is contained in:
@@ -105,6 +105,7 @@ Version 1.0.7 (in progress in the dev branch)
|
||||
* ArcadePhysics.moveTowardsMouse changed to ArcadePhysics.moveTowardsPointer and now lets you specify which pointer to move towards (defaults to Input.activePointer).
|
||||
* ArcadePhysics.angleBetweenMouse changed to ArcadePhysics.angleBetweenPointer and now lets you specify which pointer to get the angle to (defaults to Input.activePointer).
|
||||
* ArcadePhysics.velocityFromAngle and ArcadePhysics.velocityFromRotation added with examples created.
|
||||
* Fixed the RandomDataGenerator.sow method so if you give in the same seed you'll now get the same results (thanks Hsaka)
|
||||
|
||||
|
||||
* TODO: look at Sprite.crop (http://www.html5gamedevs.com/topic/1617-error-in-spritecrop/)
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
$title = "rnd";
|
||||
require('../head.php');
|
||||
?>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
var game = new Phaser.Game(800, 600, Phaser.CANVAS, '', { create: create, update: update, render: render });
|
||||
|
||||
function create() {
|
||||
|
||||
game.rnd.sow([123]);
|
||||
console.log('A');
|
||||
console.log(game.rnd.integer());
|
||||
console.log(game.rnd.integer());
|
||||
console.log(game.rnd.integer());
|
||||
console.log(game.rnd.integer());
|
||||
console.log(game.rnd.integer());
|
||||
|
||||
game.rnd.sow([0]);
|
||||
console.log('B');
|
||||
console.log(game.rnd.integer());
|
||||
console.log(game.rnd.integer());
|
||||
console.log(game.rnd.integer());
|
||||
console.log(game.rnd.integer());
|
||||
console.log(game.rnd.integer());
|
||||
|
||||
game.rnd.sow([123]);
|
||||
console.log('C');
|
||||
console.log(game.rnd.integer());
|
||||
console.log(game.rnd.integer());
|
||||
console.log(game.rnd.integer());
|
||||
console.log(game.rnd.integer());
|
||||
console.log(game.rnd.integer());
|
||||
}
|
||||
|
||||
function update() {
|
||||
}
|
||||
|
||||
function render() {
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<?php
|
||||
require('../foot.php');
|
||||
?>
|
||||
@@ -5,8 +5,6 @@
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
|
||||
|
||||
var game = new Phaser.Game(800, 600, Phaser.AUTO, '', { preload: preload, create: create, update: update, render: render });
|
||||
|
||||
function preload() {
|
||||
@@ -27,8 +25,6 @@
|
||||
function render() {
|
||||
}
|
||||
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
<?php
|
||||
|
||||
@@ -30,10 +30,11 @@ window.onload = function () {
|
||||
|
||||
for (var i = 0; i < 100; i++)
|
||||
{
|
||||
var s = game.add.sprite(game.world.randomX, game.world.randomY, 'mushroom');
|
||||
// console.log(s.x, s.y);
|
||||
game.add.sprite(game.world.randomX, game.world.randomY, 'mushroom');
|
||||
}
|
||||
|
||||
game.add.text(600, 800, "- phaser -", { font: "32px Arial", fill: "#330088", align: "center" });
|
||||
|
||||
d = game.add.sprite(0, 0, 'phaser');
|
||||
d.anchor.setTo(0.5, 0.5);
|
||||
|
||||
|
||||
@@ -80,10 +80,12 @@ Phaser.RandomDataGenerator.prototype = {
|
||||
this.s0 = this.hash(' ');
|
||||
this.s1 = this.hash(this.s0);
|
||||
this.s2 = this.hash(this.s1);
|
||||
this.c = 1;
|
||||
|
||||
var seed;
|
||||
|
||||
for (var i = 0; seed = seeds[i++]; ) {
|
||||
for (var i = 0; seed = seeds[i++]; )
|
||||
{
|
||||
this.s0 -= this.hash(seed);
|
||||
this.s0 += ~~(this.s0 < 0);
|
||||
this.s1 -= this.hash(seed);
|
||||
|
||||
Reference in New Issue
Block a user