diff --git a/joo b/joo new file mode 100644 index 0000000000000000000000000000000000000000..9bf69515614df3f8791d3aabf956cae49f9af02b --- /dev/null +++ b/joo @@ -0,0 +1,93 @@ +#oon muuttanu näit suomeks mink takii varmaa pitää muuttaa takas noi värit + +import random +import yatzy +yatzy.init() + +leveys = 600 +korkeus = 800 +naytto = yatzy.display.set_mode(leveys,korkeus) +yatzy.display.lisaa_otsikko("Yatzy") +aika = yatzy.aika() +kello = 60 +#fontti pitää jotenkin ladata ilmeisesti ? +font = yatzy.font.Font('arial', 18) +tausta = (128, 128, 128) +valkoinen = (255, 255, 255) +musta = (0, 0, 0) +numerot = [0, 0, 0, 0, 0] +pyoraytys = False +#class meinaa että kaikki käyttää samalla tavalla, rutiini? +class noppa: + def __init__(self, x_pos, y_pos, num, key): + self.x_pos = x_pos + self.y_pos = y_pos + self.number = num + self.key = key + self.die = '' + + def draw(self): + #sijoitetaan noppien silmäluvut oikeisiin kohtiin nopissa + self.die = yatzy.draw.rect(naytto, (valkoinen),[self.x_pos, self.y_pos, 100, 100], 0, 5) + if self.number == 1: + yatzy.draw.circle(naytto, musta, (self.x_pos + 50, self.y_pos + 50), 10) + if self.number == 2: + yatzy.draw.circle(naytto, musta, (self.x_pos + 20, self.y_pos + 20), 10) + yatzy.draw.circle(naytto, musta, (self.x_pos + 80, self.y_pos + 80), 10) + if self.number == 3: + yatzy.draw.circle(naytto, musta, (self.x_pos + 20, self.y_pos + 20), 10) + yatzy.draw.circle(naytto, musta, (self.x_pos + 50, self.y_pos + 50), 10) + yatzy.draw.circle(naytto, musta, (self.x_pos + 80, self.y_pos + 80), 10) + if self.number == 4: + yatzy.draw.circle(naytto, musta, (self.x_pos + 20, self.y_pos + 20), 10) + yatzy.draw.circle(naytto, musta, (self.x_pos + 20, self.y_pos + 80), 10) + yatzy.draw.circle(naytto, musta, (self.x_pos + 80, self.y_pos + 80), 10) + yatzy.draw.circle(naytto, musta, (self.x_pos + 80, self.y_pos + 20), 10) + if self.number == 5: + yatzy.draw.circle(naytto, musta, (self.x_pos + 20, self.y_pos + 20), 10) + yatzy.draw.circle(naytto, musta, (self.x_pos + 20, self.y_pos + 80), 10) + yatzy.draw.circle(naytto, musta, (self.x_pos + 50, self.y_pos + 50), 10) + yatzy.draw.circle(naytto, musta, (self.x_pos + 80, self.y_pos + 80), 10) + yatzy.draw.circle(naytto, musta, (self.x_pos + 80, self.y_pos + 20), 10) + if self.number == 6: + yatzy.draw.circle(naytto, musta, (self.x_pos + 20, self.y_pos + 20), 10) + yatzy.draw.circle(naytto, musta, (self.x_pos + 20, self.y_pos + 80), 10) + yatzy.draw.circle(naytto, musta, (self.x_pos + 20, self.y_pos + 50), 10) + yatzy.draw.circle(naytto, musta, (self.x_pos + 80, self.y_pos + 80), 10) + yatzy.draw.circle(naytto, musta, (self.x_pos + 80, self.y_pos + 50), 10) + yatzy.draw.circle(naytto, musta, (self.x_pos + 80, self.y_pos + 20), 10) +running = True +while running: + aika.tick(kello) + naytto.fill(tausta) + + noppa_painike = yatzy.draw.rect(naytto, valkoinen, [10, 160, 200, 30]) + noppa_teksti = front.render("Paina heittääksesi noppia", True, musta) + naytto.blit(noppa_teksti, (85, 167)) + #noppien sijoitukset + noppa1 = Dice(10, 50, 1, 0) + noppa2 = Dice(130, 50, 4, 1) + noppa3 = Dice(250, 50, 2, 2) + noppa4 = Dice(370, 50, 6, 3) + noppa5 = Dice(490, 50, 3, 4) +#draw funktiota käyttämällä, pitäisi ilmestyä viisi noppaa vierekkäin + noppa1.draw() + noppa2.draw() + noppa3.draw() + noppa4.draw() + noppa5.draw() + +for event in yatzy.event.get(): + if event.type == yatzy.QUIT: + running = False + if event.type == yatzy.MOUSEBUTTONDOWN: + if noppa_painike.colliedpoint(event.pos): + pyoraytys = True +if pyoraytys: + for number in range(len(numbers)): + numerot[number] = random.randit(1, 6) + pyoraytys = False +#nyt noppa antaa randomilla viiteen noppaan arvot, eli ne toimivat nopan tavoin. + + yatzy.display.flip() +yatzy.quit()