Computer Science Canada Picture allocation trouble |
Author: | shoobyman [ Mon Jan 08, 2007 5:24 pm ] | ||
Post subject: | Picture allocation trouble | ||
You may need to have 2 pictures called ship.bmp and enemyship.bmp in order to see my error. When it runs, it gives an error that the picture was not successfully created. However, if i get rid of the "eneship" or "ship1" stuff, it works fine. I think this is because it has no room to allocate new pictures, but it hasn't exceeded 1000 pictures yet. Anyone know what my problem is? |
Author: | CodeMonkey2000 [ Mon Jan 08, 2007 5:33 pm ] | ||
Post subject: | Re: Picture allocation trouble | ||
try something like this:
you kept allocating memory for the same picture, so just allocate it once and use that like a reference. |
Author: | Clayton [ Mon Jan 08, 2007 5:46 pm ] |
Post subject: | Re: Picture allocation trouble |
are you getting the error from the Pic.FileNew() or the Pic.Rotate()? highlight the line where you get the error, or post up the pictures with the code. |
Author: | ericfourfour [ Mon Jan 08, 2007 8:40 pm ] | ||
Post subject: | Re: Picture allocation trouble | ||
Well let's isolate a bit of code:
What you need to understand is that Pic.FileNew and Pic.Rotate bot allocate memory for one picture. In the for loop you are allocating memory for 4 pictures each iteration. If there are 360 iterations that means at the end of your program you will have 360 * 4 = 1440 (+ 2 at the beginning) pictures. Since Turing's preset maximum is 1000 it is impossible for your code to finish. I would recommend loading around 36 images instead (one for every ten degrees). Also, you should look into the procedure, Pic.Free. |