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

Username:   Password: 
 RegisterRegister   
 Can pictures be used in/as an array?
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
NEEDSHELP




PostPosted: Tue Jun 09, 2009 9:31 pm   Post subject: 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...
Sponsor
Sponsor
Sponsor
sponsor
DtY




PostPosted: Tue Jun 09, 2009 9:42 pm   Post subject: 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:
Turing:
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




PostPosted: Tue Jun 09, 2009 10:22 pm   Post subject: 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) [i]this is where the problem arises for turing tells me that it was an "Illegal picture ID number '0' saying that the probable cause was that the picture was not sucessfully created."
get guess

if guess = aswr(x) then
put "Correct!"
elsif guess not= aswr(x) then
put "That's wrong!"
end if
x:= x+1
exit when x = 8
end loop

i've tried figuring out why such a statement appears like so but haven't been able to find any answers.
here's my whole code so far:

var qst :array 1 .. 8 of string
var OptA :array 1 .. 8 of string
var OptB :array 1 .. 8 of string
var OptC :array 1 .. 8 of string
var OptD :array 1 .. 8 of string
var aswr :array 1 .. 8 of string
var guess :string
var pics :array 1 .. 8 of int
var x :int:= 1


qst(1) := "To which animal does this eye belong to?"
qst(2) := "What about this one?"
qst(3) := "I see you... this is an eye of..."
qst(4) := "LOOK AT ME! Which animal now?"
qst(5) := "This is an eye?! But, who's?"
qst(6) := "And this one?"
qst(7) := "What animal has such a eye?"
qst(8) := "Ohh, pretty... Who has these?"

OptA(1):="Snake"; OptB(1):="Salmon"; OptC(1):="Desert Lizard"; OptD(1):="Frog"
OptA(2):="Porcupine"; OptB(2):="Cat"; OptC(2):="Dog"; OptD(2):="Wolf Cub"
OptA(3):="Lion"; OptB(3):="Wolverine"; OptC(3):="Antelope"; OptD(3):="Giraffe"
OptA(4):="White Wolf"; OptB(4):="Polar Bear"; OptC(4):="Owl"; OptD(4):="Arctic Fox"
OptA(5):="Jellyfish"; OptB(5):="Sea Cucumber"; OptC(5):="Octopus"; OptD(5):="Hippopotamus"
OptA(6):="Crocodile"; OptB(6):="Frog"; OptC(6):="Salamander"; OptD(6):="Eel"
OptA(7):="Ostrich"; OptB(7):="Rhinocerous"; OptC(7):="Turkey"; OptD(7):="Turtle"
OptA(8):="Lemur"; OptB(8):="Jumping Spider"; OptC(8):="Angler Fish"; OptD(8):="Caterpillar"

aswr(1) := "A"
aswr(2) := "C"
aswr(3) := "A"
aswr(4) := "C"
aswr(5) := "C"
aswr(6) := "B"
aswr(7) := "D"
aswr(8) := "B"

pics(1):= Pic.FileNew("eye1.bmp")
pics(2):= Pic.FileNew ("eye2.bmp")
pics(3):= Pic.FileNew ("eye3.bmp")
pics(4):= Pic.FileNew ("eye4.bmp")
pics(5):= Pic.FileNew ("eye5.bmp")
pics(6):= Pic.FileNew ("eye6.bmp")
pics(7):= Pic.FileNew ("eye7.bmp")
pics(8):= Pic.FileNew ("eye8.bmp")

Draw.Fill (500,300,7,7)
colourback (7)
colour (0)

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)
get guess

if guess = aswr(x) then
put "Correct!"
elsif guess not= aswr(x) then
put "That's wrong!"
end if
x:= x+1
exit when x = 8
end loop

if anyone, 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




PostPosted: Wed Jun 10, 2009 11:56 am   Post subject: 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.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
BigBear




PostPosted: Wed Jun 10, 2009 1:58 pm   Post subject: RE:Can pictures be used in/as an array?

Turing:
%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




PostPosted: Wed Jun 10, 2009 3:46 pm   Post subject: RE:Can pictures be used in/as an array?

That doesn't use an array though...
NEEDSHELP




PostPosted: Wed Jun 10, 2009 9:43 pm   Post subject: 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 Smile

and, my project was completed (and worked) successfully with all your help

thanks again!
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  [ 7 Posts ]
Jump to:   


Style:  
Search: