Global foodlayer = 1 Type Food Global List:TList = New TList Field x,y Function Create:Food(x,y) Local f:Food = New Food f.x=x f.y=y List.Addlast(f) Return f End Function Function UpdateAll() For Local f:Food = EachIn List f.Update() Next End Function Method Render() SetColor 0,255,0 DrawRect x,y,7,7 SetColor 255,255,255 End Method Method Update() Render() Local Collided:Object[], CollidedObj:Object, G:Gog Collided = CollideRect(X,Y,7,7,FoodLayer,0,Self) For CollidedObj = EachIn Collided If Gog(CollidedObj) Print 1 G = Gog(CollidedObj) G.Energy:+10 Food.List.Remove(Self) Exit End If Next End Method End Type Type Gog Field x,y Field Energy Function Create:gog(x,y) Local g:gog = New gog g.x=x g.y=y Return g End Function Method Update() DrawRect(x,y,7,7) DrawText Energy,x+10,y+10 CollideRect(x,y,7,7,0,FoodLayer,Self) End Method End Type Graphics 800,600,0,-1 For Local I:Int = 0 To 30 Food.Create(Rnd(0,800),Rnd(0,600)) Next Local G:Gog = Gog.Create(MouseX(),MouseY()) While Not KeyHit(key_escape) ResetCollisions() G.X = MouseX() G.Y = MouseY() G.Update() Food.UpdateAll() Flip Cls Wend
I would guess you haven't set the WriteMAsk of the gog to the Foodlayer.