Dame
dame.py — Python Source, 1 KB (1696 bytes)
Dateiinhalt
from visual import * import time class Spielbrettstein: def __init__ (self,farbe = 1,position = (0,0,0)): self.stein = box(pos = position,height = 0.2,length = 1,width = 1) if farbe == 1: self.stein.color = color.black else: self.stein.color = color.white class Spielbrett: def __init__(self): self.brett = [] for i in range(0,64): self.brett.append(Spielbrettstein(farbe = (i%2)+(i/8)%2,position = (i/8,0,-(i%8)))) class Spielstein: def __init__(self,farbe = 1,position = (0,0,0)): self.stein = cylinder(pos = position,radius = 0.5,length = 0.4,axis = (0,0.4,0),material = materials.wood) self.farbe = farbe if farbe == 1: self.stein.color = (1,1,1) else: self.stein.color = (0.35,0.35,0.35) self.istDame = False def ZurDameMachen(self): if self.istDame == False: self.stein.length = self.stein.length * 2 self.istDame = True class Spiel: def __init__(self): scene.background = (0.2,0.5,0.7) self.brett = Spielbrett() self.steine = [] for i in range(12): self.steine.append(Spielstein(farbe = 1,position = (((i*2)+i/4+1)%8,0,-(i/4)))) # time.sleep(1) #watch it!!!!! for i in range(12): self.steine.append(Spielstein(farbe = 0,position = (((i*2)+i/4)%8,0,(i/4)-7))) #time.sleep(1) Spiel() while True: if scene.mouse.events: currentevent = scene.mouse.getevent() if scene.mouse.pick: picked_object = scene.mouse.pick time.sleep(0.2)