Illegal Picture Id... Again
Author |
Message |
milkislife
|
Posted: Wed May 13, 2009 9:19 am Post subject: Illegal Picture Id... Again |
|
|
This is the program that has illegal picture id problems and also has font never being allocated prolblems.
if you are going to test program the name of pictures in the code will tell you what the pictures are..
if you need further details look at my earlier posts..
peace
Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)
<Answer Here>
Turing: |
var bkg : int
var w : int
var eagle : int
var Pic1, Pic2 : int
var dx, dy, rx, ry : int
var num : int
var x, y, button : int
var timer, point : int
var font1 : int
var s1, s2, s3, s4, s5 : int
var timerout : boolean
timerout := false
font1 := Font.New ("arial:20")
w := Window.Open ("graphics:600;400")
View.Set ("offscreenonly")
process gunshot (song : string)
Music.PlayFile (song )
end gunshot
process bass (song1 : string)
Music.PlayFile (song1 )
end bass
process flim (song2 : string)
Music.PlayFile (song2 )
end flim
procedure deagle
eagle := Pic.FileNew ("deagle2.jpg")
Pic.Draw (eagle, maxx div 2, 1, picCopy)
if x < maxx div 2 then
eagle := Pic.FileNew ("deagle1.jpg")
Pic.Draw (eagle, maxx div 2, 1, picCopy)
end if
if x < maxx div 2 and button = 1 then
fork gunshot ("gun.wav")
eagle := Pic.FileNew ("deagle1 shot.jpg")
Pic.Draw (eagle, maxx div 2, 1, picCopy)
end if
if x > maxx div 2 and button = 1 then
fork gunshot ("gun.wav")
eagle := Pic.FileNew ("deagle2 shot.jpg")
Pic.Draw (eagle, maxx div 2, 1, picCopy)
end if
end deagle
% Deer and Bird
procedure deer
Pic1 := Pic.FileNew ("deer3.jpg")
Pic.Draw (Pic1, dx, dy, picXor)
dx := dx - 15
end deer
procedure bird
Pic2 := Pic.FileNew ("bird.jpg")
Pic.Draw (Pic2, rx, ry, picXor)
rx := rx - 25
end bird
%scope
procedure scope
drawoval (x, y, 50, 50, black)
drawline (x - 50, y, x + 50, y, black)
drawline (x, y - 50, x, y + 50, black)
end scope
procedure timerfive
timer := timer - 1
if timer = 0 then
timerout := true
end if
end timerfive
procedure timerone
timer := timer - 1
if timer = 0 then
timerout := true
end if
end timerone
%Gameplay-5 minute mode
procedure fivemin
point := 0
fork flim ("Flim2.mp3")
loop
rx := Rand.Int (300, 600)
ry := Rand.Int (300, 350)
dx := Rand.Int (300, 600)
dy := Rand.Int (1, 250)
num := Rand.Int (1, 2)
loop
bkg := Pic.FileNew ("forest.jpg")
Pic.Draw (bkg, 1, 1, picCopy)
font1 := Font.New ("arial:20")
timerfive
Mouse.Where (x, y, button )
if num <= 1 then
deer
elsif num = 2 then
bird
end if
Font.Draw ("Timer " + intstr (timer ), maxx - 125, 1, font1, purple)
Font.Draw ("Points " + intstr (point ), 1, 1, font1, purple)
exit when rx < 0
exit when dx < 0
scope
deagle
if button = 1 and x > rx and x < rx + 129 and y > ry and y < ry + 86 then
point := point + 20
elsif button = 1 and x > dx and x < dx + 142 and y > dy and y < dy + 95 then
point := point + 10
end if
if timerout = true then
exit
end if
View.Update
end loop
if timerout = true then
exit
end if
end loop
end fivemin
%Gameplay mode-1 minute mode
procedure onemin
point := 0
fork flim ("Flim2.mp3")
loop
rx := Rand.Int (300, 600)
ry := Rand.Int (300, 350)
dx := Rand.Int (300, 600)
dy := Rand.Int (1, 250)
num := Rand.Int (1, 2)
loop
bkg := Pic.FileNew ("forest.jpg")
Pic.Draw (bkg, 1, 1, picCopy)
font1 := Font.New ("arial:20")
timerone
Mouse.Where (x, y, button )
if num <= 1 then
deer
elsif num = 2 then
bird
end if
Font.Draw ("Timer " + intstr (timer ), maxx - 100, 1, font1, purple)
Font.Draw ("Points " + intstr (point ), 1, 1, font1, purple)
exit when rx < 0
exit when dx < 0
scope
deagle
if button = 1 and x > rx and x < rx + 129 and y > ry and y < ry + 86 then
point := point + 20
elsif button = 1 and x > dx and x < dx + 142 and y > dy and y < dy + 95 then
point := point + 10
end if
if timerout = true then
exit
end if
View.Update
end loop
if timerout = true then
exit
end if
end loop
end onemin
%Gameplay mode-Unlimited time
procedure notime
point := 0
fork flim ("Flim2.mp3")
loop
rx := Rand.Int (300, 600)
ry := Rand.Int (300, 350)
dx := Rand.Int (300, 600)
dy := Rand.Int (1, 250)
num := Rand.Int (1, 2)
loop
bkg := Pic.FileNew ("forest.jpg")
Pic.Draw (bkg, 1, 1, picCopy)
font1 := Font.New ("arial:20")
Mouse.Where (x, y, button )
if num <= 1 then
deer
elsif num = 2 then
bird
end if
Font.Draw (intstr (point ), 1, 1, font1, purple)
exit when rx < 0
exit when dx < 0
scope
deagle
if button = 1 and x > rx and x < rx + 129 and y > ry and y < ry + 86 then
point := point + 20
elsif button = 1 and x > dx and x < dx + 142 and y > dy and y < dy + 95 then
point := point + 10
end if
View.Update
end loop
end loop
end notime
%Game Screen (Game choices)
procedure mainscreen
fork bass ("bass.mp3")
loop
font1 := Font.New ("arial:20")
colourback (white)
cls
Mouse.Where (x, y, button )
Font.Draw ("Hunter!", maxx div 2, maxy - 20, font1, purple)
Font.Draw ("Hunt the mutant animals.....", maxx div 2 - 300, maxy div 2 - 40, font1, purple)
Font.Draw ("WITH A DEAGLE!!", maxx div 2 - 250, maxy div 2 - 70, font1, purple)
Font.Draw ("Choose a game mode!", maxx div 2, maxy - 40, font1, purple)
Font.Draw ("5 Minute Mayhem", maxx div 2, maxy - 100, font1, purple)
Font.Draw ("1 Minute Shoot", maxx div 2, maxy - 130, font1, purple)
Font.Draw ("Unlimited", maxx div 2, maxy - 160, font1, purple)
Font.Draw ("Written and Programed by: Ian Clark", 100, 100, font1, purple)
drawfilloval (maxx div 2 - 20, maxy - 90, 7, 7, brightgreen)
drawfilloval (maxx div 2 - 20, maxy - 120, 7, 7, brightred)
drawfilloval (maxx div 2 - 20, maxy - 150, 7, 7, yellow)
if button = 1 and whatdotcolour (x, y ) = brightgreen then
Music.PlayFileStop
timer := 500
fivemin
exit
elsif button = 1 and whatdotcolour (x, y ) = brightred then
Music.PlayFileStop
timer := 100
onemin
exit
elsif button = 1 and whatdotcolour (x, y ) = yellow then
Music.PlayFileStop
notime
exit
end if
View.Update
cls
end loop
end mainscreen
procedure highscore
cls
font1 := Font.New ("arial:20")
s1 := 1000
s2 := 800
s3 := 600
s4 := 400
s5 := 200
Font.Draw ("High Score!", maxx div 2, maxy - 50, font1, purple)
Font.Draw ("First Place " + intstr (s1 ), maxx div 2 - 20, maxy - 120, font1, purple)
Font.Draw ("Second Place " + intstr (s2 ), maxx div 2 - 20, maxy - 150, font1, purple)
Font.Draw ("Third Place " + intstr (s3 ), maxx div 2 - 20, maxy - 180, font1, purple)
Font.Draw ("Fourth Place " + intstr (s4 ), maxx div 2 - 20, maxy - 210, font1, purple)
Font.Draw ("Fifth Place " + intstr (s5 ), maxx div 2 - 20, maxy - 240, font1, purple)
if point > s5 and point < s4 then
s5 := point
elsif point > s4 and point < s3 then
s4 := point
elsif point > s3 and point < s2 then
s3 := point
elsif point > s2 and point < s1 then
s2 := point
elsif point > s1 then
s1 := point
end if
end highscore
% Game Start
loop
mainscreen
loop
Mouse.Where (x, y, button )
cls
font1 := Font.New ("arial:20")
Font.Draw ("GAME OVER!", maxx div 2, maxy - 20, font1, purple)
Font.Draw ("WANNA PLAY AGAIN?", maxx div 2, maxy - 50, font1, purple)
Font.Draw ("Yes", maxx div 2, maxy - 120, font1, purple)
Font.Draw ("No", maxx div 2, maxy - 150, font1, purple)
drawfilloval (maxx div 2 - 20, maxy - 110, 7, 7, brightgreen)
drawfilloval (maxx div 2 - 20, maxy - 140, 7, 7, brightred)
Font.Draw ("High Scores", 100, 10, font1, purple)
drawfilloval (80, 20, 7, 7, purple)
if button = 1 and whatdotcolour (x, y ) = brightgreen then
timerout := false
mainscreen
elsif button = 1 and whatdotcolour (x, y ) = brightred then
quit
elsif button = 1 and whatdotcolour (x, y ) = purple then
cls
highscore
end if
View.Update
end loop
end loop
|
Please specify what version of Turing you are using
<Answer Here> |
|
|
|
|
|
Sponsor Sponsor
|
|
|
DifinityRJ
|
Posted: Wed May 13, 2009 10:41 am Post subject: Re: Illegal Picture Id... Again |
|
|
Turing: |
procedure deagle
eagle := Pic.FileNew ("deagle2.jpg")
Pic.Draw (eagle, maxx div 2, 1, picCopy)
if x < maxx div 2 then
eagle := Pic.FileNew ("deagle1.jpg")
Pic.Draw (eagle, maxx div 2, 1, picCopy)
end if
if x < maxx div 2 and button = 1 then
fork gunshot ("gun.wav")
eagle := Pic.FileNew ("deagle1 shot.jpg")
Pic.Draw (eagle, maxx div 2, 1, picCopy)
end if
if x > maxx div 2 and button = 1 then
fork gunshot ("gun.wav")
eagle := Pic.FileNew ("deagle2 shot.jpg")
Pic.Draw (eagle, maxx div 2, 1, picCopy)
end if
end deagle
|
I don't understand why you are using the same variable for different pictures, it may cause some problems. |
|
|
|
|
|
milkislife
|
Posted: Wed May 13, 2009 12:35 pm Post subject: Re: Illegal Picture Id... Again |
|
|
It basically changes the direction of the gun, when your pointer is on the left side of the screen the gun points left (it sits at the middle bottem of the screen. When you shoot (click), the gun has a bit of an explosoin coming out of it... thus changes to the Deagle shot(1& 2).
It was tried to put all the varibles at the top (pi1:=pic.new()) so they dont get redeclared, but the problem remained constant. |
|
|
|
|
|
DanTheMan
|
Posted: Thu May 14, 2009 8:29 am Post subject: RE:Illegal Picture Id... Again |
|
|
This may be too simple of an answer, but try changing the pictures to bitmap, and losing the spaces in the picture. I'm not sure why it would give you an illegal picture ID unless there is something wrong with the filepath or file name.
Also, don't forget to put the picture in the same folder as your turing program. |
|
|
|
|
|
Dusk Eagle
|
Posted: Thu May 14, 2009 1:31 pm Post subject: Re: Illegal Picture Id... Again |
|
|
Neither changing the picture to bitmap nor taking out the spaces in the picture will affect anything. Making sure the pictures are in the same directory as your code (or that your code points to the correct directory) could help though. Also, make sure you've typed your picture file names correctly - they're case sensitive. One other thing to watch for is inconsistent use of file extensions: for instance, if your picture is called "forest.jpeg", be sure not to load "forest.jpg".
I haven't run into the font problem yet, but when the above problem is addressed your code will eventually receive a problem stating "Cannot allocate item. Out of id numbers (max 1000)." To solve this, you must Pic.Free a picture once you are done using it. However, rather than constantly loading the picture to memory and then dismissing it, it would probably be a lot better to load the pic files once at the very beginning of your code and then redraw them again and again. This could significantly boost the speed of this program. |
|
|
|
|
|
|
|