WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

 
 
Thread Tools Rating: Thread Rating: 19 votes, 5.00 average. Display Modes
Prev Previous Post   Next Post Next
  #6  
Old 02-15-2006, 05:56 PM
betancourtb82 betancourtb82 is offline
Member
 
Join Date: Jan 2006
Posts: 103
Nevermind that last question, I just figured it out. Now for my real question. The reason I'm writing this code is to create a scenario where someone falls when they get shot (i.e. a projectile hits the avatar, activated by a mouse click). I have modeled my code from the duckcourt demo but can't get the enemy to stay on the ground when shot. I'm thinking it has to do with the way the avatar is "viewed" by the program. I was wondering if you could help me figure out how to distinguish between each element in the array and denote who's getting shot. For now I would be happy just being able to click on the avatars in this code and have them fall and stay down. I think I can go from there. Thanks again


Code:
import viz

viz.go()
avatars = []
FREEZE_AVATAR = 0

#Go through a loop six times.
for i in range(4):
	#Each time you go through the loop, create a new duck and 
	male = viz.add('male.cfg')
	male.translate(-i, 0,10)
	male.rotate(180,0,0)

#Add the new male to the "avatars" array.
	avatars.append(male)


def onkeydown(key):
	if key == 'r':
		print 'R pressed'
		# Kill timer FREEZE_AVATAR
		viz.killtimer(FREEZE_AVATAR)
		male.clear(viz.ALL)
		male.clear(viz.CURRENT_ACTION)
		male.state(1)
		
viz.callback(viz.KEYDOWN_EVENT,onkeydown)



def ontimer(num):
	if num == FREEZE_AVATAR:
		#Freeze the avatar
		male.speed(0)
		

viz.callback(viz.TIMER_EVENT,ontimer)

def onmousedown(button):
	#The mouse button 'button' is being pressed
	if button == viz.MOUSEBUTTON_LEFT:
			#Perform the action
			male.act(7)
			#Start a timer to freeze the avatar when the action is over
			viz.starttimer(FREEZE_AVATAR,(male.getduration(7)-.07),1)
			#male.act(8)	pass

viz.callback(viz.MOUSEDOWN_EVENT,onmousedown)

viz.mouse(viz.OFF)

Last edited by betancourtb82; 02-16-2006 at 11:58 AM.
Reply With Quote
 


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 07:11 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2026, vBulletin Solutions, Inc.
Copyright 2002-2023 WorldViz LLC