import pygame from pygame.locals import * class World: def __init__(self): self.opcje = Options("options.txt") pygame.init() #width, height = 800, 600 self.width, self.height = 1024, 768 screen = pygame.display.set_mode((width, height),FULLSCREEN|HWSURFACE|DOUBLEBUF) #screen = pygame.display.set_mode((width, height),FULLSCREEN) pygame.display.set_caption('Kimboot') pygame.mouse.set_visible(0) self.odeworld = ode.World() self.odeworld.setERP(0.8) self.odeworld.setCFM(1E-5) self.space=ode.Space() self.contactgroup=ode.JointGroup() # self.odeworld.setGravity((0,-9.81,0)) body1 = ode.Body(self.odeworld) M = ode.Mass() M.setSphere(1500, 0.05) body1.setMass(M) tup = pygame.mouse.get_pos() x,y = tup[0],tup[1] pozycja = [] pozycja.extend((float(x),float(y),0.0)) body1.setPosition(pozycja) self.rope = [body1] self.ropejoints = [] ogniwa = 10 val = 210 for i in range(1,ogniwa): self.rope.append(ode.Body(self.odeworld)) M = ode.Mass() M.setSphere(500, 0.05) self.rope[i].setMass(M) self.rope[i].setPosition((pozycja[0]+(i*(val/ogniwa)),pozycja[1]+(i*(val/ogniwa)),0)) self.ropejoints.append(ode.BallJoint(self.odeworld)) self.ropejoints[i-1].attach(self.rope[i-1], self.rope[i]) self.ropejoints[i-1].setAnchor(self.rope[i-1].getPosition()) self.ballbody = ode.Body(self.odeworld) M = ode.Mass() M.setSphere(2500, 0.05) self.ballbody.setMass(M) self.ballbody.setPosition((pozycja[0]+((i+1)*(val/ogniwa)),pozycja[1]+((i+1)*(val/ogniwa)),0)) radius = 30 self.ballgeom=ode.GeomSphere(space,radius) self.ballgeom.setBody(ballbody) self.ballgeom.size=radius j2 = ode.BallJoint(self.odeworld) j2.attach(rope[-1], ballbody) j2.setAnchor(rope[-1].getPosition()) # j2.setAnchor( (1,2,0) ) self.tlo = pygame.Surface(screen.get_size(),HWSURFACE|DOUBLEBUF) self.tlo = tlo.convert() self.tlo.fill((250, 250, 250)) screen.blit(self.tlo, (0, 0)) pygame.display.flip() self.clock = pygame.time.Clock() self.aww_sound = load_sound('aww.wav',self.opcje) self.punch_sound = load_sound('punch.wav',self.opcje) self.screams, self.splats, self.bravos = [], [], [] for i in range(5): self.screams.append(load_sound("scream0"+str(i+1)+".wav",self.opcje)) for i in range(6): self.splats.append(load_sound("splat0"+str(i+1)+".wav",self.opcje)) for i in range(5): self.bravos.append(load_sound("bravo0"+str(i+1)+".wav",self.opcje)) self.enemies = [] for i in range(2): self.enemies.append(Enemy(self.odeworld,self.space,self.width,self.height)) self.fist = Fist(self.odeworld,space) self.ball = pygame.sprite.Sprite() self.ball.image, self.ball.rect = load_image('ball.png', -1) self.ball.body = self.ballbody self.allsprites = pygame.sprite.RenderPlain((fist, enemies, ball)) self.corpses = pygame.sprite.RenderPlain() self.fps = 50 self.dt = 1.0/fps loopFlag = True self.clk = pygame.time.Clock() self.ticks = 0 self.czestosc = 90 self.kombo = False self.komboile = 0 self.czaskomba = 0 napis,napispos = wypisz("",(200,10,10),(250,250,250),tlo,200) startnapisu = 0 punkty, trupy, najkombo = 0, 0, 0 krew = Blood(opcje) #for drop in krew.particles: # krewy.add(drop) jest_krew = False