Click here to Skip to main content
15,881,794 members
Articles / Artificial Intelligence

Rotating Sprite Objects on DirectDraw Wrapper for C#

Rate me:
Please Sign up or sign in to vote.
3.00/5 (4 votes)
9 Dec 2004CPOL4 min read 83.7K   637   25  
Evaluate C# on delivering more than 1000 animated sprites on fullscreen 1280x1024.
using System;
using System.Drawing;
using Microsoft.DirectX;
using Microsoft.DirectX.DirectDraw;
using DDW.DRAW;

namespace DDW.ENGINE
{
	public class CWorld
	{
		public string m_Name;
		public DDW.ENGINE.CEngine m_Engine=null;

		public Microsoft.DirectX.DirectDraw.Device m_Device=null;

		public DDW.DEBUG.CTrace m_Trace=null;

		public DDW.DRAW.CSprite m_SPR_BackDrop=null;

		public string m_WorldFileName="";
		public string m_WorldName="";


		public CWorld(CEngine e)
		{
			m_Engine=e;
			if (this.m_Trace==null)
				this.m_Trace = new DDW.DEBUG.CTrace();
		}
		~CWorld()
		{
		}

		public System.Exception Create(string filename, string worldname)
		{
			try
			{
				m_SPR_BackDrop = new DDW.DRAW.CSprite(m_Engine.m_Device.m_Device);
				m_SPR_BackDrop.Load("spr green","green01.bmp");
				m_SPR_BackDrop.m_Width=512;
				m_SPR_BackDrop.m_Heigth=512;
				return null;
			}
			catch(Exception e)
			{
				this.m_Trace.T("CWorld::Create>"+e);
				return e;
			}
		}

		public System.Exception Draw(Microsoft.DirectX.DirectDraw.Surface s)
		{
			try
			{
				s.Draw(
					new Rectangle(
						0,
						0,
						1280,
						1024
					),
					m_SPR_BackDrop.m_Surface.m_Surface,
					new Rectangle(
						0,
						0,
						m_SPR_BackDrop.m_Width,
						m_SPR_BackDrop.m_Heigth
					),
					DrawFlags.KeySource|DrawFlags.Wait
				);
				return null;
			}
			catch(Exception e)
			{
				this.m_Trace.T("CWorld::Draw>"+e);
				return e;
			}
		}
	}
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior)
Portugal Portugal
Financial Apps addict since early programming ages;
Statistical Apps writer;
Computer gamming and graphics programmer with a 2 commercial titles: Armor PC/PPC, MidWay XBOX/PC/PPC;
Manic Basketball fan and player;
Traveller;

Comments and Discussions