
-----------------------------------
SIXAXIS
Sun Mar 02, 2008 2:03 pm

Rotating
-----------------------------------
I'm trying to make an image keep rotating forever, but I get the error 

Illegal picture ID number '0'

after about 10 seconds of running the program.

I'm using an array, a for loop, and an image to rotate. Here is my code.

setscreen ("graphics:800;600,offscreenonly,nobuttonbar")
var image : int := Pic.FileNew ("image.JPG")
var rotate : array 1 .. 99999 of int
loop
    for i : 1 .. maxint
        cls
        rotate (i) := Pic.Rotate (image, i, -1, -1)
        Pic.Draw (rotate (i), 50, 50, picCopy)
        View.Update
        delay (5)
    end for
end loop

-----------------------------------
HeavenAgain
Sun Mar 02, 2008 2:33 pm

RE:Rotating
-----------------------------------
var rotate : array 1 .. 99999 of int andfor i : 1 .. maxint
 rotate(i) % remember rotate is only size of 99999 
this is where constant would kick in, maxint is a big number, bigger than your 9999999 however many 9s you have, so ....... see the problem?

and array in here is not necessary.... you bascailly have the same picture, the difference is only the angle of seeing it... and plus you already have the built in rotate, why bother storing the same pictures and waste space right?

setscreen ("graphics:800;600,offscreenonly,nobuttonbar")
var image : int := Pic.FileNew ("image.JPG") 
var degrees : int := 0
loop
degrees = (degrees+1) mod 360
draw rotate(image, degrees)
end loop

-----------------------------------
McKenzie
Sun Mar 02, 2008 5:49 pm

Re: Rotating
-----------------------------------
You get an illegal picture because Turing only allows you to assign 1000 picture IDs. Fortunately, you only need 360 of them for your rotation. Store all 360 rotations of your picture in your array once, then just use your array. As HeavenAgain pointed out you will want to use mod to keep track of your angle.

-----------------------------------
CodeMonkey2000
Sun Mar 02, 2008 10:03 pm

RE:Rotating
-----------------------------------
Actually you can cut that down to 36, each image represents 10 degrees. It's not that precise, but it's good enough, plus it's efficient.
