My guess would be that in your code you are altering the value of the variable 'hunger' so it becomes negative.
When you hit the line:
Stretch Sprite 22,hunger,100
it causes the runtime error. To test this, immediately before the stretch sprite line add the line:
If hunger < 0 Then End
If the program stops before erroring then that is the problem.
Are you altering the value of hunger anywhere else in your program?
wait 0001
If hunger_Dec > 0 Then Dec hunger_Dec
If hunger_Dec = 0
hunger = hunger - Rnd(5)
if hunger<0 then hunger=0
If hunger < 0 Then End: Rem This line is ignored if hunger is a legal value
Stretch Sprite 22,hunger,100
hunger_Dec = 100
EndIf
If hunger<10
if foodwaterx-x<>0 : `check if the dog’s at the right x position. If not then…
x=x+((foodwaterx-x)/ABS(foodwaterx-x))
endif
if foodwatery-y<>0 : `check if the dog’s at the right y position. If not then…
y=y+((foodwatery-y)/ABS(foodwatery-y))
endif
Endif
You do a range check immediately after the line
hunger = hunger - Rnd(5) but you might not be doing it elsewhere in your program after altering the hunger variable.
This is the only thing I can think of that might be causing the problem.
TDK_Man