Posted: 23rd May 2009 14:46
Hi All, I'm so nearly finished my first game but cannot seem to work out whats going wrong with this sprite code. The problem manisfests itself in two ways. Either when I exit the inventory screen, the game freezes (white screen) or if this doesnt happen then the third time (and its always the third), I enter the inventory sub I get the error message "bob does not exist" which I know relates to sprites.
The full code is too large to reproduce here in its entirity so I'm hoping someone might be able to see something obvious thats wrong with these sprites.
Thanks in advance
The Code...
MAIN LOOP
Landsize=5000
set camera range 10,Landsize*2
"If click on backpack icon then gosub Inventory"
END MAIN LOOP
Inventory:
set camera range 1,3000
backdrop on
while...
....
..
if Mouseclick()=0 then ObjectRelease=0
for i = 1 to 16
If ValidSlot=0: Rem ie not a backpack spot availabel only for big backpacks
if MX>HandItem(i,4)-sprite width(HandItem(i,1))/2 and MX<HandItem(i,4)+sprite width(HandItem(i,1))/2
if MY>HandItem(i,5)-sprite height(HandItem(i,1))/2 and MY<HandItem(i,5)+sprite height(HandItem(i,1))/2
if objectpickup(1)=0 or objectpickup(1)<>Handitem(i,1)
type=HandItem(i,2)
No=HandItem(i,3)
gosub handweapons
text 810,380,name$
for z = 1 to 7
gosub yellow:if val(Attr$(z,2))>0 then gosub red
text 810,380+z*20,Attr$(z,1)
next z
endif
if mouseclick()=1 and ObjectRelease=0
ObjectRelease=1
if ObjectPickUp(1)=0
if HandItem(i,2)<>0
for z = 1 to 28
ObjectPickup(z) = HandItem(i,z)
next z
endif
else
ValidDrop=0
if ObjectPickUp(11)>0 and ObjectPickUp(11)=HandItem(i,2) then ValidDrop=1
if HandItem(i,11)>0 and HandItem(i,11)=ObjectPickUp(2) then ValidDrop=1
if ObjectPickUp(1)>6110
if Handitem(i,6)>Dex then Validdrop=0
if Handitem(i,7)>Int then Validdrop=0
if Handitem(i,8)>Cha then Validdrop=0
if Handitem(i,9)>Ant then Validdrop=0
if Handitem(i,10)>Str then Validdrop=0
endif
if Handitem(i,1)>6110
if ObjectPickUp(6)>Dex then Validdrop=0
if ObjectPickUp(7)>Int then Validdrop=0
if ObjectPickUp(8)>Cha then Validdrop=0
if ObjectPickUp(9)>Ant then Validdrop=0
if ObjectPickUp(10)>Str then Validdrop=0
endif
if ObjectPickUp(1)<6111 and i<11 then ValidDrop=1
if ObjectPickUp(1)-6100=i then ValidDrop=1
If ValidDrop=1
OldObj=ObjectPickUp(1)-6100
ObjectPickUp(1)=0
for z = 2 to 28
if z<>4 and z<>5
HandItem(OldObj,z)=HandItem(i,z)
HandItem(i,z)=ObjectPickUp(z)
ObjectPickUp(z)=0
endif
next z
sprite HandItem(i,1),HandItem(i,4),HandItem(i,5),HandItem(i,12)
sprite HandItem(OldObj,1),HandItem(OldObj,4),HandItem(OldObj,5),HandItem(OldObj,12)
endif
endif
endif
endif
endif
endif
next i
if objectpickup(1)>0
Sprite objectpickup(1),MX,MY,objectpickup(12)
type=ObjectPickUp(2)
No=ObjectPickUp(3)
gosub handweapons
Gosub Green
text 810,520,name$
for z = 1 to 7
gosub yellow:if val(Attr$(z,2))>0 then gosub red
text 810,520+z*20,Attr$(z,1)
next z
endif
Endif
sync
endwhile
backdrop off
set camera range 10,Landsize*2
Return