
-----------------------------------
NEEDSHELP
Tue Jun 09, 2009 9:31 pm

Can pictures be used in/as an array?
-----------------------------------
I have previously asked this question and I will attempt to ask it again hoping to have some answer of some sort:

can you use pictures in an array and how can one do so?
(an example or two would be greatly appreciated...)

thnkx...

-----------------------------------
DtY
Tue Jun 09, 2009 9:42 pm

RE:Can pictures be used in/as an array?
-----------------------------------
(correct me if I'm wrong...) In Turing, images/sprites aren't actually images/sprites as they are in other languages, they are just integers representing the loaded image, so you can make an array of integers, and load stuff into it:
var pics: array 0..2 of int
pics(0) := Pic.Load(...)
pics(1) := Pic.Load(...)
pics(2) := Pic.Load(...)
You can also use a loop to load them, which is probably why you want them in an array.

-----------------------------------
NEEDSHELP
Tue Jun 09, 2009 10:22 pm

Re: Can pictures be used in/as an array?
-----------------------------------
okie, so your help really cleared things up for me

however, when i try to get a loop to simplify things,  a problem arises in my code like so:

loop
    put qst(x)
    delay(500)
    put "A) ", OptA(x)
    put "B) ", OptB(x)
    put "C) ", OptC(x)
    put "D) ", OptD(x) 
    put ""
    Pic.Draw (pics(x), 200, 300, picCopy)  ANYONE, could figue out why my program is not working and how i could fix it, i would be most grateful...  :wink: 

thank you..

-----------------------------------
Tony
Wed Jun 10, 2009 11:56 am

RE:Can pictures be used in/as an array?
-----------------------------------
my first guess, based on the error message, is that the image is simply isn't loaded. You can check what Pic.FileNew("eye1.bmp") returns. Some common reasons is that the image name is either misspelled or the file is located in a different folder than your program is looking in.

-----------------------------------
BigBear
Wed Jun 10, 2009 1:58 pm

RE:Can pictures be used in/as an array?
-----------------------------------
%http://compsci.ca/v3/viewtopic.php?t=4637&highlight=gif
%%%%%%%%%%%%%%%%%%%%%%%
% Program To Use GIFs %
% Kevin The Short One %
% Canada Flag Animated%
%%%%%%%%%%%%%%%%%%%%%%%
View.Set ("offscreenonly")
colorback (black)
cls   %% make the screen look good...
%%%%%% ^ sets the window size etc, i used window.open so i can close at the end
var picnum, pic : int := 0
%%%% u need a variable for the picture.. and one to count up the frames
loop
    exit when hasch %%% exits when u push a button
    if picnum not= 8 then  %%% the number of frames, makes sure it done exceed
        picnum += 1 %%% makes the frame count go higher
    else %%% the frame number is higher then the amount of pictures
        picnum := 1 %%% restart at frame 1
    end if
    pic := Pic.FileNew ("Images/can" + intstr (picnum) + ".BMP")
    %%% ok... that makes the picture variable change to reflect the current picture
    %%%% intstr converts interger to string so it will be can1.bmp or can2.bmp depending on the frame...
    Pic.Draw (pic, maxx div 2 - 75, maxy div 2 - 50, picCopy) %%% draws the flag in the middle of screen
    View.Update
    cls
    delay (100) %%% so its kinda smoother... u could use View.Update **i made this for simplicity..
end loop

here is a method of using pictures in a for loop taken from this tutorial

http://compsci.ca/v3/viewtopic.php?t=4637&highlight=gif

-----------------------------------
DtY
Wed Jun 10, 2009 3:46 pm

RE:Can pictures be used in/as an array?
-----------------------------------
That doesn't use an array though...

-----------------------------------
NEEDSHELP
Wed Jun 10, 2009 9:43 pm

RE:Can pictures be used in/as an array?
-----------------------------------
thanks for all the help ideas guys... turns out that Toni was right... my pictures weren't located in the same folder as my application thus giving me that error message... 

+_+ wow, what a simpleton i was...
thankfully, i learned my lesson :)

and, my project was completed (and worked) successfully with all your help

thanks again!
