10 Replies - 8875 Views - Last Post: 29 February 2012 - 08:17 AM Rate Topic: -----

#1 Pylons  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 28-February 12

C# Dice Roll Program With Images

Posted 28 February 2012 - 05:01 PM

Hi, i am trying my best to do this program which is to make a program that lets the user to roll two dices as many as it wants, but the dices rolled can not be shown as numbers but as a image.

such as


[0]

for a dice roll of 1.



i havent made the loop code for the program yet and i only know how to make the random numbers for the rolls, i just can't figure out how to make the arraylist for the images and make the code to actually use the images instead of numbers... if you know what i mean.



here is my code so far, thanks for the help!

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace DiceRoll Game
{
    class Diceroll
    {
        static void Main(string[] args)
        {
            
            int[] DiceUno = new int[6];
            int[] DiceDos = new int[6];
            Random rnd = new Random();

            Console.WriteLine("This program will allow you to roll two dices");
            Console.WriteLine("\nAs many times as you want");
            Console.WriteLine("\n\nWhen you want to exit the program, please type (exit)");
            Console.WriteLine("\nPress any key to begin rolling");
            Console.Read();
            

            for (int i = 0; i < 1; i++)
            {
                int diceRoll = 0;
                diceRoll = rnd.Next(6);
                DiceUno[diceRoll]++;
                Console.WriteLine("Dice 1 is rolled a: {0}", diceRoll + 1);
                diceRoll = rnd.Next(6);
                DiceDos[diceRoll]++;
                Console.WriteLine("Dice 2 is rolled a: {0}", diceRoll + 1);
               
            }




            
        }
    }
}


Is This A Good Question/Topic? 0
  • +

Replies To: C# Dice Roll Program With Images

#2 Curtis Rutland  Icon User is online

  • (╯□)╯︵ (~ .o.)~
  • member icon


Reputation: 4525
  • View blog
  • Posts: 7,893
  • Joined: 08-June 10

Re: C# Dice Roll Program With Images

Posted 28 February 2012 - 05:07 PM

Well, first of all, don't use ArrayList, use List<T>, because it's the appropriate way to handle collections of a specific type.

Second, what do you expect the image to display in? This is a Console Application, correct? Consoles can only display text. You'd have to create a Windows Forms/WCF application to use images. That's a starting point.
Was This Post Helpful? 0
  • +
  • -

#3 Pylons  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 28-February 12

Re: C# Dice Roll Program With Images

Posted 28 February 2012 - 05:12 PM

As for the images i was going to do a
text box with a O inside it to make it look like a dice with a single O in it to look like a roll of 1.
to do this i was going to do Console.writeline"(the text image of the dice 1)"

thanks for the quick responses.
Was This Post Helpful? 0
  • +
  • -

#4 tlhIn`toq  Icon User is offline

  • Please show what you have already tried when asking a question.
  • member icon

Reputation: 5571
  • View blog
  • Posts: 11,910
  • Joined: 02-June 10

Re: C# Dice Roll Program With Images

Posted 28 February 2012 - 05:27 PM

First let's clarify something:

Do you really mean "images", like pictures: bitmaps and jpg graphics?
Or do you mean character representations using [ ] and 0 for dots? (ASCII art)

┌─────┐
|0    |
|  0  |
|    0|
└─────┘


You will find all the ALT codes here for this drawing
This was done with 191, 196, 218, 124, and so on as you can see on that page

Please take a try at coding a solution now that you have been given a direction to research. Once you have updated your code if you are still having issues please post in this thread rather than starting a new one.

A word to our newer members that may be anxious to help:
Please help this person by NOT giving them the code to do it. So much more is learned by trial and error than by someone just handing you the answer. The OP needs to put in the effort and do some trial and error just like you did in the beginning if they are to grow as a developer.

View PostPylons, on 28 February 2012 - 06:12 PM, said:

i was going to do a text box ...
to do this i was going to do Console.writeline"(the text image of the dice 1)"


That makes NO SENSE. A TextBox is a windows forms GUI control. Console.WriteLine() does not output to a textbox. It outputs to the console.

So either your terms are mixed up - or you are very mistaken about how to go about this.
Was This Post Helpful? 0
  • +
  • -

#5 Pylons  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 28-February 12

Re: C# Dice Roll Program With Images

Posted 28 February 2012 - 05:28 PM

Thanks so much for the Alt Code, that is exactly what i really needed to do this!
i'll update this as soon as i finished.

once again thanks so much!
Was This Post Helpful? 0
  • +
  • -

#6 tlhIn`toq  Icon User is offline

  • Please show what you have already tried when asking a question.
  • member icon

Reputation: 5571
  • View blog
  • Posts: 11,910
  • Joined: 02-June 10

Re: C# Dice Roll Program With Images

Posted 28 February 2012 - 05:35 PM

View PostCurtis Rutland, on 28 February 2012 - 06:07 PM, said:

Well, first of all, don't use ArrayList, use List<T>, because it's the appropriate way to handle collections of a specific type.

Second, what do you expect the image to display in? This is a Console Application, correct? Consoles can only display text. You'd have to create a Windows Forms/WCF application to use images. That's a starting point.


This is a homework project. No doubt they haven't learned List<T> yet.
I think he could do an ArrayList with ints for the ASCII values, right?
218, 196, 196, 196, 196, 191, // ┌────┐
124,  7 ,  32,  32,  32, 124, // |   |


This has the advantage of using the ALT+7 value for a real dot instead of a zero or oh character
Was This Post Helpful? 0
  • +
  • -

#7 AdamSpeight2008  Icon User is offline

  • MrCupOfT
  • member icon


Reputation: 2267
  • View blog
  • Posts: 9,479
  • Joined: 29-May 08

Re: C# Dice Roll Program With Images

Posted 28 February 2012 - 05:58 PM

The only thing that change are the dots, which strongly suggests a function method. That creates a dice face.
A B
CDE
F G



string GetDiceFace(bool : A, bool : B, bool : C, bool : D, bool : E, bool : F , bool : G) : string
{
 string dice_face
 /* face drawing code */
 return dice_face
}


This post has been edited by AdamSpeight2008: 28 February 2012 - 05:58 PM

Was This Post Helpful? 0
  • +
  • -

#8 superkb10  Icon User is offline

  • D.I.C Regular

Reputation: 29
  • View blog
  • Posts: 298
  • Joined: 27-November 11

Re: C# Dice Roll Program With Images

Posted 28 February 2012 - 08:19 PM

AdamSpeight2008

He wouldn't even need a function, just a string for each side of the dice then just write it out. This is assuming that he is making a Console Application that is.
Was This Post Helpful? 0
  • +
  • -

#9 AdamSpeight2008  Icon User is offline

  • MrCupOfT
  • member icon


Reputation: 2267
  • View blog
  • Posts: 9,479
  • Joined: 29-May 08

Re: C# Dice Roll Program With Images

Posted 28 February 2012 - 09:05 PM

superkb10 It's a helper function, suppose the char used for the dot is changed you'd to rewrite all of the string.

Warning vb.net code ahead!
Spoiler

Was This Post Helpful? 0
  • +
  • -

#10 Curtis Rutland  Icon User is online

  • (╯□)╯︵ (~ .o.)~
  • member icon


Reputation: 4525
  • View blog
  • Posts: 7,893
  • Joined: 08-June 10

Re: C# Dice Roll Program With Images

Posted 28 February 2012 - 10:55 PM

View Postsuperkb10, on 28 February 2012 - 09:19 PM, said:

AdamSpeight2008

He wouldn't even need a function, just a string for each side of the dice then just write it out. This is assuming that he is making a Console Application that is.


That doesn't make much sense. Of course you don't need a function, but it's good practice to use one.
Was This Post Helpful? 0
  • +
  • -

#11 superkb10  Icon User is offline

  • D.I.C Regular

Reputation: 29
  • View blog
  • Posts: 298
  • Joined: 27-November 11

Re: C# Dice Roll Program With Images

Posted 29 February 2012 - 08:17 AM

Yeah, it is good practice. I was just throwing out another suggestion.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1