;########################
;# Example 1.2 ZoneTest #
;########################
; By Steven Matty
;
; This setsup 12 zones with either cicles or boxes around them
; If the dot comes into contact with one, the screen will flash
; Turn the lights down for a nice strobe :)

VWait 40             ; Wait for disk activity to finish
BLITZ                ; BLITZ!
BitMap 0,320,DispHeight,1    ; Open a 1bitplane bitmap 320x???
BitMapOutput 0
Use BitMap 0
Slice 0,44,320,DispHeight,$fff8,1,8,2,320,320   ; And a slice
Show 0                                          ; Show it
PalRGB 0,1,15,15,15                             ; Set ink 1 to white
Use Palette 0                                   ; Use the palette
ZoneInit 0,12                                   ; Clear Zones 0-12
For n=0 To 12                                   ;
x2.w=Int(Rnd(30))+5                             ;
y2.w=Int(Rnd(30))+5                             ;
x.w=Int(Rnd(320-(x2*2)))                        ;
y.w=Int(Rnd(DispHeight-(y2*2)))                 ;
If x2>=320 Then x2=319                          ;
If y2>=DispHeight Then y2=DispHeight-1          ;
g=Int(Rnd(2))                                   ; Circle or Box
If g=0
  Box x,y,x+x2,y+y2,1
  SetZone n,x,y,x+x2,y+y2                       ; Set Box zone
Else
  Circle x,y,x2,1
  SetZone n,x,y,x2                              ; Set Circular zone
End If
Next n
Mouse On                                        ; Mouse ON
Repeat
xo.w=xm.w
yo.w=ym.w
xm.w=MouseX
ym.w=MouseY
If xo<>xm OR yo<>ym
  Plot xo,yo,0                                  ; Update pointer
  Plot xm,ym,1
EndIf

zn.w=Zone(xm,ym)                                ; Are we in the ZONE?
If zn<>-1 Then Locate 0,0:NPrint "Zone ",zn," hit!" ; Yes!
If zn=-1 Then Locate 0,0:NPrint"            "          ; No!
VWait
Until Joyb(0)                                  ; Until mousebutton
AMIGA
End
