player
player.py — Python Source, 1 KB
Dateiinhalt
from visual import * class player(frame): v = vector(0,0,0) def __init__(self): frame.__init__(self) self.body = box(frame=self,pos=(-14,0,0),length=0.25,height=4,width=0.3,color=color.white) # self.v = vector(0,0,0) self.speedp = 0.1 def move(self, keys, s): if keys: if s=="w" or s=="up": self.v = vector(0,self.speedp,0) elif s=="s" or s=="down": self.v = vector(0,-self.speedp,0) self.pos += self.v self.v = self.v*0.98 if self.y>8-0.5*self.body.height: self.y=8-0.5*self.body.height elif self.y<-8+0.5*self.body.height: self.y=-8+0.5*self.body.height def increase(self): self.body.size+=(0,2,0) def decrease(self): self.body.size+=(0,-2,0) def slow (self): self.speedp -= 0.05 def fast (self): self.speedp += 0.1