News:

PlayBASIC2DLL V0.99 Revision I Commercial Edition released! - Convert PlayBASIC programs to super fast Machine Code. 

Main Menu

Sniper Game

Started by monkeybot, June 01, 2013, 02:44:19 PM

Previous topic - Next topic

monkeybot

This was the prototype.


PlayBASIC Code: [Select]
; 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())
Login required to view complete source code



monkeybot

#1
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...

micky4fun

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 :)

bmorris

We need the new version, methinks.

monkeybot

#4
Yeah mick that's in the new version.

The listing is the teaser.

If only i could find someone to do some gfx...

micky4fun

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 :)

stevmjon

so far, pretty good monkeybot.
It's easy to start a program, but harder to finish it...

I think that means i am getting old and get side tracked too easy.

LemonWizard

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.