want to know how to pass a random number to text to be displayed

July 3, 2009 by admin · Comment
Filed under: Xbox360 News 

could anyone tell me what im doing wrong here?

 

GraphicsDeviceManager graphics;

 

 

SpriteBatch spriteBatch;

 

 

SpriteFont font;

 

 

Rectangle spriterect;

 

 

 

int roll = 0;

 

 

public Game1()

 

{

graphics =

new GraphicsDeviceManager(this);

 

Content.RootDirectory =

"Content";

 

}

 

/// <summary>

 

 

/// Allows the game to perform any initialization it needs to before starting to run.

 

 

/// This is where it can query for any required services and load any non-graphic

 

 

/// related content. Calling base.Initialize will enumerate through any components

 

 

/// and initialize them as well.

 

 

/// </summary>

 

 

protected override void Initialize()

 

{

 

// TODO: Add your initialization logic here

 

spriterect =

new Rectangle(30, 20, 600, 450);

 

 

base.Initialize();

 

}

 

/// <summary>

 

 

/// LoadContent will be called once per game and is the place to load

 

 

/// all of your content.

 

 

/// </summary>

 

 

protected override void LoadContent()

 

{

 

// Create a new SpriteBatch, which can be used to draw textures.

 

spriteBatch =

new SpriteBatch(GraphicsDevice);

 

font = Content.Load<

SpriteFont>("Kootenay");

 

 

// TODO: use this.Content to load your game content here

 

}

 

/// <summary>

 

 

/// UnloadContent will be called once per game and is the place to unload

 

 

/// all content.

 

 

/// </summary>

 

 

protected override void UnloadContent()

 

{

 

// TODO: Unload any non ContentManager content here

 

}

 

/// <summary>

 

 

/// Allows the game to run logic such as updating the world,

 

 

/// checking for collisions, gathering input, and playing audio.

 

 

/// </summary>

 

 

/// <param name="gameTime">Provides a snapshot of timing values.</param>

 

 

protected override void Update(GameTime gameTime)

 

{

 

Random dieroll = new Random();

 

 

 

int d4 = 4;

 

 

int d6 = 6;

 

 

int d8 = 8;

 

 

int d10 = 10;

 

 

int d12 = 12;

 

 

int d20 = 20;

 

 

 

// Allows the game to exit

 

 

if(GamePad.GetState(PlayerIndex.One).Buttons.A == ButtonState.Pressed)

 

{

d4 = dieroll.Next(1,d4+1);

d4 = roll;

 

}

 

if (GamePad.GetState(PlayerIndex.One).Buttons.B== ButtonState.Pressed)

 

{

d6 = dieroll.Next(1, d6 + 1);

d6 = roll;

}

 

if (GamePad.GetState(PlayerIndex.One).Buttons.X== ButtonState.Pressed)

 

{

d8 = dieroll.Next(1, d8 + 1);

d8 = roll;

}

 

if (GamePad.GetState(PlayerIndex.One).Buttons.Y == ButtonState.Pressed)

 

{

d10 = dieroll.Next(1, d10 + 1);

d10 = roll;

}

 

if (GamePad.GetState(PlayerIndex.One).Buttons.LeftShoulder == ButtonState.Pressed)

 

{

d12 = dieroll.Next(1, d12 + 1);

d12 = roll;

}

 

if (GamePad.GetState(PlayerIndex.One).Buttons.RightShoulder == ButtonState.Pressed)

 

{

d20 = dieroll.Next(1, d20 + 1);

d20 = roll;

}

 

 

if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)

 

 

this.Exit();

 

 

// TODO: Add your update logic here

 

 

base.Update(gameTime);

 

}

 

/// <summary>

 

 

/// This is called when the game should draw itself.

 

 

/// </summary>

 

 

/// <param name="gameTime">Provides a snapshot of timing values.</param>

 

 

protected override void Draw(GameTime gameTime)

 

{

 

Vector2 text = new Vector2(200, 300);

 

GraphicsDevice.Clear(

Color.CornflowerBlue);

 

spriteBatch.DrawString(font, roll.ToString, spriterect.X, spriterect.Y,

Color.Black);

 

 

 

// TODO: Add your drawing code here

 

 

base.Draw(gameTime);

 

}

}

}

i just want to make a simple d and d dice roller for marketplace, any help would be great

want to know how to pass a random number to text to be displayed

July 3, 2009 by admin · Comment
Filed under: Xbox360 News 

could anyone tell me what im doing wrong here?

 

GraphicsDeviceManager graphics;

 

 

SpriteBatch spriteBatch;

 

 

SpriteFont font;

 

 

Rectangle spriterect;

 

 

 

int roll = 0;

 

 

public Game1()

 

{

graphics =

new GraphicsDeviceManager(this);

 

Content.RootDirectory =

"Content";

 

}

 

/// <summary>

 

 

/// Allows the game to perform any initialization it needs to before starting to run.

 

 

/// This is where it can query for any required services and load any non-graphic

 

 

/// related content. Calling base.Initialize will enumerate through any components

 

 

/// and initialize them as well.

 

 

/// </summary>

 

 

protected override void Initialize()

 

{

 

// TODO: Add your initialization logic here

 

spriterect =

new Rectangle(30, 20, 600, 450);

 

 

base.Initialize();

 

}

 

/// <summary>

 

 

/// LoadContent will be called once per game and is the place to load

 

 

/// all of your content.

 

 

/// </summary>

 

 

protected override void LoadContent()

 

{

 

// Create a new SpriteBatch, which can be used to draw textures.

 

spriteBatch =

new SpriteBatch(GraphicsDevice);

 

font = Content.Load<

SpriteFont>("Kootenay");

 

 

// TODO: use this.Content to load your game content here

 

}

 

/// <summary>

 

 

/// UnloadContent will be called once per game and is the place to unload

 

 

/// all content.

 

 

/// </summary>

 

 

protected override void UnloadContent()

 

{

 

// TODO: Unload any non ContentManager content here

 

}

 

/// <summary>

 

 

/// Allows the game to run logic such as updating the world,

 

 

/// checking for collisions, gathering input, and playing audio.

 

 

/// </summary>

 

 

/// <param name="gameTime">Provides a snapshot of timing values.</param>

 

 

protected override void Update(GameTime gameTime)

 

{

 

Random dieroll = new Random();

 

 

 

int d4 = 4;

 

 

int d6 = 6;

 

 

int d8 = 8;

 

 

int d10 = 10;

 

 

int d12 = 12;

 

 

int d20 = 20;

 

 

 

// Allows the game to exit

 

 

if(GamePad.GetState(PlayerIndex.One).Buttons.A == ButtonState.Pressed)

 

{

d4 = dieroll.Next(1,d4+1);

d4 = roll;

 

}

 

if (GamePad.GetState(PlayerIndex.One).Buttons.B== ButtonState.Pressed)

 

{

d6 = dieroll.Next(1, d6 + 1);

d6 = roll;

}

 

if (GamePad.GetState(PlayerIndex.One).Buttons.X== ButtonState.Pressed)

 

{

d8 = dieroll.Next(1, d8 + 1);

d8 = roll;

}

 

if (GamePad.GetState(PlayerIndex.One).Buttons.Y == ButtonState.Pressed)

 

{

d10 = dieroll.Next(1, d10 + 1);

d10 = roll;

}

 

if (GamePad.GetState(PlayerIndex.One).Buttons.LeftShoulder == ButtonState.Pressed)

 

{

d12 = dieroll.Next(1, d12 + 1);

d12 = roll;

}

 

if (GamePad.GetState(PlayerIndex.One).Buttons.RightShoulder == ButtonState.Pressed)

 

{

d20 = dieroll.Next(1, d20 + 1);

d20 = roll;

}

 

 

if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)

 

 

this.Exit();

 

 

// TODO: Add your update logic here

 

 

base.Update(gameTime);

 

}

 

/// <summary>

 

 

/// This is called when the game should draw itself.

 

 

/// </summary>

 

 

/// <param name="gameTime">Provides a snapshot of timing values.</param>

 

 

protected override void Draw(GameTime gameTime)

 

{

 

Vector2 text = new Vector2(200, 300);

 

GraphicsDevice.Clear(

Color.CornflowerBlue);

 

spriteBatch.DrawString(font, roll.ToString, spriterect.X, spriterect.Y,

Color.Black);

 

 

 

// TODO: Add your drawing code here

 

 

base.Draw(gameTime);

 

}

}

}

i just want to make a simple d and d dice roller for marketplace, any help would be great

"Index was outside the bounds of the array."

July 3, 2009 by admin · Comment
Filed under: Xbox360 News 

I'm trying to read a text file and store it into an array, then draw a map according to the contents of the file. The file contents are:

5
7
2000002
2000002
2111112
2222222
2222222
I'm using this code to read the file, then draw it:
1 public void InitializeReadMaps(int map) // this is just run once, it's just a test  
2 {  
3     this.FileName = "map" + map.ToString() + ".txt";  
4     this.file = new FileStream(this.FileName, FileMode.Open, FileAccess.Read);  
5     this.sr = new StreamReader(this.file);  
6     string line = this.sr.ReadLine();  
7     this.YLength = Int32.Parse(line);  
8     this.XLength = Int32.Parse(line);  
9     this.map = new char[this.XLength, this.YLength];  
10 }  
11   
12 public void ReadMaps()  
13 {  
14     if (!sr.EndOfStream)  
15     {  
16         for (int y = 0; y < (this.YLength - 1); y++)  
17         {  
18             string line = this.sr.ReadLine();  
19             for (int x = 0; x < (this.XLength - 1); x++)  
20             {  
21                 map[x, y] = line[x];  
22             }  
23         }  
24     }  
25 }  
26   
27 public void DrawContent(SpriteBatch spriteBatch)  
28 {  
29     for(int y = 0; y < this.YLength; y++)  
30     {  
31         for (int x = 0; x < this.XLength; x++)  
32         {  
33             switch (this.map[x,y])  
34             {  
35                 case '1': tile.DrawTile(spriteBatch, x, y, 1); break;  
36                 case '2': tile.DrawTile(spriteBatch, x, y, 2); break;  
37             }  
38         }  
39     }  
40 }  

When I use this, I get "Index was outside the bounds of the array." on line 21,
map[x, y] = line[x]; 

Thanks.

"Index was outside the bounds of the array."

July 3, 2009 by admin · Comment
Filed under: Xbox360 News 

I'm trying to read a text file and store it into an array, then draw a map according to the contents of the file. The file contents are:

5
7
2000002
2000002
2111112
2222222
2222222
I'm using this code to read the file, then draw it:
1 public void InitializeReadMaps(int map) // this is just run once, it's just a test  
2 {  
3     this.FileName = "map" + map.ToString() + ".txt";  
4     this.file = new FileStream(this.FileName, FileMode.Open, FileAccess.Read);  
5     this.sr = new StreamReader(this.file);  
6     string line = this.sr.ReadLine();  
7     this.YLength = Int32.Parse(line);  
8     this.XLength = Int32.Parse(line);  
9     this.map = new char[this.XLength, this.YLength];  
10 }  
11   
12 public void ReadMaps()  
13 {  
14     if (!sr.EndOfStream)  
15     {  
16         for (int y = 0; y < (this.YLength - 1); y++)  
17         {  
18             string line = this.sr.ReadLine();  
19             for (int x = 0; x < (this.XLength - 1); x++)  
20             {  
21                 map[x, y] = line[x];  
22             }  
23         }  
24     }  
25 }  
26   
27 public void DrawContent(SpriteBatch spriteBatch)  
28 {  
29     for(int y = 0; y < this.YLength; y++)  
30     {  
31         for (int x = 0; x < this.XLength; x++)  
32         {  
33             switch (this.map[x,y])  
34             {  
35                 case '1': tile.DrawTile(spriteBatch, x, y, 1); break;  
36                 case '2': tile.DrawTile(spriteBatch, x, y, 2); break;  
37             }  
38         }  
39     }  
40 }  

When I use this, I get "Index was outside the bounds of the array." on line 21,
map[x, y] = line[x]; 

Thanks.

17 Again (Blu-ray/DVD Combo + Digital Copy) [Blu-ray] (Blu-ray) newly tagged "blu-ray"

July 2, 2009 by admin · Comment
Filed under: Xbox360 News 
17 Again (Blu-ray/DVD Combo + Digital Copy) [Blu-ray]

17 Again (Blu-ray/DVD Combo + Digital Copy) [Blu-ray] (Blu-ray)
By Zac Efron

Buy new: $24.99

First tagged “blu-ray” by Armchair Commentary “Amazon.com Movies & TV Editors”
Customer tags: blu-ray(2), high definition, 17 again, digital copy, zac efron, high school musical troy, matthew perry

Michael Jackson: The Music And The Money

July 2, 2009 by admin · Comment
Filed under: Xbox360 News 
Posted By:Jane Wells

474bb_jackson_michael_2.thumb Michael Jackson: The Music And The Money

Monday the two men who submitted a 2002 will for Michael Jackson naming them as co-executors will be in court with lawyers for Jackson’s mother.    1ffa8_more-bullet Michael Jackson: The Music And The Money Read More
Sectors:Media

Watchmen (Director’s Cut) (Two-Disc Special Edition + Amazon Digital Bundle + Digital Copy) (DVD) newly tagged "blu-ray"

July 2, 2009 by admin · Comment
Filed under: Xbox360 News 
Watchmen (Director's Cut) (Two-Disc Special Edition + Amazon Digital Bundle + Digital Copy)

Watchmen (Director’s Cut) (Two-Disc Special Edition + Amazon Digital Bundle + Digital Copy) (DVD)
By Matt Frewer

Buy new: $21.49

First tagged “blu-ray” by S. Chi
Customer tags: watchmen(10), superhero(9), alternate history(7), alan moore(7), dave gibbons(6), adventure(4), comics(4), animated(3), digital copy(3), action(3), billy crudup, 300

CodePlex Daily Summary for Thursday, July 02, 2009

July 2, 2009 by admin · Comment
Filed under: Xbox360 News 

CodePlex Daily Summary for Thursday, July 02, 2009

New Projects

  • NerdDinner(VB): 在看《ASP.Net MVC Step By Step》一书,决定把书上的NerdDinner项目用VB2010写一遍,借个地方放代码:)
  • Jac Silverlight Game Server: This is a silverlight games service project. Contains server and client code souce and demo.
  • Salient.MapIconSetMaker: A wrapper for google MapIconMaker. Dynamically generate sets of fully populated GIcon objects for use with Google Maps API. Includes a jQuery plug…
  • Silverlight Templates: Silverlight 3 templates that can be used with Blogger.com
  • JacDigitalDrum: Here is a computer digital Drum kit's softwear. Hardwear use arduino.
  • Cultiv Contact Form: The Cultiv Contact Form package allows you to quickly get a basic contact form in your Umbraco website.
  • JacArdSL: arduino comunication to silverlight
  • TE: This is to convert a global site of teleeye to .net.
  • YouTube API for ASP.NET: YouTube API for ASP.NET, AJAX-extended
  • Reflex: Reflex is a collection of tools, utilities and helpers methods for manipulating data via System.Reflection Reflex enable you to easily transform …
  • Sword of the Stars Calculator: The SotS Calculator is aimed at making quick decisions on whether or not to colonize that high CH planet. You can pick a race, appropriate techs, a…
  • MVC & jquery: Give me one more js framework? No, jquery is enough.
  • Umbraco Examine: Umbraco Examine is a powerful, fully configurable, and extensible library used for indexing Umbraco content to allow for fast and easy content sear…
  • upabibo-lib: Library management. This project is developed by Upabibo Hoang Anh Tran.
  • Single Sign On - Light Weight: Single Sign On (SSO) solution for cross domain sites which do not share cookies, session ids etc. Built using WCF Service. A Silverlight based sit…
  • TwiLite: A twitter API and client. TwiLite (Twitter Lite) has three goals: 1. Maximum Speed, both of user interface and API 2. Minimum system resource …

New Releases

Most Popular Projects

Most Active Projects

CodePlex Daily Summary for Thursday, July 02, 2009

July 2, 2009 by admin · Comment
Filed under: Xbox360 News 

CodePlex Daily Summary for Thursday, July 02, 2009

New Projects

  • NerdDinner(VB): 在看《ASP.Net MVC Step By Step》一书,决定把书上的NerdDinner项目用VB2010写一遍,借个地方放代码:)
  • Jac Silverlight Game Server: This is a silverlight games service project. Contains server and client code souce and demo.
  • Salient.MapIconSetMaker: A wrapper for google MapIconMaker. Dynamically generate sets of fully populated GIcon objects for use with Google Maps API. Includes a jQuery plug…
  • Silverlight Templates: Silverlight 3 templates that can be used with Blogger.com
  • JacDigitalDrum: Here is a computer digital Drum kit's softwear. Hardwear use arduino.
  • Cultiv Contact Form: The Cultiv Contact Form package allows you to quickly get a basic contact form in your Umbraco website.
  • JacArdSL: arduino comunication to silverlight
  • TE: This is to convert a global site of teleeye to .net.
  • YouTube API for ASP.NET: YouTube API for ASP.NET, AJAX-extended
  • Reflex: Reflex is a collection of tools, utilities and helpers methods for manipulating data via System.Reflection Reflex enable you to easily transform …
  • Sword of the Stars Calculator: The SotS Calculator is aimed at making quick decisions on whether or not to colonize that high CH planet. You can pick a race, appropriate techs, a…
  • MVC & jquery: Give me one more js framework? No, jquery is enough.
  • Umbraco Examine: Umbraco Examine is a powerful, fully configurable, and extensible library used for indexing Umbraco content to allow for fast and easy content sear…
  • upabibo-lib: Library management. This project is developed by Upabibo Hoang Anh Tran.
  • Single Sign On - Light Weight: Single Sign On (SSO) solution for cross domain sites which do not share cookies, session ids etc. Built using WCF Service. A Silverlight based sit…
  • TwiLite: A twitter API and client. TwiLite (Twitter Lite) has three goals: 1. Maximum Speed, both of user interface and API 2. Minimum system resource …

New Releases

Most Popular Projects

Most Active Projects

Loading and drawing a sprite

July 2, 2009 by admin · Comment
Filed under: Xbox360 News 

I've been following the book by Aaron Reed, Learning XNA 3.0.

I've just started reading it, and everything seemed clear up until the second chapter.

I added my sprite to the contents and compiled it.

I then added the line:

     Texture2D texture; 

Between the GraphicsDeviceManager and SpriteBatch lines of code.

I then added:

    Content.Load<Texture2D>(@"Images/logo"); 

In the load content section.

And finally, I added:

spriteBatch.Begin(); 
            spriteBatch.Draw(texture, Vector2.Zero, Color.White); 
            spriteBatch.End(); 

In the draw section, after the Clear call.

Apparently this should draw the logo on the screen once I hit debug.
However I'm receiving the following error message:

"This method does not accept null for this parameter." "texture"
and it highlights this line:

       

 spriteBatch.Draw(texture, Vector2.Zero, Color.White); 

Any help would be greatly appreciated. I've understood everything up to this point, but I can't get passed this.

When I created the new file, I selected XNA 3.0 and am using the PC version. I'm also using the Express edition of Microsoft Visual C# 2008.

Next Page »