Hi Guys,
thanks for the responses

The fact that the script works for left but not right is what's killing me.
Add to that, once left is clicked then right works perfectly. So although
for some reason I have what might be a NAN index, it  resolves itself once
the second (identical function) is called. This implies to me a difference
between cell[posX+1] and cell[posX-1] , in that one is a NAN the other
isn't.

I was kinda hoping that someone would pop up and go of course [x-1] is
different to [x+1]!!!!

Anyways I like the idea of leaner meaner json and can easily adapt so that
 to go right used to be x+1 and down was y+1  : cell[x][y]
becomes (in a single dimensioned)  right equals x+1 and down is  x+8.
:cell[0-63]

I'm not convinced it will help since I still need to be able to lookahead
to the adjoining cells :  if cell[x+8]=0 but the fact that it is not
multidimensional might make it easier to solve.

I'll post my results if you are interested

thanks

Rob



On Wed, Feb 29, 2012 at 12:38 AM, rasmusfl0e <[email protected]> wrote:

> Hmmm, maybe I'm missing something - but sometimes your for-loops run to 8
> and sometimes to 7... is that on purpose. It would explain "index out of
> range" type errors.
>
> also you can make everything easier on yourself by letting your php script
> return some cleanr/meaner json:
>
> [
>     [5,4,4,4,4,4,4,4],
>     [6,0,0,0,0,0,0,5],
>     [6,0,0,0,0,0,0,5],
>     [6,0,0,0,0,0,0,5],
>     [6,0,0,0,0,0,0,5],
>     [6,0,0,0,0,0,0,5],
>     [6,0,0,0,0,0,0,5],
>     [6,0,0,0,0,0,0,5]
> ]
>
> and then in your json request you do:
>
>     onSuccess: function(result) {
>         cell = result;
>     }
>
> no need to jump through for-loops ;)
>
>
> On Wednesday, February 29, 2012 1:00:39 AM UTC+1, Rob Stocker wrote:
>>
>> Hi All,
>> I'm building a game using the joomla and mootools frameworks.
>> I was originally using the following php script to parse values into
>> javascript and it worked fine for the past year. But now I've decided to
>> tidy things up and catch the 8*8 grid via a json call instead.  The code is
>> here 
>> http://jsfiddle.net/Techbot/**3TVfb/1/<http://jsfiddle.net/Techbot/3TVfb/1/>
>>
>> My problem is MoveRight() won't run unless MoveLeft() is called first.
>> This doesn't make sense - both functions are identical except for
>> increments instead of decrements. I  get cell[PosX +1] is not defined (why
>> not cell[PosX + 1][PosY]??) if I call MoveRight() first, but if I call
>> MoveLeft() then MoveRight() everything gets defined. I've been stuck on
>> this for days now.
>>
>> <?php
>>     for ($y=0;  $y <= 7 ; $y++) {
>>         $name='row'.$y;
>>         $arr[$y] = explode(",",($this->row->$**name));
>>         $x = 0;
>>         foreach ($arr[$y] as $row){
>>             ?>
>> <script type='text/javascript'>
>> cell[<?php echo $x ;?>][<?php echo $y ;?>]=<?php echo $row ; ?>;
>> </script>
>> <?php
>> $x= $x+1;
>>     }
>> }
>> ?>
>>
>> Any ideas as to what I am missing?
>>
>> --
>> Rob & Lisa - EMC23
>> 083 416 0618
>> <http://goog_1827821969>[email protected]
>> www.emc23.com
>>
>>
> On Wednesday, February 29, 2012 1:00:39 AM UTC+1, Rob Stocker wrote:
>>
>> Hi All,
>> I'm building a game using the joomla and mootools frameworks.
>> I was originally using the following php script to parse values into
>> javascript and it worked fine for the past year. But now I've decided to
>> tidy things up and catch the 8*8 grid via a json call instead.  The code is
>> here 
>> http://jsfiddle.net/Techbot/**3TVfb/1/<http://jsfiddle.net/Techbot/3TVfb/1/>
>>
>> My problem is MoveRight() won't run unless MoveLeft() is called first.
>> This doesn't make sense - both functions are identical except for
>> increments instead of decrements. I  get cell[PosX +1] is not defined (why
>> not cell[PosX + 1][PosY]??) if I call MoveRight() first, but if I call
>> MoveLeft() then MoveRight() everything gets defined. I've been stuck on
>> this for days now.
>>
>> <?php
>>     for ($y=0;  $y <= 7 ; $y++) {
>>         $name='row'.$y;
>>         $arr[$y] = explode(",",($this->row->$**name));
>>         $x = 0;
>>         foreach ($arr[$y] as $row){
>>             ?>
>> <script type='text/javascript'>
>> cell[<?php echo $x ;?>][<?php echo $y ;?>]=<?php echo $row ; ?>;
>> </script>
>> <?php
>> $x= $x+1;
>>     }
>> }
>> ?>
>>
>> Any ideas as to what I am missing?
>>
>> --
>> Rob & Lisa - EMC23
>> 083 416 0618
>> <http://goog_1827821969>[email protected]
>> www.emc23.com
>>
>>


-- 
Rob & Lisa - EMC23
083 416 0618
 <http://goog_1827821969>[email protected]
www.emc23.com

Reply via email to