Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- View.Set ("graphics:1024;768,position:center;center,nobuttonbar,offscreenonly")
- var circlex, circley, mousex, mousey, button, shootertimer,direcnum,soundcounter : int
- var now, last, count : int := 10
- var direction : string := "right"
- var background : string := "mountain_scenery_-1742.jpg"
- var picID : int
- var picx, picy,i,score : int := 0
- var scored:string
- var stillgood, timeset, buttongood : boolean := false
- var chars : array char of boolean
- shootertimer := maxint
- stillgood:=true
- soundcounter:=1
- picID := Pic.FileNew (background)
- Pic.Draw (picID, picx, picy, picCopy)
- randint (circlex, 100, 980)
- randint (circley, 100, 700)
- process DoMusic
- Music.PlayFile ("gunshotgood.mp3")
- end DoMusic
- process Hit
- locate(15,30)
- put "BAM!"
- end Hit
- procedure drawtarget (circlex, circley : int)
- drawfilloval (circlex, circley, 30, 30, 40)
- drawfilloval (circlex, circley, 25, 25, 0)
- drawfilloval (circlex, circley, 20, 20, 40)
- drawfilloval (circlex, circley, 15, 15, 0)
- drawfilloval (circlex, circley, 10, 10, 40)
- end drawtarget
- loop
- Mouse.Where (mousex, mousey, button)
- drawoval (mousex, mousey, 5, 5, green)
- drawoval (mousex, mousey, 6, 6, green)
- drawline (mousex - 5, mousey, mousex + 5, mousey, green)
- drawline (mousex, mousey - 5, mousex, mousey + 5, green)
- if direction = "right" then
- i := i + 5
- elsif direction = "left" then
- i := i - 5
- end if
- Pic.Draw (picID, picx, picy, picCopy)
- drawtarget (circlex + i, circley)
- Mouse.Where (mousex, mousey, button)
- drawoval (mousex, mousey, 5, 5, green)
- drawoval (mousex, mousey, 6, 6, green)
- drawline (mousex - 5, mousey, mousex + 5, mousey, green)
- drawline (mousex, mousey - 5, mousex, mousey + 5, green)
- delay (20)
- if button = 1 and stillgood = true then
- drawfilloval (mousex, mousey, 2, 2, yellow)
- if Time.Elapsed - shootertimer >= 1000 then
- stillgood := false
- end if
- if timeset = false then
- shootertimer := Time.Elapsed
- fork DoMusic
- timeset := true
- end if
- if mousex > circlex + i - 10 and mousex < circlex + i + 10 and mousey > circley - 10 and mousey < circley + 10 and stillgood = true then
- randint (circlex, 100, 980)
- randint (circley, 100, 700)
- i := 0
- score:=score+1
- randint(direcnum,1,2)
- if direcnum=1 then
- direction:="right"
- else
- direction:="left"
- end if
- end if
- end if
- if button=0 then
- stillgood:=true
- shootertimer:=maxint
- timeset:=false
- end if
- View.Update
- if i >= maxx - circlex - 30 then
- direction := "left"
- elsif i <= 0 - circlex + 30 then
- direction := "right"
- end if
- now := Time.Elapsed
- if (now - last >= 1000) then
- count := count - 1
- locate (1, 1)
- last := now
- if count = 0 then
- cls
- exit
- end if
- end if
- Input.KeyDown (chars)
- if chars (chr (27))
- then
- cls
- exit
- end if
- end loop
- scored:=intstr(score)
- var font1,font2: int
- font2:=Font.New("Arial:80:bold")
- font1 := Font.New ("sans serif:30:bold")
- assert font1 > 0
- Font.Draw ("GAME OVER",180,600,font2,black)
- Font.Draw ("Your Score is: ", 320, 400, font1, black)
- Font.Draw (scored, 610, 398, font1, red)
- Font.Free (font1)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement