Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: SFML 2.0 0n MAC  (Read 1771 times)

0 Members and 1 Guest are viewing this topic.

wvtrammell

  • Jr. Member
  • **
  • Posts: 70
    • View Profile
SFML 2.0 0n MAC
« on: May 26, 2013, 12:04:54 am »
I just installed the latest version.  My old program user 2-dim arrays Array[200][200].  The new version will not accept this so I discovered on line how to use vectors  to define it.
std::vector< std::vector<int> > Array(200, std::vector<int>(200));
However, my source looks like this
ncx = 0; ncy = 0;
for (x = 0; x < 1000; x = x + 100)
    {
    for y = 0; y < 1000; y = y+100))
        {
        Array[ncx][ncy] = variable;
         ncy++;
        }
    ncx++;
    }
It compiles  but gives a run time error.   Bad index
Any suggestions?
Thanks
Warren

zsbzsb

  • Hero Member
  • *****
  • Posts: 1409
  • Active Maintainer of CSFML/SFML.NET
    • View Profile
    • My little corner...
    • Email
Re: SFML 2.0 0n MAC
« Reply #1 on: May 26, 2013, 01:57:56 am »
Please use the [ code = cpp] [ /code] tags when posting code. This makes it so much easier to read what you post.

As to your problem, why in the world would you loop to 1000 and attempt to access elements if your array is only declared to be 200 in length. Don't try to access indexes that don't try to exist and maybe you won't get the error.  ;)
Motion / MotionNET - Complete video / audio playback for SFML / SFML.NET

NetEXT - An SFML.NET Extension Library based on Thor

G.

  • Hero Member
  • *****
  • Posts: 1593
    • View Profile
Re: SFML 2.0 0n MAC
« Reply #2 on: May 26, 2013, 02:20:07 am »
You're also supposed to reset ncy.
Weird code. ???

wvtrammell

  • Jr. Member
  • **
  • Posts: 70
    • View Profile
Re: SFML 2.0 0n MAC
« Reply #3 on: May 26, 2013, 09:41:28 pm »
Code: [Select]
Mr. zsbzsb
Sorry but I have no idea what [code = cpp]
tag are.
Mr. G
I think you have found my problem.
I am trying to isolate and store the actual x's and y's being used for sorting later in the program.
Thanks
Warren

 

anything