This was the prototype.
[pbcode]
; PROJECT : sniper
; AUTHOR : monkeybot
; CREATED : 24/02/2012
; EDITED : 01/06/2013
; ---------------------------------------------------------------------
explicit on
Constant headRadius=8
Constant Difficulty=5
global gametime
global startofFrame
global playerX
global playerY
global sw=GetscreenWidth();/2
global sh=GetscreenHeight();/2
global bh;=newfxImage(500,500);loadnewfximage("C:\Users\jasonp\Desktop\playbasic\myprogs\in progress\sniper\sniper.tga")
global PersonImage=newfximage(headRadius*2,headRadius*4)
global BadPersonImage=newfximage(headRadius*2,headRadius*4)
global badguys
global TownSprite
;global score=0
global GunLatch=false
global t=timer()
mouse off
type tTimerReport
func$,time
endtype
;type tBulletHole
; x,y
;endtype
;type tBuilding
; x,y,height,width,winCntX,winCntY
;endtype
type tWindow
x,y,xSize,ySize,minX,MaxX
endtype
type tPerson
pType,pMode,x#,y#,speed#,ammoCount,minX,maxX,score,firepos,countdownTimer,shots,spr
endtype
constant pModeWalk=1
constant pModeFire=2
constant pModeDuck=3
type tPlayer
x,y,GunLatch,score,lives
endtype
dim player as tPlayer list
;endfunction minx#,maxX#,miny#,maxy#,count
;function drawAst(x#,y#,count,minx#,maxX#,miny#,maxy#)
player=new Tplayer
player.lives=3
dim lx#(360)
dim ly#(360)
dim bh(20)
;prepbh()
dim Window as tWindow list
;dim Building(20) as tBuilding
dim person as tPerson list
;dim Bullethole as tBulletHole list
dim timerReport as tTimerReport list ;x y w h w w
global town=NewFXImage(sw,sh)
global sight =NewFXImage(10,10)
global sightSpr
setfps (50)
repeat
initstuff()
DoSetup()
gameloop()
gameover()
until false
end
Function initStuff()
prepbh()
player.lives=3
t=timer()
player.score=0
gametime=0
endfunction
Function gameLoop()
local incr
local loopincr
randomize timer()
; local gametime
local gametimer=timer()
repeat
playerx=mousex()
playery=mousey()
if timer()-gametimer>1000
gametime++
gametimer=timer()
endif
PositionSprite sightSpr,playerx,playery
cls
; resetTimerReport()
; makeTimerReport("loop start")
; DrawImage town,0,0,1
if timer()>t
DeployAtRandomWin2()
t=timer()+(200*difficulty)
endif
; makeTimerReport("display peoples")
DisplayPeoples()
; DrawImage town,0,0,1
;if not LeftMouseButton(); and gunLatch=true
; gunLatch=false
;endif
; #cls
incr+=fps()
inc loopincr
; #print "Gt "+str$(gametime)+" "+"fps "+str$(fps() )+" Avg "+str$(incr/loopincr)
; #print "listSize "+str$(GetListSize(person()) )
if LeftMouseButton() and GunLatch=false
gunlatch=true
fireGun()
if PointHitSprite(playerx,playery,townSprite)
RenderToImage town
inkmode 1
circlec playerx,playery,5,1,$0
RenderToScreen
endif
endif
if RightMouseButton()
; bulletHole=new tBulletHole
; bullethole.x=rnd(sw)
; bullethole.y=rnd(sh)
MakeBulletHole()
endif
if not LeftMouseButton(); and gunLatch=true
gunLatch=false
endif
; makeTimerReport("DisplayBulletholes")
; DisplayBulletholes()
DrawAllSprites
drawsprite sightSpr
;DrawImage bh,900,200,1
; displayTimerReports()
ink $ffffff
text 300,10,"SCORE "+str$(player.score)
text 300,20,"FPS "+str$(fps())
text 300,30,"Active People "+str$(GetListSize(person()))
text 300,40,"Targets "+str$(badguys)
text 300,50,"GameTime "+str$(Gametime)
text 300,60,"player.lives "+str$(player.lives)
sync
until player.lives=0
EndFunction
function gameover()
cls
Print "you scored : "+str$(player.score)
Print "you lasted : "+str$(gametime)+" seconds"
print "press any key to continus"
sync
waitnokey
waitkey
cleartypes()
EndFunction
function cleartypes()
for each person()
person=null
next
for each window()
window=null
next
endfunction
Function resetTimerReport()
for each timerReport()
timerReport=null
next
startofFrame=timer()
endfunction
Function spriteTown()
endfunction
Function makeTimerReport(s$)
local oldtime
if GetListSize(timerReport())>0
oldtime=timerReport.time
endif
timerReport=new tTimerReport
timerReport.time=timer()-startofFrame
timerReport.func$=s$
;startofFrame=timer()-timerReport.time
endfunction
Function displayTimerReports()
local y,q;=0
#cls
for q=0 to GetListSize(timerReport())
SetListPos timerReport(),q
;text 600,y*10,timerReport.func$
;text 800,y*10,str$( timerReport.time)
#print timerReport.func$+" "+str$(timerReport.time)
inc y
next
endfunction
Function MakeBulletHole()
rendertoimage town
; inkmode 33
; inkalpha 0.80
DrawImage bh(rnd(20)),rnd(sw-100),rnd(sh-100),1
RenderToScreen
endfunction
Function DoSetup()
RenderToImage town
cls $0
inkmode 1
MakeBuilding(00,600,300,600,5,9)
MakeBuilding(300,600,150,500,3,7)
MakeBuilding(450,600,250,450,3,9)
MakeBuilding(700,600,100,550,1,6)
ImageMaskColour town,$111111
townSprite=newSprite(sw,sh,town)
positionsprite townSprite,0,0
SpriteCollisionMode townSprite,6
constant sightS=5
local temp=newfxImage(sightS*2,sightS*2,0)
rendertoimage temp
cls $111111
ink $ff0000
circle sightS,sightS,sightS,0;,$ff0000
line sightS,0,sightS,sightS*2
line 0,sightS,sightS*2,sightS
ImageMaskColour temp,$111111
;ImageMaskColour bh,$ffffff
sightSpr=NewSprite(10,10,temp)
SpriteDrawMode sightSpr,2
CenterSpriteHandle sightSpr
#print sightSpr
rendertoimage personImage
ink $ffffff
circle headRadius*2/2,headRadius,headRadius,1
circle headRadius*2/2,(Headradius*2)+(Headradius/4),headRadius-3,1
rendertoimage BadpersonImage
ink $660000
circle headRadius*2/2,headRadius,headRadius,1
circle headRadius*2/2,(Headradius*2)+(Headradius/4),headRadius-3,1
rendertoscreen
endfunction
;constant pModeWalk=1
;constant pModeFire=2
;constant pModeDuck=3
function DisplayPeoples()
for each person()
select person.ptype
case 0
case 1
case 2
if person.x#>person.firepos-2 and person.x#<person.firepos+2 then person.pmode=pModeFire
endselect
select person.pMode
case pModeWalk
person.x#+=person.speed#
case pModeFire
;person.colour=rndrgb()
SpriteFlashColour person.spr,$ff0000
SpriteDrawMode person.spr,2+1024
if person.countDownTimer=0
person.countDownTimer=timer()+2000
endif
if timer()> person.countDownTimer; and person.countDownTimer<>0
deletesprite person.spr
person=null
person.pMode=pModeWalk
person.countDownTimer=0
makeBulletHole()
player.lives-=1
goto skip
endif
case pModeDuck
EndSelect
;circle person.x#,person.y#,headRadius,1
; circle person.x#,person.y#+headradius+3,headRadius-3,1
;spritecol
PositionSprite person.spr,person.x#,person.y#
if person.x#<person.minX or person.x#>person.maxX
DeleteSprite person.spr
person=NULL;.pType=0
endif
;circlec person.firepos,person.y#,5,0,person.colour
skip:
next
; unlockbuffer
EndFunction
Function fireGun()
; print "bang"
for each person()
;if CircleHitSprite(person.x#,person.y#,headRadius,SightSpr)
if PointHitSprite (PlayerX,PlayerY,person.spr)
player.score+=person.score
deletesprite person.spr
person=null
if person.ptype=2 then badguys--
endif
next
endfunction
Function HostageSitualtion(num,offset)
local px#,pspeed#
;num,offset)
; local q
setlistpos window(),rnd(GetListSize(window()) )
if rnd(50)>25
px#=window.x-(window.xSize+headRadius)
pspeed#=rndRange#(0.05,0.2)
else
px#=window.x+(window.xSize+headRadius)
pspeed#=-rndRange#(0.05,0.2)
endif
person = new tPerson
person.x#=px#
person.Speed#=pspeed#
;for q=0 to num
person = new tPerson
person.x#=px#
person.Speed#=pspeed#
; print "deciding"
person.y#=window.y
person.pType=rnd(2)
; person.Colour=$00FFFF
person.score=-1
if person.pType=2
; person.Colour=$ff0000
person.speed#*=2;rndRange#(-0.6,0.6)
person.score=2
badguys++
endif
person.minx=window.minX-headradius
person.maxX=window.maxX
person.pMode=pModeWalk
person.firePos=window.x ;( (((window.x+(window.xSize/2)))) - (((window.x-(window.xSize)/2))) ) ;( (((window.x+window.xSize)/2)-2) - (((window.x-window.xSize)/2)+2) )
; next
endfunction num
Function DeployAtRandomWin()
setlistpos window(),rnd(GetListSize(window()) )
person = new tPerson
if rnd(50)>25
person.x#=window.x-(window.xSize+headRadius)
person.speed#=rndRange#(0.05,0.2)
else
person.x#=window.x+(window.xSize+headRadius)
person.speed#=-rndRange#(0.05,0.2)
endif
person.spr=newsprite(person.x#,person.y#,personImage)
person.y#=window.y+headradius
person.pType=rnd(2)
person.score=-1
if person.pType=2
person.speed#*=2
person.score=2
badguys++
person.spr=newsprite(person.x#,person.y#,BadpersonImage)
endif
person.minx=window.minX-headradius
person.maxX=window.maxX
person.pMode=pModeWalk
person.firePos=window.x
spritedrawmode person.spr,0
CenterSpriteHandle person.spr
endfunction num
Function DeployAtRandomWin2()
setlistpos window(),rnd(GetListSize(window()) )
person = new tPerson
local speed#=rndRange#(0.05,0.2)
if rnd(50)>25
person.x#=window.x-(window.xSize+headRadius)
person.speed#=speed#
else
person.x#=window.x+(window.xSize+headRadius)
person.speed#=-speed#
endif
person.pType=rndrange(1,2)
select person.ptype
;case 0
; #print "select 0"
case 1 ;member of pub
#print "select 1"
person.score=-1
person.spr=newsprite(person.x#,person.y#,personImage)
case 2 ;bad dude
#print "select 2"
person.score=2
person.spr=newsprite(person.x#,person.y#,BadpersonImage)
person.speed#*=2
badguys++
endselect
;default
person.y#=window.y+headradius
person.minx=window.minX-headradius
person.maxX=window.maxX
person.pMode=pModeWalk
person.firePos=window.x
spritedrawmode person.spr,0
CenterSpriteHandle person.spr
;endselect
endfunction num
Function MakeBuilding(x,y,width,height,winCntX,winCntY)
local x2=x+width
local y2=y-height
local winx,winy
local wx,wx1,wy,wy1
ink $ffffff
local q=rndrange($30,$60)
boxc x,y,x2,y2,1,rgb(q,q,q);$003300;+width,y-height
local winXsize=width /(winCntX+1)
local winYsize=abs(height)/(winCntY+2)
ink $ff0000
x=x+winxSize/2
y=y-winySize/2
for winy=winCntY+1 to 2 step -1
for winx=0 to winCntX step 2
wx=x+(winx*(winXsize)); wy=
wy= y-(winy*(winysize))
wx1= x +(winx*(winXsize))+winXsize
wy1= y -(winy*(winysize))+(winysize/2)
boxc wx,wy,wx1,wy1,1,$111111
boxc wx,wy,wx1,wy1,0,$ffffff
window = new tWindow
window.x=x+(winx*(winXsize))+winxSize/2
window.y=y-(winy*(winysize))+winySize/4
window.xSize=winxSize
window.xSize=winySize/2
window.MinX=x
Window.MaxX=x+(width-winxSize)
next
next
endfunction
Function prepBH()
local z
for z=0 to 20
bh(z)=buildBH()
next
endfunction
Function buildBH()
local minx#,maxX#,miny#,maxy#,count,trash
local bhImage
minx#,maxX#,miny#,maxy#,count=makeAst3(50,8,40);radius#,jagX#,jagY#)
bhImage=newfxImage(maxX#-minx# ,maxy#-miny#)
rendertoimage bhImage
drawast((maxX#-minx#)/2 ,(maxy#-miny#)/2,count,minx#,maxX#,miny#,maxy#);x,y,count,min,min,max,max
trash,trash,trash,trash,count=makeAst3(30,5,5)
drawast(GetImageWidth(bhImage)/2,getimageheight(bhImage)/2,count,minx#,maxX#,miny#,maxy#)
rendertoscreen
endfunction BhImage
Function makeAst3(radius#,jagX#,jagY#)
local minx#=1000
local miny#=1000
local maxX#,maxY#
local deg#,jy#;,q;,x2#,y2#
local q,count=1
local speed#,angle#
repeat
jy#=1+rnd#(jagy#) ;random indent
deg#=deg#+1+rnd#(jagX#) ;random length around circumference
lx#(count)=(cos(deg#)*(radius#+jy#))
ly#(count)=(sin(deg#)*(radius#+jy#))
if lx#(count)<minx# then minx#=lx#(count)
if ly#(count)<miny# then miny#=ly#(count)
if lx#(count)>maxX# then maxX#=lx#(count)
if ly#(count)>maxy# then maxy#=ly#(count)
inc count
Until deg#>=359
endfunction minx#,maxX#,miny#,maxy#,count
function drawAst(x#,y#,count,minx#,maxX#,miny#,maxy#)
;rendertoscreen
local q
for q=1 to count-2
line x#+lx#(q),y#+ly#(q),x#+lx#(q+1),y#+ly#(q+1)
; wait 50
; sync
next
line x#+lx#(q),y#+ly#(q),x#+lx#(1),y#+ly#(1)
; boxc x#+minx#,y#+miny#,x#+maxx#,y#+maxy#,0,$ff0000
EndFunction
[/pbcode]
This is the WIP of the new version
The controls are:-
right mouse zooms
mouse wheel=scope range
left mouse fires
download to follow shortly...
Hi All
I could not get mousewheel to do anything and right button only makes more broken glass , don't seem to zoom on targets ?
mick :)
We need the new version, methinks.
Yeah mick that's in the new version.
The listing is the teaser.
If only i could find someone to do some gfx...
Hi all
ahh thought I was missing out on something , well monkeybot I hope new version will be posted soon
and hope you find some gfx's that you want , not easy at all doing them youself as I well know, iv'e been very lucky over the last few years BlinkOk has been about
mick :)
so far, pretty good monkeybot.
This may be necro-posting but I can try to help with GFX depending if they are 2d or not but i'm better at pixel art styled stuff.