Ryan Bowen 2011. Powered by Blogger.
RSS

My Wrestle With Arrays

I'm currently working on a C program that is a simulation of "Turtle Graphics".

Turtle Graphics for those who don't know is when you have a square of blank paper and you program a route into this "turtle" for it to follow on the following commands: Go Forward, Turn Left, Turn Right, Raise Pen, Lower Pen.

The idea is you have to plan your drawing by entering precise commands into the "turtle" for it to then initiate by moving around and lowering the pen to draw a line.
It is based off an exercise in Deitel's C How to Program (5th Edition) and inspired by a turtle robot I actually used as a child at school, so if I have used one maybe other people have too?

I'm using arrays in C and so far it hadn't been working well for me but I literally dreamt the answer last night and now it seems like it's going to work at last!

For those interested I was foolishly trying to program the position of the turtle and the floor as separate arrays and compare them but now I've just assigned the x and y co-ordinates of the turtle as integers!

If I get the program working by tomorrow I'll upload a copy for everyone to have a play-around with, it's not that exciting but it is an interesting way to learn about arrays in C if you're a beginner like me!

  • Digg
  • Del.icio.us
  • StumbleUpon
  • Reddit
  • RSS

0 comments:

Post a Comment

Total Pageviews