Python Forum
Need some help with Dice Game for daughter in school
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Need some help with Dice Game for daughter in school
#1
Hi, my daughter needs to finish a project with a dice program in gygame. So far she can roll the dice and see the results. Now she needs to show the results in numbers too, not only the dice. I assume we need the print command for this ?
Any help would be appreciated.
This is what we got so far :
from random import randrange

class Die():
    def __init__(self, position):
        self.position = position
        self.value = 6
        self.displayed = False

    def show(self):
        pass

    def hide(self):
        pass

    def toggle(self):
        pass

    def throw(self):
        self.value = randrange(1, 6)

    def display(self):
        filename = str(self.value) + "_dots"
        if filename == "1_dots":
            filename = "1_dot"
        screen.blit(filename, self.position)

die1 = Die((20, 80))
die2 = Die((180, 80))
die3 = Die((340, 80))
die4 = Die((500, 80))
die5 = Die((660, 80))

def number_count(dice):
    die1 = Die((20, 80))
    die2 = Die((180, 80))
    die3 = Die((340, 80))
    die4 = Die((500, 80))
    die5 = Die((660, 80))

    numbers = [None, 0, 0, 0, 0, 0, 0]
    for die in dice:
         numbers[die.value] += 1
    return numbers

def product(a):
        p = 1
        for f in a:
            p *= f
        return p

def draw():
    screen.clear()
    die1.display()
    die2.display()
    die3.display()
    die4.display()
    die5.display()

def update():
    pass

def on_key_down(key):
    if key == keys.SPACE:
        die1.throw()
        die2.throw()
        die3.throw()
        die4.throw()
        die5.throw()   
buran write Feb-11-2021, 02:13 PM:
Moved to Homework as it is school assignment + there is nothing that is pygame related in the question (so far). In any case Homework takes priority over Game Development
Reply


Messages In This Thread
Need some help with Dice Game for daughter in school - by OptX - Feb-11-2021, 01:33 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  regarding dice game hola123 4 2,415 Feb-10-2021, 11:00 PM
Last Post: hola123
  Two dice Game of Pig help elliemehl 2 4,274 Feb-14-2019, 01:19 AM
Last Post: woooee
  Trying to help stressed out daughter Olly66 4 2,831 Jan-26-2019, 12:43 PM
Last Post: gehrenfeld
  Two Dice Pig Game in Python 3.6 Help inspired22 4 11,708 Oct-10-2018, 01:17 PM
Last Post: ichabod801
  School Work Assignment: Snake Game DarksideMoses 6 5,260 Apr-29-2018, 10:56 PM
Last Post: DarksideMoses
  help with while loop on dice game sean5 2 4,244 Dec-14-2017, 07:24 PM
Last Post: nilamo
  Small game (school project) Ganesh 7 5,718 Nov-08-2017, 09:04 PM
Last Post: Ganesh
  dice game im stuck sylerr 3 4,486 May-12-2017, 10:50 PM
Last Post: ichabod801

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020