Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Rotating
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
SIXAXIS




PostPosted: Sun Mar 02, 2008 2:03 pm   Post subject: Rotating

I'm trying to make an image keep rotating forever, but I get the error

code:
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.

Turing:
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
Sponsor
Sponsor
Sponsor
sponsor
HeavenAgain




PostPosted: Sun Mar 02, 2008 2:33 pm   Post subject: RE:Rotating

code:
var rotate : array 1 .. 99999 of int
and
code:
for 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?

code:
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




PostPosted: Sun Mar 02, 2008 5:49 pm   Post subject: 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




PostPosted: Sun Mar 02, 2008 10:03 pm   Post subject: 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.
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 4 Posts ]
Jump to:   


Style:  
Search: