Jump to content
Xtreme .Net Talk

romanhoehne

Members
  • Posts

    8
  • Joined

  • Last visited

Everything posted by romanhoehne

  1. TBFG (turn based fantasy game) That is the Code for the 1st Layer. numberOfBitmaps = how many different 32x32 pixel-Bitmaps will be used Game.mapBase = Array of integer (2dimensional) How can I improve permormance in this code? How can I do this in Direct3d? Thanks alot, Roman //Draw surface (gras, whater..) using System; using System.Drawing; using Microsoft.DirectX; using Microsoft.DirectX.DirectDraw; using TBFG; using TBFG.Global; namespace TBFG.Drawing { public class MapDrawObject { public MapDrawObject(Device display, int numberOfBitmaps) { _theMapSurfaces = new Surface [numberOfBitmaps]; _description=new SurfaceDescription(); _description.Clear(); _description.Width=32; _description.Height=32; for (int i = 0; i<numberOfBitmaps; i++) { _theMapSurfaces [i] = new Surface("Bilder\\Base\\" + i.ToString() +".bmp", _description, display); } } private SurfaceDescription _description; public Surface [] _theMapSurfaces; public void Draw(int xPos, int yPos, Surface _back) { int i = yPos; Rectangle destination = new Rectangle(0,0,32,32); for (i = yPos; i<Global.GlobalData.YResSqr +yPos; i++) { int j = xPos; for(j = xPos; j<Global.GlobalData.XResSqr +xPos; j++) { try { destination.Location=Game.target.PointToScreen(new Point((j-xPos)*GlobalData.SqaureResolution+32,(i-yPos)*GlobalData.SqaureResolution+32)); _back.DrawFast(destination.X, destination.Y, DrawingUtils.MapTile(j,i, Game.mapBase), new Rectangle(0,0,32,32), DrawFastFlags.DoNotWait ); } catch {} } } } } } //Draw trees, buidungs using System; using System.Drawing; using Microsoft.DirectX; using Microsoft.DirectX.DirectDraw; using TBFG; using TBFG.Global; namespace TBFG.Drawing { /// <summary> /// Summary description for BuildingDrawObject. /// </summary> public class BuildingDrawObject { public BuildingDrawObject(Device display, int numberOfBitmaps) { _description =new SurfaceDescription(); _buildingsurfaces = new Surface [numberOfBitmaps + 1]; _description.Clear(); ColorKey CC = new ColorKey(); int aColor = Color.FromArgb(148,101,66).ToArgb(); CC.ColorSpaceHighValue = aColor; CC.ColorSpaceLowValue = aColor; _buildingsurfaces [1] = new Surface("Bilder\\Advanced\\Dragonhost.bmp", _description, display); _buildingsurfaces [1].SetColorKey(Microsoft.DirectX.DirectDraw.ColorKeyFlags.SourceDraw, CC); _description.Clear(); aColor = Color.FromArgb(115,109,181).ToArgb(); CC.ColorSpaceHighValue = aColor; CC.ColorSpaceLowValue = aColor; _buildingsurfaces [2] = new Surface("Bilder\\Advanced\\Tree1.bmp", _description, display); _buildingsurfaces [2].SetColorKey(Microsoft.DirectX.DirectDraw.ColorKeyFlags.SourceDraw, CC); _description.Clear(); aColor = Color.FromArgb(191,123,199).ToArgb(); CC.ColorSpaceHighValue = aColor; CC.ColorSpaceLowValue = aColor; _buildingsurfaces [3] = new Surface("Bilder\\Advanced\\Rock1.bmp", _description, display); _buildingsurfaces [3].SetColorKey(Microsoft.DirectX.DirectDraw.ColorKeyFlags.SourceDraw, CC); } private SurfaceDescription _description; public Surface [] _buildingsurfaces; public void Draw(int xPos, int yPos, Surface _back) { int i = yPos; Rectangle destination = new Rectangle(0,0,0,0); for (i = yPos; i<Global.GlobalData.YResSqr+yPos; i++) { int j = xPos; for(j = xPos; j<Global.GlobalData.XResSqr+xPos; j++) { destination.Location=Game.target.PointToScreen(new Point((j-xPos)*GlobalData.SqaureResolution+32,(i-yPos)*GlobalData.SqaureResolution+32)); try { if(Game.mapAdvanced.GetMapValue(j, i)!=0) { _back.DrawFast(destination.X, destination.Y, DrawingUtils.MapTile(j,i, Game.mapAdvanced), DrawFastFlags.DoNotWait |DrawFastFlags.SourceColorKey ); } } catch {} } } } } }
  2. Hi, I have started writing a turn based game in directdraw with 2 layers (ground like gras, dessert.. and objects like trees or buldings over the ground) and animated sprites (loaded in frames, based on a timer), which I can move over the 2 other layers. But now... it seems, that the performance is not that good, if I have 50 animated sprites for example. Are there solutions (may be in c#), how to do this easy with direct3d? Does direct3d improves the performance compared to directdraw? Thanks, Roman
  3. Hello, I have a Problem: In my MainWindows I can easy access the Control - it ist simply "this". In my MainWindow I use a Class DrawingUtils an this class use other classes like Figure, witch should be draw: class Figure public void Draw (Control control) {Rectangle destination = new Rectangle(0,0,96,96); destination.Location=control.PointToScreen(new Point(360,360)); . . . class DrawingUtils private void CreateSurfaces(Control control) { _display = new Device(); _display.SetCooperativeLevel(control, CooperativeLevelFlags.Normal); How can I access the Control from my Mainwindow in a Class? I do not want to use Parameters like "(Control control)". Is there a way to access it from those classes? Thank You a lot, Roman
  4. Hi all, what is the fastest way to display Bitmaps using csharp and directx9? I use _primary.Draw(destination, MapTile(j,i), new Rectangle(0,0,32,32), Microsoft.DirectX.DirectDraw.DrawFlags.Wait, new DrawEffects() ) ; for the map and _primary.Draw(destination, _theSurfaces[0], DrawFlags.Wait | DrawFlags.KeySource) ; for a field what ist moving over the map. Has somebody other ways to do it? Ciao, Roman
  5. Thanx alot! Thanx for the help! Is there a way to bring bitmaps faster to the screen using directX9 / c#? When I move/scroll the map and the knight in windowed mode.. it seams to fl[ai]cker... Regards, Roman :rolleyes:
  6. Thanx alot! It works :) :) Regards, Roman
  7. Hi, I've downloaded some samples for directdraw, but only in directx7 (SpaceBreakout) or I've found some for dx9 in C or C++ on this pages here. I want to move some small bitmaps (50 times 50 Pixs) with black as transparent color over a map (400 times 400 Pixs visible, 1000 times 1000 virtual). All in mode "display.SetCooperativeLevel(this, CooperativeLevelFlags.Normal);" . FullScreen maybe later... Are here some good hints in csharp for directx9 here or has someone an example? Here is, what I have tried so far (the "knight" has still a black Border...): private void Draw() .... primary.Draw(destination, offscreen, new Rectangle(i,j,300,300), Microsoft.DirectX.DirectDraw.DrawFlags.Wait, new DrawEffects() ) ; primary.Draw(destination1, knight, DrawFlags.Wait); private void CreateSurfaces() { display = new Device(); display.SetCooperativeLevel(this, CooperativeLevelFlags.Normal); SurfaceDescription description = new SurfaceDescription(); description.SurfaceCaps.PrimarySurface = true; primary = new Surface(description, display); description.Clear(); clip = new Clipper(display); clip.Window = this; primary.Clipper = clip; description.Clear(); offscreen = new Surface("card.bmp", description, display); description.Clear(); ColorKey CC = new ColorKey(); CC.ColorSpaceHighValue = 0; CC.ColorSpaceLowValue = 0; knight = new Surface("knight.bmp", description, display); knight.SetColorKey(Microsoft.DirectX.DirectDraw.ColorKeyFlags.SourceDraw, CC); } Maybe, I have forgotten something Best regards Roman
  8. Hi, I've downloaded some samples for directdraw, but only in directx7 (SpaceBreakout) or I've found some for dx9 in C or C++ on this pages here. I want to move some small bitmaps (50 times 50 Pixs) with black as transparent color over a map (400 times 400 Pixs visible, 1000 times 1000 virtual). All in mode "display.SetCooperativeLevel(this, CooperativeLevelFlags.Normal);" . FullScreen maybe later... Are here some good hints in csharp for directx9 here or has someone an example? Here is, what I have tried so far (the "knight" has still a black Border...): private void Draw() .... primary.Draw(destination, offscreen, new Rectangle(i,j,300,300), Microsoft.DirectX.DirectDraw.DrawFlags.Wait, new DrawEffects() ) ; primary.Draw(destination1, knight, DrawFlags.Wait); private void CreateSurfaces() { display = new Device(); display.SetCooperativeLevel(this, CooperativeLevelFlags.Normal); SurfaceDescription description = new SurfaceDescription(); description.SurfaceCaps.PrimarySurface = true; primary = new Surface(description, display); description.Clear(); clip = new Clipper(display); clip.Window = this; primary.Clipper = clip; description.Clear(); offscreen = new Surface("card.bmp", description, display); description.Clear(); ColorKey CC = new ColorKey(); CC.ColorSpaceHighValue = 0; CC.ColorSpaceLowValue = 0; knight = new Surface("knight.bmp", description, display); knight.SetColorKey(Microsoft.DirectX.DirectDraw.ColorKeyFlags.SourceDraw, CC); } Maybe, I have forgotten something :( Best regards Roman
×
×
  • Create New...