The Post in Which I Explain The Post in Which Daddy Helps me With Arrays.

Several people have indicated that my last post was pretty technical, so let me see if I can explain it differently…

It’s like this: Imagine that Daddy and I are walking down the road. I have a notebook that I can write stuff in.

First Daddy and I walk past house number 64. Daddy tells me to “Write down the number of the house we just walked past”, so I write “…the number of the house we just walked past”.

Then we walk past house number 66 and Daddy tells me to “write down the number of the house we just walked past”, so again I write “…the number of the house we just walked past”.

THEN we walk past house number 68 and Daddy tells me again to “write down the number of the house we just walked past”, so then there’s a plot twist and I write “…the number of the house we just walked past”.

Finally we walk past house number 70 and Daddy asks what I’ve written down so I look at the notebook and see:

  • …the number of the house we just walked past.
  • …the number of the house we just walked past.
  • …the number of the house we just walked past.

so I look at the number of the house we just walked past and see that it’s 70. I say to Daddy “70 70 70” and he gets annoyed.

Now replace me with my computer and Daddy with me and that is what I was talking about in the last post.

The Post in Which Daddy Helps Me With Arrays.

I am making a grid based game where you have to move big blocks around and onto buttons and stuff like that. I also wanted the player to be able to undo their moves if they made a mistake, so I needed a big array that would remember the positions of the blocks and then if the player pressed the undo button, it would move the blocks (and the player) back to their earlier positions. However, the position of the block was also an array because some blocks could be odd shapes and I needed to store all of that information as well. So basically I had a huge array of all the information that ever was in a smaller array that was the position and shape of oddly shaped blocks.

It didn’t work.

I tried to fix it but it just made the code messier and I really couldn’t figure it out. I decided to do another, better and simpler version of it and that didn’t work ether. It seemed like while the actual position of the block moved, it would change bits of the array that saved previous positions, but it would only do it in specific spots. I figured out that it would only do it when I undid moves. I found the exact line that would change one list and for some reason the other one changed. I stared at that line for quite awhile until Daddy looked at it. He went online and found out that somehow instead of the code putting the data of the array at that time in the other array, it was REFERRING to the array of the current position. So instead of reading data of the array at the time when I wanted to go back to, the code was just looking at what the blocks current position is.

I fixed it by adding [:] to the right lines and it worked!…almost. I just had to write a bit more code and fix a few more glitches, and then it worked. The end.

I Wrote a Story.

Just before Christmas I finished writing a story called Norsar. It took a while to write it but then Daddy made it into a real book for me.

It’s inspired by The Hobbit and The Lord of The Rings.

Mama and Daddy fixed the spelling of some stuff for me, but didn’t change any words.

I drew the cover and map myself.

Click here to see it in the online store.