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

Username:   Password: 
 RegisterRegister   
 After I jump in my program it crashes if i try to run....
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
1kd7




PostPosted: Wed Oct 15, 2014 1:28 pm   Post subject: After I jump in my program it crashes if i try to run....

What is it you are trying to achieve?
After I jump in my program it crashes if i try to run....
The error says Illegal Picture ID number....



Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)

Turing:


var R,x,S :int:=1
var y :int:=40
var mx, my, button : int
var ex : int := maxx-30
var ey : int := 10
var speed :int:=7
View.Set("graphics:1250;400,offscreenonly")
var move : array char of boolean
var platform:boolean:=false
var LinkRun1 : int := Pic.FileNew ("LinkRun1.bmp")
var LinkRun2 : int := Pic.FileNew ("LinkRun2.bmp")
var LinkRun3 : int := Pic.FileNew ("LinkRun3.bmp")
var LinkRun4 : int := Pic.FileNew ("LinkRun4.bmp")
var LinkRun5 : int := Pic.FileNew ("LinkRun5.bmp")
var LinkRun6 : int := Pic.FileNew ("LinkRun6.bmp")
var LinkJump : int := Pic.FileNew ("LinkJump.bmp")
var LinkJumpL : int := Pic.FileNew ("LinkJump.bmp")
var LinkRunL1 : int := Pic.FileNew ("LinkRunL1.bmp")
var LinkRunL2 : int := Pic.FileNew ("LinkRunL2.bmp")
var LinkRunL3 : int := Pic.FileNew ("LinkRunL3.bmp")
var LinkRunL4 : int := Pic.FileNew ("LinkRunL4.bmp")
var LinkRunL5 : int := Pic.FileNew ("LinkRunL5.bmp")
var LinkRunL6 : int := Pic.FileNew ("LinkRunL6.bmp")
var LinkStand : int := Pic.FileNew ("LinkStand.bmp")
var LinkStandL : int := Pic.FileNew ("LinkStandL.bmp")
var LinkSlash1 : int := Pic.FileNew ("LinkSlash1.bmp")
var LinkSlash2 : int := Pic.FileNew ("LinkSlash2.bmp")
var LinkSlash3 : int := Pic.FileNew ("LinkSlash3.bmp")
var LinkSlash4 : int := Pic.FileNew ("LinkSlash4.bmp")
var LinkSlash5 : int := Pic.FileNew ("LinkSlash5.bmp")
var LinkSlashL1 : int := Pic.FileNew ("LinkSlash1L.bmp")
var LinkSlashL2 : int := Pic.FileNew ("LinkSlash2L.bmp")
var LinkSlashL3 : int := Pic.FileNew ("LinkSlash3L.bmp")
var LinkSlashL4 : int := Pic.FileNew ("LinkSlash4L.bmp")
var LinkSlashL5 : int := Pic.FileNew ("LinkSlash5L.bmp")
var Platform : boolean

Pic.SetTransparentColor (LinkJump,white)
Pic.SetTransparentColor (LinkRun1,white)
Pic.SetTransparentColor (LinkRun2,white)
Pic.SetTransparentColor (LinkRun3,white)
Pic.SetTransparentColor (LinkRun4,white)
Pic.SetTransparentColor (LinkRun5,white)
Pic.SetTransparentColor (LinkRun6,white)
Pic.SetTransparentColor (LinkRunL1,white)
Pic.SetTransparentColor (LinkRunL2,white)
Pic.SetTransparentColor (LinkRunL3,white)
Pic.SetTransparentColor (LinkRunL4,white)
Pic.SetTransparentColor (LinkRunL5,white)
Pic.SetTransparentColor (LinkRunL6,white)
Pic.SetTransparentColor (LinkStand,white)
Pic.SetTransparentColor (LinkStandL,white)
Pic.SetTransparentColor (LinkSlash1,white)
Pic.SetTransparentColor (LinkSlash2,white)
Pic.SetTransparentColor (LinkSlash3,white)
Pic.SetTransparentColor (LinkSlash4,white)
Pic.SetTransparentColor (LinkSlash5,white)
Pic.SetTransparentColor (LinkSlashL1,white)
Pic.SetTransparentColor (LinkSlashL2,white)
Pic.SetTransparentColor (LinkSlashL3,white)
Pic.SetTransparentColor (LinkSlashL4,white)
Pic.SetTransparentColor (LinkSlashL5,white)

procedure BG
Pic.ScreenLoad("BG.bmp",0,0,picMerge)
end BG


process music
loop
Music.PlayFile ("MS.mp3")
end loop
end music

procedure Stand
cls
BG
Pic.Draw(LinkStand,x,y,picMerge)
View.Update
end Stand

procedure StandL
cls
BG
Pic.Draw(LinkStandL,x,y,picMerge)
View.Update
end StandL

procedure RunRight
var LinkRun : int := Pic.FileNew ("LinkRun"+intstr(R)+".bmp")
[color=red][b]Pic.Draw(LinkRun,x,y,picMerge)[/b][/color]
View.Update
delay(95)
cls
BG
R:=R+1
x:=x+speed
if R = 6 then
R:=1
end if
end RunRight

procedure RunLeft
var LinkRunL : int := Pic.FileNew ("LinkRunL"+intstr(R)+".bmp")
Pic.Draw(LinkRunL,x,y,picMerge)
View.Update
delay(95)
cls
BG
R:=R+1
x:=x-speed
if R = 6 then
R:=1
end if
end RunLeft

[color=red][b]procedure JumpRight
Platform:= false
for i:1..5
BG
Pic.Draw(LinkJump,x,y,picMerge)
View.Update
delay(95)
cls
R:=R+1
x:=x+speed
y:=y+speed*2
end for
end JumpRight[/b]
[/color]
procedure Fall
y:=y-speed*2
end Fall

procedure SlashRight
Pic.Draw(LinkSlash1,x,y,picMerge)
View.Update
delay(95)
cls
BG
Pic.Draw(LinkSlash2,x,y,picMerge)
View.Update
delay(95)
cls
BG
Pic.Draw(LinkSlash3,x,y,picMerge)
View.Update
delay(95)
cls
BG
Pic.Draw(LinkSlash4,x,y,picMerge)
View.Update
delay(95)
cls
BG
Pic.Draw(LinkSlash5,x,y,picMerge)
View.Update
delay(95)
cls
BG
end SlashRight

procedure SlashLeft
Pic.Draw(LinkSlashL1,x,y,picMerge)
View.Update
delay(95)
cls
BG
Pic.Draw(LinkSlashL2,x,y,picMerge)
View.Update
delay(95)
cls
BG
Pic.Draw(LinkSlashL3,x,y,picMerge)
View.Update
delay(95)
cls
BG
Pic.Draw(LinkSlashL4,x,y,picMerge)
View.Update
delay(95)
cls
BG
Pic.Draw(LinkSlashL5,x,y,picMerge)
View.Update
delay(95)
cls
BG
end SlashLeft

fork music

loop
if y=40 then
Platform:= true
end if
if Platform = false then
Fall
end if
Input.KeyDown (move)
if move('d') then
RunRight
elsif move('a') then
RunLeft

elsif move ('w') then
JumpRight

elsif move(' ') then
Mouse.Where (mx, my, button)

if mx<x then
SlashLeft
elsif mx>x then
SlashRight
end if

else
Mouse.Where (mx, my, button)
if mx<x then
StandL
elsif mx>x then
Stand

end if
end if

end loop




Please specify what version of Turing you are using
4.1.1
Sponsor
Sponsor
Sponsor
sponsor
Tony




PostPosted: Wed Oct 15, 2014 2:05 pm   Post subject: RE:After I jump in my program it crashes if i try to run....

code:

procedure RunRight
var LinkRun : int := Pic.FileNew ("LinkRun"+intstr(R)+".bmp")

Pic.FileNew loads an image as an asset, and gives you an integer ID, to refer to that asset later. Turing has a limit of ~1000 such IDs.

Since you images don't change, there is really no need to load the same images again and again and again, inside of a loop. Your game basically has a lifespan of ~1000 steps.

Besides, you've already loaded all of the images at the top of the program.
code:

var LinkRun1 : int := Pic.FileNew ("LinkRun1.bmp")
var LinkRun2 : int := Pic.FileNew ("LinkRun2.bmp")
var LinkRun3 : int := Pic.FileNew ("LinkRun3.bmp")
var LinkRun4 : int := Pic.FileNew ("LinkRun4.bmp")
var LinkRun5 : int := Pic.FileNew ("LinkRun5.bmp")
var LinkRun6 : int := Pic.FileNew ("LinkRun6.bmp")
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: