Click here to Skip to main content
16,006,355 members
Home / Discussions / C#
   

C#

 
GeneralC# Printable Reports from Access DB Pin
Glenn E. Lanier II31-May-05 10:24
Glenn E. Lanier II31-May-05 10:24 
GeneralRe: C# Printable Reports from Access DB Pin
KaptinKrunch31-May-05 19:04
KaptinKrunch31-May-05 19:04 
GeneralRe: C# Printable Reports from Access DB Pin
Glenn E. Lanier II1-Jun-05 3:01
Glenn E. Lanier II1-Jun-05 3:01 
GeneralRe: C# Printable Reports from Access DB Pin
Anonymous2-Jun-05 6:14
Anonymous2-Jun-05 6:14 
GeneralRe: C# Printable Reports from Access DB Pin
Glenn E. Lanier II2-Jun-05 6:32
Glenn E. Lanier II2-Jun-05 6:32 
GeneralRe: C# Printable Reports from Access DB Pin
KaptinKrunch2-Jun-05 16:14
KaptinKrunch2-Jun-05 16:14 
GeneralRe: C# Printable Reports from Access DB Pin
Glenn E. Lanier II6-Jun-05 6:57
Glenn E. Lanier II6-Jun-05 6:57 
GeneralI'm Totally Stumped - DirectDraw C# Surfaces Pin
YawgmothIII31-May-05 8:59
YawgmothIII31-May-05 8:59 
Ok I've been lurking around your site for a while now and the articles/tutorials have been a great help, but i've seem to run into.. something..

I'm trying to learn how to program for DirectX in C#. I only plan to use DirectDraw at the moment, and I think I've started to get a decent understanding of how it all works.

Now for the problem....

The problem started when I was getting this error:
- Object reference not set to an instance of an object

Now that I understand what the compiler is saying is wrong i was able to make that error go away.. though i don't fully understand why...lol.
Appearently all i needed was:
- SpriteSet[(int)Sprite.BlueBlob] = new classSprite();

but i thought it already did that when I did this:
- private classSprite[] SpriteSet = new classSprite[2];

So if anyone could explain that to me, it would be greatly appreciated.
The new problem is:
- Value does not fall within the expected range

when i try to do this:
TempSurface = new Surface(SpriteSet[(int)Sprite.BlueBlob].FilePath, description, display);

I have stripped this program many times, trying to find out what i needed to change but have been unable to find anything. plz help me!

I've only pasted here what i think you may need to solve my problem... if there is a better way you'd like me to post it or if you need more, just say.

The line the Error occurs is at the bottom of the code.

<br />
// Define Sprite Class<br />
		public class classSprite<br />
		{<br />
			public string FilePath;<br />
			public int Height = new int();<br />
			public int Width = new int();<br />
			public Surface SpriteSurface;<br />
			public SurfaceDescription desc = new SurfaceDescription();<br />
			public int tFrames = new int();<br />
			public Rectangle[] frames;<br />
			public int[,] FrameRefrences = new int[4,8];<br />
			public int[] AnimTotals = new int[4];<br />
		}<br />
		// Define Unit Class<br />
		public class classUnit<br />
		{<br />
			public uint CurrentFrame;<br />
			public uint CurAnim;<br />
			public uint PrevAnim;<br />
			public int AnimX;<br />
			public int AnimY;<br />
			public int UnitSpriteSet;<br />
			public int Facing;<br />
		}<br />
		// Setup Enumerations<br />
		enum Sprite {BlueBlob, RedBlob};<br />
		enum Dir {N, NE, E, SE, S, SW, W, NW};<br />
		enum Anim {Walk, Attack, Death, Dead};<br />
<br />
		// Create Arrays of Unit and Sprite classes<br />
		private classSprite[] SpriteSet = new classSprite[2];<br />
		private classUnit[] Units = new classUnit[1]; <br />
<br />
		private System.ComponentModel.IContainer components;<br />
		private System.Windows.Forms.Timer AnimationTimer;<br />
		private System.Windows.Forms.Label label1;<br />
<br />
		// The DirectDraw Device, used in all the application<br />
		private Device display = new Device();<br />
		// The Front Surface<br />
		private Surface front = null;<br />
		// The Back Surface<br />
		private Surface back = null;<br />
		<br />
		private Surface TempSurface = null;<br />
		// The Clipper<br />
		private Clipper clip = null;	<br />
<br />
<br />
private void InitDirectDraw()<br />
		{<br />
			// Used to describe a Surface<br />
			SurfaceDescription description = new SurfaceDescription();<br />
			// Init the Device<br />
			display = new Device();<br />
#if DEBUG<br />
			display.SetCooperativeLevel(this,CooperativeLevelFlags.FullscreenExclusive);<br />
#else<br />
			// Set the Cooperative Level and parent, Setted to Full Screen Exclusive to the form)<br />
			display.SetCooperativeLevel(this, CooperativeLevelFlags.FullscreenExclusive);<br />
			// Set the resolution and color depth used in full screen(640x480, 16 bit color)<br />
			display.SetDisplayMode(640, 480, 16, 0, false);<br />
#endif<br />
			// Define the attributes for the front Surface<br />
			description.SurfaceCaps.PrimarySurface = true;<br />
#if DEBUG<br />
			front = new Surface(description, display);<br />
#else<br />
			description.SurfaceCaps.Flip = true;<br />
			description.SurfaceCaps.Complex = true;<br />
<br />
			// Set the Back Buffer count<br />
			description.BackBufferCount = 1;<br />
<br />
			// Create the Surface with specifed description and device)<br />
			front = new Surface(description, display);<br />
#endif<br />
			description.Clear();<br />
#if DEBUG<br />
			description.Width = front.SurfaceDescription.Width;<br />
			description.Height = front.SurfaceDescription.Height;<br />
			description.SurfaceCaps.OffScreenPlain = true;<br />
			back = new Surface(description, display);<br />
#else<br />
			// A Caps is a set of attributes used by most of DirectX components<br />
			SurfaceCaps caps = new SurfaceCaps();<br />
			// Yes, we are using a back buffer<br />
			caps.BackBuffer = true;<br />
<br />
			// Associate the front buffer to back buffer with specified caps<br />
			back = front.GetAttachedSurface(caps);<br />
#endif<br />
			// Create the Clipper<br />
			clip = new Clipper(display);<br />
			/// Set the region to this form<br />
			clip.Window = this;<br />
			// Set the clipper for the front Surface<br />
			front.Clipper = clip;		<br />
	<br />
			description.Clear();<br />
			// Load Blue Blob Data<br />
			SpriteSet[(int)Sprite.BlueBlob] = new classSprite();<br />
			SpriteSet[(int)Sprite.BlueBlob].FilePath = Application.StartupPath + "\\BlueBlob_Sequence.bmp";<br />
			SpriteSet[(int)Sprite.BlueBlob].Height = 40;<br />
			SpriteSet[(int)Sprite.BlueBlob].Width = 40;<br />
			TempSurface = new Surface(SpriteSet[(int)Sprite.BlueBlob].FilePath, description, display);// This is the line the Error Occurs<br />
			SpriteSet[(int)Sprite.BlueBlob].SpriteSurface = TempSurface;<br />
			SpriteSet[(int)Sprite.BlueBlob].desc = description;<br />
			SpriteSet[(int)Sprite.BlueBlob].tFrames = 152;<br />
			SpriteSet[(int)Sprite.BlueBlob].frames = new Rectangle[SpriteSet[(int)Sprite.BlueBlob].tFrames];<br />
			SpriteSet[(int)Sprite.BlueBlob].AnimTotals[(int)Anim.Walk] = 10;<br />
			SpriteSet[(int)Sprite.BlueBlob].AnimTotals[(int)Anim.Attack] = 5;<br />
			SpriteSet[(int)Sprite.BlueBlob].AnimTotals[(int)Anim.Death] = 4;<br />
			SpriteSet[(int)Sprite.BlueBlob].AnimTotals[(int)Anim.Dead] = 1;<br />
			}<br />
		}

GeneralRe: I'm Totally Stumped - DirectDraw C# Surfaces Pin
Christian Graus31-May-05 11:53
protectorChristian Graus31-May-05 11:53 
GeneralRe: I'm Totally Stumped - DirectDraw C# Surfaces Pin
Anonymous31-May-05 12:42
Anonymous31-May-05 12:42 
GeneralRe: I'm Totally Stumped - DirectDraw C# Surfaces Pin
Christian Graus31-May-05 12:50
protectorChristian Graus31-May-05 12:50 
GeneralRe: I'm Totally Stumped - DirectDraw C# Surfaces Pin
Anonymous31-May-05 15:04
Anonymous31-May-05 15:04 
GeneralRe: I'm Totally Stumped - DirectDraw C# Surfaces Pin
Christian Graus31-May-05 15:21
protectorChristian Graus31-May-05 15:21 
Generalusing windows' auto complete Pin
Green Fuze31-May-05 8:43
Green Fuze31-May-05 8:43 
GeneralRe: using windows' auto complete Pin
OMalleyW31-May-05 9:00
OMalleyW31-May-05 9:00 
GeneralRe: using windows' auto complete Pin
Green Fuze31-May-05 12:35
Green Fuze31-May-05 12:35 
QuestionVideo Buffer? Pin
OMalleyW31-May-05 8:13
OMalleyW31-May-05 8:13 
AnswerRe: Video Buffer? Pin
OMalleyW1-Jun-05 7:16
OMalleyW1-Jun-05 7:16 
GeneralLooking for MS Word AutoShape like Toolbar Pin
Don Ashworth31-May-05 7:56
Don Ashworth31-May-05 7:56 
GeneralOdbcDataReader!! Pin
trk_wakil31-May-05 7:34
trk_wakil31-May-05 7:34 
GeneralRe: OdbcDataReader!! Pin
KaptinKrunch31-May-05 19:47
KaptinKrunch31-May-05 19:47 
GeneralRe: OdbcDataReader!! Pin
trk_wakil1-Jun-05 1:08
trk_wakil1-Jun-05 1:08 
Generalneed client-based component for use in web pages Pin
ctlajoie31-May-05 6:54
ctlajoie31-May-05 6:54 
QuestionProcessStartInfo.Arguments - No Spaces in Path? Pin
pgaribay521131-May-05 6:46
pgaribay521131-May-05 6:46 
AnswerRe: ProcessStartInfo.Arguments - No Spaces in Path? Pin
r_u_i_z_m31-May-05 7:06
r_u_i_z_m31-May-05 7:06 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.