pic rotate help
Author |
Message |
shoobyman
|
Posted: Thu Dec 07, 2006 10:09 am Post subject: pic rotate help |
|
|
code: | setscreen ("offscreenonly")
var angle : int := 0
var velx, vely := 0
var chars : array char of boolean
var pic : int
pic := Pic.FileNew ("ship.bmp")
loop
Input.KeyDown (chars)
View.Update
delay (30)
cls
Pic.Draw (pic , 100, 100, picCopy)
pic := Pic.Rotate (pic, angle, 23, 33)
if chars (KEY_LEFT_ARROW) then
angle := 10
elsif chars (KEY_RIGHT_ARROW) then
angle := -10
else
angle := 0
end if
end loop
|
when i run it, if i press the arrow key (other than the pic looking bad), it gives me an error after a few seconds it gives me this error
"illegal picID number "0" (probable cause picture was not successfully created)"
anyone know how to fix it? |
|
|
|
|
|
Sponsor Sponsor
|
|
|
NikG
|
Posted: Thu Dec 07, 2006 3:44 pm Post subject: Re: pic rotate help |
|
|
shoobyman wrote: code: | setscreen ("offscreenonly")
var angle : int := 0
var velx, vely := 0
var chars : array char of boolean
var pic : int
pic := Pic.FileNew ("ship.bmp")
loop
Input.KeyDown (chars)
View.Update
delay (30)
cls
Pic.Draw (pic , 100, 100, picCopy)
pic := Pic.Rotate (pic, angle, 23, 33)
if chars (KEY_LEFT_ARROW) then
angle := 10
elsif chars (KEY_RIGHT_ARROW) then
angle := -10
else
angle := 0
end if
end loop
|
Your code is kinda all-over-the-place, and I'm almost positive that's why you're getting the error. Here's a cleaner (and probably less error prone) version: code: | loop
Input.KeyDown (chars)
if chars (KEY_LEFT_ARROW) then
angle := 10
pic := Pic.Rotate (pic, angle, 23, 33)
elsif chars (KEY_RIGHT_ARROW) then
angle := -10
pic := Pic.Rotate (pic, angle, 23, 33)
else
angle := 0
pic := Pic.Rotate (pic, angle, 23, 33)
end if
Pic.Draw (pic , 100, 100, picCopy)
View.Update
delay (30)
cls
end loop
| Your order of command was weird. Why would you update an empty screen, delay, clear the screen, then draw the pic, then change the angle??? Also, notice how I made it change the angle only if there is input? |
|
|
|
|
|
NikG
|
Posted: Thu Dec 07, 2006 3:47 pm Post subject: (No subject) |
|
|
Actually, now I know why you're gettin the error.
It's because of your else clause in the if statement. Remove it!
You shouldn't get the error with my code anymore, but it's not proper.
And it doesn't make sense to keep resetting the angle to 0 if there's no input. |
|
|
|
|
|
shoobyman
|
Posted: Thu Dec 07, 2006 5:51 pm Post subject: (No subject) |
|
|
thanks, everything works (and I fixed the ungly picture problem) |
|
|
|
|
|
|
|