Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Rotating Dice

Rotating Dice

Scheduled Pinned Locked Moved Visual Basic
csharpgraphicsgame-devtutorialquestion
7 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    RBCC
    wrote on last edited by
    #1

    I am building a dice game, with rotating dice. The dice will have 1-6 dots on each side. I am also building a class to play the game, but can't figure out how to send a message to roll the dice in the class without the class knowing about the simulating rolling dice, how is this done?:confused: I am avidly interested in graphics and ado.net

    D F 2 Replies Last reply
    0
    • R RBCC

      I am building a dice game, with rotating dice. The dice will have 1-6 dots on each side. I am also building a class to play the game, but can't figure out how to send a message to roll the dice in the class without the class knowing about the simulating rolling dice, how is this done?:confused: I am avidly interested in graphics and ado.net

      D Offline
      D Offline
      Dave Kreskowiak
      wrote on last edited by
      #2

      Some code samples would be helpful. Since we can't see your design, there is no way we can tell you what your doing right or wrong. RageInTheMachine9532

      A 1 Reply Last reply
      0
      • D Dave Kreskowiak

        Some code samples would be helpful. Since we can't see your design, there is no way we can tell you what your doing right or wrong. RageInTheMachine9532

        A Offline
        A Offline
        Anonymous
        wrote on last edited by
        #3

        I am just trying to get started!:confused:

        D 1 Reply Last reply
        0
        • A Anonymous

          I am just trying to get started!:confused:

          D Offline
          D Offline
          Dave Kreskowiak
          wrote on last edited by
          #4

          First, what do you mean by "roll the dice in the class without the class knowing about the simulating rolling dice"? Does this mean that you have 2 seperate classes, something that is displaying graphics dice and something else that actually picks the numbers that the dice will show? Is this a user control you've written to display the dice? RageInTheMachine9532

          R 1 Reply Last reply
          0
          • D Dave Kreskowiak

            First, what do you mean by "roll the dice in the class without the class knowing about the simulating rolling dice"? Does this mean that you have 2 seperate classes, something that is displaying graphics dice and something else that actually picks the numbers that the dice will show? Is this a user control you've written to display the dice? RageInTheMachine9532

            R Offline
            R Offline
            RBCC
            wrote on last edited by
            #5

            class dice dim adie1 as int16 dim adie2 as int16 property die1 as int16 get return adie1 end get set sdie1=value end set 'What I am trying to is to make sure that the class is self-contained' ' it can roll the die on the form and count the value of the die private function count_die (die1 as int16, die2 as int 16)as int16 dim total as int16 total=die1+die2 return total public sub getFirstRoll (die1 as int16, die2 as int16)as int16<-- returns array dim firstroll()as int16 redim firstroll(rolls) firstroll(rolls)= count_die(die1,die2) rolls=rolls+1 return firstroll 'test rolls! I am avidly interested in graphics and ado.net

            D 1 Reply Last reply
            0
            • R RBCC

              I am building a dice game, with rotating dice. The dice will have 1-6 dots on each side. I am also building a class to play the game, but can't figure out how to send a message to roll the dice in the class without the class knowing about the simulating rolling dice, how is this done?:confused: I am avidly interested in graphics and ado.net

              F Offline
              F Offline
              FruitBatInShades
              wrote on last edited by
              #6

              Heres some code that may point you in the right direction. It is Airware so the syntax will not be correct:-

              Class DiceDisplay
              Property Display as PictureBox
              Property NoOfDice as int16
              Property Pips as int16
              Public Sub RollEm
              Dim Roller as DiceRoller(NoOfDice, Pips)
              Roller.Roll
              DrawDice(Roller)
              End Function
              Public Sub DrawDice(ByRef Results as DiceRoller)
              Dim Index as Int16
              For Index = 1 to NoOfDice
              DrawDiceImage(Roller.Results(Index))
              Next Index
              End sub
              End Class
              Class DiceRoller
              Property Results as arraylist
              Public Sub Roll(ByVal NoOfDice as int16, ByVal Pips as int16)
              Dim Index as int16
              For Index = 1 to NoOfDice
              Results.Add(convert.toint16(rnd(Pips)))
              Next Index
              End Sub
              End Class

              Definitely a PEBCAK! (Problem Exists Between Keyboard And Chair) My first ASP.Net site is now up :-O http://www.redravenrpg.com

              1 Reply Last reply
              0
              • R RBCC

                class dice dim adie1 as int16 dim adie2 as int16 property die1 as int16 get return adie1 end get set sdie1=value end set 'What I am trying to is to make sure that the class is self-contained' ' it can roll the die on the form and count the value of the die private function count_die (die1 as int16, die2 as int 16)as int16 dim total as int16 total=die1+die2 return total public sub getFirstRoll (die1 as int16, die2 as int16)as int16<-- returns array dim firstroll()as int16 redim firstroll(rolls) firstroll(rolls)= count_die(die1,die2) rolls=rolls+1 return firstroll 'test rolls! I am avidly interested in graphics and ado.net

                D Offline
                D Offline
                Dave Kreskowiak
                wrote on last edited by
                #7

                If you have a visual component that display rotating dice, you might want to consider building your class into a UserControl (Windows Control Library). That way, you can put your dice logic and visual elements in one place instead of having to worry about synchronizing two seperate classes. RageInTheMachine9532

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups