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

Username:   Password: 
 RegisterRegister   
 Turing Multiple Sprites Problem (Illegal photo ID)
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
kwanzahh




PostPosted: Mon Jan 10, 2011 7:05 pm   Post subject: Turing Multiple Sprites Problem (Illegal photo ID)

I have a very simple turing code of just a car (sprite)controlled by keys moving around a track (background image). Basically, i've added another pic/sprite and used the same code so that two different cars can be controlled by different keys on the keyboard. When i try to run, it tells me the sprite.new line is an illegal picture id, saying that probably the picture wasnt successfully created. But the picture is the exact same name and it's in the same folder, i've been trying to figure this out for days but cant' seem to. Here's the code


%Screen Settings
setscreen ("graphics:640;480")
%Variables
var porsche:int
var vette:int
var sprite:array char of boolean
var sprite2:array char of boolean
var porschectrl:int
var vettectrl:int
var backdrop:int
var x:int
var y:int
var x2:int
var y2:int
x:=65
y:=330
x2:=45
y2:=330
%Declarations and Assignments
porsche := Pic.FileNew("porsche.gif")
vette:=Pic.FileNew("corvette.gif")
backdrop := Pic.FileNew("Backdrop.jpg")
porschectrl :=Sprite.New(porsche)
vettectrl :=Sprite.New(vette)
%Background
Pic.Draw(backdrop,0,0,picXor)
%Key Controls
loop
Sprite.SetPosition (porschectrl,x,y,false)
Sprite.Show(porschectrl)
Input.KeyDown (sprite)
if sprite (KEY_UP_ARROW) then
y := y+5
delay(50)
elsif sprite (KEY_DOWN_ARROW) then
y :=y-5
delay (50)
elsif sprite (KEY_LEFT_ARROW) then
x :=x-5
delay(50)
elsif sprite (KEY_RIGHT_ARROW) then
x:=x+5
delay(50)
end if
Sprite.SetPosition (vettectrl,x2,y2,false)
Sprite.Show(vettectrl)
Input.KeyDown (sprite2)
if sprite2 ("w") then
y2 := y2+5
delay(50)
elsif sprite ("s") then
y2 :=y2-5
delay (50)
elsif sprite ("a") then
x2 :=x2-5
delay(50)
elsif sprite ("d") then
x2:=x2+5
delay(50)
end if
end loop
Sponsor
Sponsor
Sponsor
sponsor
Tony




PostPosted: Mon Jan 10, 2011 7:13 pm   Post subject: Re: Turing Multiple Sprites Problem (Illegal photo ID)

kwanzahh @ Mon Jan 10, 2011 7:05 pm wrote:
But the picture is the exact same name and it's in the same folder

porsche := Pic.FileNew("porsche.gif")
vette:=Pic.FileNew("corvette.gif")
...
porschectrl :=Sprite.New(porsche)
vettectrl :=Sprite.New(vette)

Those look like different source images. There is a non-zero chance that Turing fails to load that particular .gif file.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
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  [ 2 Posts ]
Jump to:   


Style:  
Search: