He attacks me, but it's boring
Blitz3D Forums/Blitz3D Programming/He attacks me, but it's boring| 
 | ||
| All, I'm looking for a convincent way to show an attack from a zombie. I have the following code, but I find that the zombie does not scare really. I need something else to add to the scene. What would you do to make it more realistic/entertaining ? The first idea that comes, would be using some blood splatting here and there, to attach to the camera, when the player is attacked. How would you do that ? Using a sprite ? Suggestions are more than welcome. 
Graphics3D 1024,768,0,2
Const Z_IDLE = 11
Const Z_IDLE2 = 12
Const Z_ATTACK = 9
Global current_action = 0
Global type_player = 1
Global type_ground = 2
Global type_pivot = 3
Global type_zombie = 4
Type t_joint
	Field entity
	Field cube
End Type
Global joint.t_joint
sc# = .06
Global zombie = LoadAnimMesh("..\models\zombie\zombie.b3d")
ScaleEntity zombie,sc,sc,sc
PositionEntity zombie,0,0,6
Global player=CreatePivot()
PositionEntity player,0,1,0
TurnEntity player,0,0,0
EntityRadius player,.3
camera=CreateCamera(player )
PositionEntity camera,0,.7,0
CameraRange camera,.1,200
CameraZoom camera,2
EntityParent camera,player
;EntityBox collpivot,EntityX(collpivot),EntityY(collpivot),EntityZ(collpivot),3,3,3
Global plane = CreatePlane()
PositionEntity plane,0,0,0
EntityColor plane,0,0,255
EntityAlpha plane,.3
;tex = CreateTexture(32,32,4)
;SetBuffer TextureBuffer(tex)
;ClsColor 0,0,0
;Cls
;Color 0,255,0
;Rect 0,0,32,32,False
;SetBuffer BackBuffer()
;EntityTexture plane,tex
EntityType zombie,type_zombie
EntityType plane,type_ground
EntityType player,type_player
EntityType plane,type_ground
Collisions type_player,type_ground,2,2
Collisions type_pivot,type_zombie,2,2
Collisions type_player,type_zombie,2,2
extractZombieAnimation()
sp#=.08
gs#=.008
ey#=EntityY(player)
;scanMesh(zombie)
;createcubes()
While Not KeyDown(1)
	yv#=EntityY(player)-ey
	ey=EntityY(player)
	
	If KeyHit(57) yv=.1
	MoveEntity player,0,yv- gs#,0
	If KeyDown(30) TurnEntity camera,-2,0,0
	If KeyDown(44) TurnEntity camera,+2,0,0
	
	If KeyDown(203) TurnEntity player,0,2,0
	If KeyDown(205) TurnEntity player,0,-2,0
	
	If (KeyDown(42)) Or (KeyDown(54)) Then
		If KeyDown(200) MoveEntity player,0,0,sp*2
		If KeyDown(208) MoveEntity player,0,0,-sp*2
	Else
		If KeyDown(200) MoveEntity player,0,0,sp
		If KeyDown(208) MoveEntity player,0,0,-sp
	EndIf
	UpdateWorld
	RenderWorld
	Text 0,0,EntityDistance (player,zombie)
	Text 0,10,EntityY(player)
	
	test_distance()
	Flip
Wend
End
;==========================================
Function test_distance()
;==========================================
If EntityDistance (player,zombie) < 1 Then
	;zombie_action(zombie,Z_ATTACK)
	zombie_action(zombie,Rand(8,10))
Else
	zombie_action(zombie,Z_IDLE)
EndIf
End Function
;==========================================
Function zombie_action(aZombie,action)
;==========================================
If action = current_action Then Return
If Animating(zombie) Then Return
current_action = action
animate_zombie(aZombie,action)
End Function
;==========================================
Function animate_zombie(aZombie,action)
;==========================================
asp# = .3
Animate aZombie,3,asp,action
;Animate aZombie,2,.2,action
End Function
;============================================
Function extractZombieAnimation()
;============================================
;
ExtractAnimSeq( zombie,2,20) ;	1	Walk cycle 1
ExtractAnimSeq( zombie,22,36);	2	Walk Cycle 2
ExtractAnimSeq( zombie,38,47);	3	Zombie being Attacked 1
ExtractAnimSeq( zombie,48,57);	4	Zombie being Attacked 2
ExtractAnimSeq( zombie,59,75);	5	Blown away onto his back
ExtractAnimSeq( zombie,78,88);	6	Still lying down And twitching (OFFSET To where he landed)
ExtractAnimSeq( zombie,91,103);	7	Die And fall forwards
ExtractAnimSeq( zombie,106,115);8	Kick Attack
ExtractAnimSeq( zombie,117,128);9	Punch/Grab Attack
ExtractAnimSeq( zombie,129,136);10	Head Butt :-)
ExtractAnimSeq( zombie,137,169);11	Idle 1
ExtractAnimSeq( zombie,170,200);12	Idle 2
ExtractAnimSeq( zombie,s,e )
End Function
;========================================
Function scanMesh(mesh)
;========================================
If CountChildren(mesh) > 0 
	
	For index = 1 To CountChildren(mesh)
		;EntityType child,type_ground
		child = GetChild (mesh,index)
		DebugLog.Print EntityName$(mesh) + "-->" + EntityName$(child)
		joint.t_joint = New t_joint
		joint\entity = child
		scanMesh(child)
	Next
	
	
EndIf
End Function
;========================================
Function createcubes()
;========================================
For joint.t_joint = Each t_joint
	cube = CreateCube(joint\entity)
	EntityColor cube,Rand(1,255),Rand(1,255),Rand(1,255)
Next
End Function
 | 
| 
 | ||
| Well you could simply yell into a microphone for a zombie sound, like this http://www.youtube.com/watch?v=oKRU-xpC_IU Or you could yell something, then reverse the sound http://www.youtube.com/watch?v=LXuR41eisnM&feature=related | 
| 
 | ||
| I would turn the light down so you can hardly see anything, flash it really bright every now and then then spend a week making sound effects and ambient background. For zombies you may also want to put some random noise into their animation time, I notice in the movies zombies typically do random sporadic stuff which would be fun to experiment with using animation time line. This is a Java (refresh rate broken in chrome?) zombie game we made once (mark sibly has green shirt). http://nullprefix.appspot.com/zip/agpudWxscHJlZml4cg8LEghHcmVldGluZxi6Fww/index.html |