WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 10-30-2012, 08:24 AM
emily800326 emily800326 is offline
Member
 
Join Date: Jul 2012
Posts: 5
about a pair game

Code:
import viz
import viztask
import random
import os
#viz.go(viz.HMD)
viz.go()

ar = viz.add('artoolkit.dle')
camera = ar.addWebCamera()

#標示###########################################################################

m1  = camera.addMatrixMarker(1,width=80)
m2  = camera.addMatrixMarker(2,width=80) 
m3  = camera.addMatrixMarker(3,width=80) 
m4  = camera.addMatrixMarker(4,width=80)
m5  = camera.addMatrixMarker(5,width=80)
m6  = camera.addMatrixMarker(6,width=80) 
m7  = camera.addMatrixMarker(7,width=80) 
m8  = camera.addMatrixMarker(8,width=80)
m9  = camera.addMatrixMarker(9,width=80)
m10 = camera.addMatrixMarker(10,width=80) 
m11 = camera.addMatrixMarker(11,width=80) 
m12 = camera.addMatrixMarker(12,width=80)
m13 = camera.addMatrixMarker(13,width=80)
m14 = camera.addMatrixMarker(14,width=80) 
m15 = camera.addMatrixMarker(15,width=80) 
m16 = camera.addMatrixMarker(16,width=80)

#字型###########################################################################
viz.setOption('viz.text.font','wt040.ttf')

rightm=viz.add('right.mp3')
wrongm=viz.add('wrong.mp3')
gameover=viz.addTexture('gameover.jpg')


#計分計時板

tt = 61  #倒數時間

gametimetitle = viz.addText( '時間', viz.SCREEN )
gametimetitle.setScale(0.7,0.7)
gametimetitle.setPosition(0.73,0.94)
gametimetitle.color([1,0,0])
gametime = viz.addText( str(tt), viz.SCREEN )#增加2d文字
gametime.setScale(1.5,1.5)
gametime.setPosition(0.84,0.89)
gametime.color([1,0,0])

gametime.visible(0)
gametimetitle.visible(0)

def ggtime():
	global tt
	if tt == 0:
		gameover()
	elif tt > 0 :
		tt = tt-1
#	elif tt == 0
		gametime.message(str(tt))
		gametime.visible(1)
		gametimetitle.visible(1)
defggtime = vizact.ontimer(1,ggtime)

#所有模型#########################################################################
model1 = viz.add("1.3DS")
model1.setScale(0.0009,0.0009,0.0009)
model1.color(1,0,0)
model2 = viz.add("2.3DS")
model2.setScale(0.0009,0.0009,0.0009)
model2.color(0,1,0)
model3 = viz.add("3.3DS")
model3.setScale(0.0009,0.0009,0.0009)
model3.color(0,0,1)
model4 = viz.add("4.3ds")
model4.setScale(0.0009,0.0009,0.0009)
model4.color(0,1,1)
model5 = viz.add("5.3DS")
model5.setScale(0.0009,0.0009,0.0009)
model5.color(1,4,0)
model6 = viz.add("6.3DS")
model6.setScale(0.0009,0.0009,0.0009)
model6.color(2,1,0)
model7 = viz.add("7.3DS")
model7.setScale(0.0009,0.0009,0.0009)
model7.color(0,1,4)
model8 = viz.add("8.3ds")
model8.setScale(0.0009,0.0009,0.0009)
model8.color(4,0,1)
model9 = viz.add("a.3DS")
model9.setScale(0.0009,0.0009,0.0009)
model9.color(1,0,0)
model10 = viz.add("b.3DS")
model10.setScale(0.0009,0.0009,0.0009)
model10.color(0,1,0)
model11 = viz.add("c.3DS")
model11.setScale(0.0009,0.0009,0.0009)
model11.color(0,0,1)
model12 = viz.add("d.3ds")
model12.setScale(0.0009,0.0009,0.0009)
model12.color(0,1,1)
model13 = viz.add("e.3DS")
model13.setScale(0.0009,0.0009,0.0009)
model13.color(1,4,0)
model14 = viz.add("f.3DS")
model14.setScale(0.0009,0.0009,0.0009)
model14.color(2,1,0)
model15 = viz.add("g.3DS")
model15.setScale(0.0009,0.0009,0.0009)
model15.color(0,1,4)
model16 = viz.add("h.3ds")
model16.setScale(0.0009,0.0009,0.0009)
model16.color(4,0,1)

links1=viz.link(m1,model1)
links2=viz.link(m2,model2)
links3=viz.link(m3,model3)
links4=viz.link(m4,model4)
links5=viz.link(m5,model5)
links6=viz.link(m6,model6)
links7=viz.link(m7,model7)
links8=viz.link(m8,model8)
links9=viz.link(m9,model9)
links10=viz.link(m10,model10)
links11=viz.link(m11,model11)
links12=viz.link(m12,model12)
links13=viz.link(m13,model13)
links14=viz.link(m14,model14)
links15=viz.link(m15,model15)
links16=viz.link(m16,model16)

model1.visible(0)
model2.visible(0)
model3.visible(0)
model4.visible(0)
model5.visible(0)
model6.visible(0)
model7.visible(0)
model8.visible(0)
model9.visible(0)
model10.visible(0)
model11.visible(0)
model12.visible(0)
model13.visible(0)
model14.visible(0)
model15.visible(0)
model16.visible(0)

###end########################################################
def gameover():
	global a,s
	if 	s==10 :
		print "end"
		defseemark.setEnabled(0)
		gameover.texture(gameover)
		
defgameover = vizact.ontimer(0.1,gameover)	

###START###################################################
s=0	
r=0
def seemark():
	global ans,flag,data01,r,a,tt,s
	deftitlemarker.setEnabled(0)
	defgameover.setEnabled(0)
	
	if not m1.getVisible() and not m9.getVisible():
		print "1+9"		
		model1.visible(0)
		model9.visible(0)
		r=r+0.5
		print r
		if r == 4.0:
				print "right"
				r=0
				rightm.play()
				
		
			
	
	elif not m2.getVisible() and not m10.getVisible():
		print "2+10"
		rightm.play()
		model2.visible(0)
		model10.visible(0)
		r=r+0.5
		print r
		if r == 4.0:
				print "right"
				r=0
				rightm.play()

		
			
	elif not m3.getVisible() and not m11.getVisible():
		print "3+11"
		rightm.play()
		model3.visible(0)
		model11.visible(0)
		r=r+0.5
		print r
		if r == 4.0:
				print "right"
				r=0
				rightm.play()

	elif not m4.getVisible() and not m12.getVisible():
		print "4+12"
		rightm.play()
		model4.visible(0)
		model12.visible(0)
		r=r+0.5
		print r
		if r == 4.0:
				print "right"
				r=0				
				rightm.play()

			
	elif not m5.getVisible() and not m13.getVisible():
		print "5+13"
		rightm.play()
		model5.visible(0)
		model13.visible(0)		
		r=r+0.5		
		print r
		
		if r == 4.0:
				print "right"
				r=0				
				rightm.play()

			
	elif not m6.getVisible() and not m14.getVisible():
		print "6+14"
		rightm.play()
		model6.visible(0)
		model14.visible(0)
		r=r+0.5
		print r
		if r == 4.0:
				print "right"
				r=0				
				rightm.play()

				
	elif not m7.getVisible() and not m15.getVisible():
		print "7+15"
		rightm.play()
		model7.visible(0)
		model15.visible(0)
		r=r+0.5
		print r

		if r == 4.0:
				print "right"
				r=0				
				rightm.play()

			
	elif not m8.getVisible() and not m16.getVisible():
		print "8+16"
		rightm.play()
		model8.visible(0)
		model16.visible(0)
		r=r+0.5	
		print r

		if r == 4.0:
				print "right"
				r=0				
				rightm.play()

	
			
	elif m1.getVisible()and m2.getVisible()and m3.getVisible() and  m4.getVisible() and m5.getVisible()and m6.getVisible()and m7.getVisible() and m8.getVisible() and m9.getVisible() and m10.getVisible() and m11.getVisible() and m12.getVisible() and m13.getVisible() and m14.getVisible() and m15.getVisible() and m16.getVisible() :
		print "wait!"
		flag=0
		r=0
		
		
	else:
		r=r+0.5
		print r
		if r == 5.0:
			print "wrong"
			r=0
			wrongm.play()
			
#		model1.visible(0)
#		model2.visible(0)
#		model3.visible(0)
#		model4.visible(0)
#		model5.visible(0)
#		model6.visible(0)
#		model7.visible(0)
#		model8.visible(0)
#		model9.visible(0)
#		model10.visible(0)
#		model11.visible(0)
#		model12.visible(0)
#		model13.visible(0)
#		model14.visible(0)
#		model15.visible(0)
#		model16.visible(0)


	
	if flag == 1 :
		defseemark.setEnabled(0)

defseemark = vizact.ontimer(0.1,seemark)

	
##遊戲的標題#######################################################################################
titlemark = camera.addMatrixMarker(0,width=80)
title = viz.addTexQuad()
title.setPosition([10,10, 1.2])
title.setScale([1.02,0.8,1])
Dtitle1 = viz.addTexture('title1.jpg')
Dtitle2 = viz.addTexture('title2.jpg')
Dtitle3 = viz.addTexture('gamestart.jpg')

#規則秒數##########################################################################################
Ruletime = 0
def titlemarker():
	global title,Dtitle
	global Ruletime
	defggtime.setEnabled(0)
	defseemark.setEnabled(0)

	if titlemark.getVisible()==1 and Ruletime == 1:
		title.setPosition([0,0, 1.2])
		title.texture(Dtitle1)
	elif titlemark.getVisible()==1 and Ruletime == 30:
		title.texture(Dtitle2)
	elif titlemark.getVisible()==1 and Ruletime == 60:
		title.texture(Dtitle3)
	elif titlemark.getVisible()==1 and Ruletime == 90:
		title.visible(0)
		
		defseemark.setEnabled(1)
		seemark()
		defggtime.setEnabled(1)
		
		model1.visible(1)
		model2.visible(1)
		model3.visible(1)
		model4.visible(1)
		model5.visible(1)
		model6.visible(1)
		model7.visible(1)
		model8.visible(1)
		model9.visible(1)
		model10.visible(1)
		model11.visible(1)
		model12.visible(1)
		model13.visible(1)
		model14.visible(1)
		model15.visible(1)
		model16.visible(1)
		
	elif  titlemark.getVisible()==0:		
		Ruletime = 0
		title.setPosition([10,10, 1.2])
	Ruletime = Ruletime+1
		
deftitlemarker = vizact.ontimer(0.1,titlemarker)
deftitlemarker.setEnabled(1)


this is my code!
and now i got some trouble!

if i touch the 1&9 code that may be invisible!
but the win sound always here
how should i do?

and if the code all(1~16) invisible~
i want make the game over
but i don't know how to write it
help~~~~~~~~~~~~~~~~
Reply With Quote
  #2  
Old 11-01-2012, 04:12 PM
Jeff Jeff is offline
WorldViz Team Member
 
Join Date: Aug 2008
Posts: 2,471
I would recommend posting the most concise example code possible that shows your problem. By creating a simplified example you maybe able to figure out what's going on. If not, then at least it will be easier for others to help troubleshoot. Also please make sure the example can be run directly by others, which means you may need to swap resources with those included in Vizard.
Reply With Quote
  #3  
Old 11-06-2012, 08:45 AM
emily800326 emily800326 is offline
Member
 
Join Date: Jul 2012
Posts: 5
clean~~~~

how to delete it
Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

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

Similar Threads
Thread Thread Starter Forum Replies Last Post
sound problem in multi-scene game lucia romero Vizard 1 12-03-2011 06:46 PM
Simple Game Design with Vizard 3.0 Apostolos Vizard 1 07-27-2011 01:39 PM
Code for Avatar control 3rd Person Adventure Game Style Gladsomebeast Vizard 0 08-26-2010 02:04 PM
Help With Creating Menus and Buttons for a Chess Game RodRSpv Vizard 1 02-27-2009 03:12 PM
game devices jkelly Vizard 10 03-27-2007 03:16 AM


All times are GMT -7. The time now is 02:40 AM.


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