Zit Zapper Game

Blitz3D Forums/Blitz3D Beginners Area/Zit Zapper Game

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

Zit Zapper is a simple game based on images and simple maths collision. The game play elements are simple: zap the zits as they pop up with your mouse. The game increases with difficulty with time. Earn bonuses or penalties dependent on the Zits that remain with each wave.

The ideas here is to add game play elements and watch this simple 99 line code game evolve in many directions based on simple collision interactivity. Add movement, images, sound, controls, etc.
AppTitle("ZitZapper")
HidePointer()

Graphics 300,200,16,2
SetBuffer(BackBuffer())

Type zit
	Field x
	Field y
	Field state
End Type
zitsize=16
zitspawntime=64
zitspawntimer=zitspawntime
zitwave=24
zitwavecounter=0

zapperwavecounter=1
zapperradius#=zitsize+1.5

;main looop
While Not KeyDown(1)

	Cls()
	
	;DrawImage Pic_Of_Unfavorable_Person_Here,0,0
	
	;create new zit
	If Not zitspawntimer 
		zit.zit = New zit
		zit\x=Rnd(GraphicsWidth()-zitsize)
		zit\y=Rnd(GraphicsHeight()-zitsize)
		zit\state=1;alive
		zits=zits+1
		zitwavecounter=zitwavecounter+1
		zitspawntimer=zitspawntime
	Else
		zitspawntimer=zitspawntimer-1	
	EndIf
	
	If zitwavecounter = zitwave
		zapperwavecounter=zapperwavecounter+1
		zitspawntime=zitspawntime-4
		zitspawntimer=zitspawntime
		If zits<=2 
			zapperpoint=zapperpoint+(1000*zapperwavecounter) ;bonus
		EndIf	
		zitwavecounter=0	
	EndIf
	
	;zapperper position
	zapperx=MouseX()
	zappery=MouseY()	
	zapperb1=MouseHit(1) Or KeyHit(57)
	
	;zit draw and collision detection	
	For zit.zit = Each zit
		Select zit\state

			Case 1;alive
				;draw
				Color(255,0,0)
				Oval(zit\x,zit\y,zitsize,zitsize,True)
				;collision
				
				If ( (zapperx-(zit\x+(zitsize/2)))*(zapperx-(zit\x+(zitsize/2))) + (zappery-(zit\y+(zitsize/2))) *(zappery-(zit\y+(zitsize/2))) )  < (zapperradius*zapperradius) ;http://freespace.virgin.net/hugo.elias/routines/r_dist.htm
					If zapperb1 
						zit\state=0;dying
						zits=zits-1
						zapperpoint=zapperpoint+ 25*zapperwavecounter
					EndIf		
				EndIf
				
			Case -16;dead
				Delete zit
				
			Default;dying
				zit\state=zit\state-1
				zitflash=255-zitflash
				Color(zitflash,zitflash,0)
				Oval(zit\x,zit\y,zitsize,zitsize,True)
				
		End Select			
				 
	Next
	
	If zits<>10
		AppTitle("ZitZapper S:"+zapperwavecounter+" N:"+zitwavecounter+" Z:"+zits+" P:"+zapperpoint)
		Color(0,255,0)
		Line zapperx-(zapperradius/3),zappery-(zapperradius/3),zapperx+(zapperradius/3),zappery+(zapperradius/3)
		Line zapperx-(zapperradius/3),zappery+(zapperradius/3),zapperx+(zapperradius/3),zappery-(zapperradius/3)
	Else
		AppTitle("ZitZapper GAME OVER: "+zapperpoint)
		Color(255,255,0) 
		Text(GraphicsWidth()/2,GraphicsHeight()/2,"GAME OVER",1,1)
		Flip()
		WaitKey()
		End
	EndIf
	
	If KeyDown(57) WaitKey()
	
	
	Flip()
	
Wend
Controls: Mouse & LMB