Jump to content
  • Advertisement
Sign in to follow this  

Find field borders

This topic is 2788 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello guys,

once again I'm here to ask you for help. The last task with operator overloading was done in time (it was not about operator overloading, but about my inability to work with arrays ;/)
so I got paid (pack of cigarettes, I feel like a pro programmer now^_^) and now the task is simple representation of Conway's Game of Life. I've completed the task, but there's one thing that lies in my mind - one of the tasks is, that borders of the array (2D or vector, I've done in with vector) have to stay empty (or dead, if you wish) all the time. It's 20x20 array, so I decided to do it the old-fashioned way and wrote down all the coordinates which are at the borders (I guess 72)... but what if I want to multiply the size of my array by two? Then I would have to write down another 72 numbers and I would need to do this every time I change the size. That's why I've been thinking about some function, that would find the borders by itself and store them somewhere, so no matter how the array is big, it will always find them for me. Any ideas?

So far I've been able to detect only vertical ones with something like:

//I'm printing 'x' where the border is
for(int i = 0; i < pole.size(); ++i){
if((i + 1) % 20 == 0){
pole = 'x';
if(i % 20 == 0){
pole = 'x';

Thanks for any ideas.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!