
rifter1818
Avatar/Signature-
Posts
257 -
Joined
-
Last visited
Content Type
Profiles
Forums
Blogs
Events
Articles
Resources
Downloads
Gallery
Everything posted by rifter1818
-
and there Much better explination Joe Mamma
-
Hope this helps You dont "need" events, there are *always* (until someone gives me an example otherwise (not including the events allready there)) ways of coding to avoid needing events.. However they are very usefull especially when writing class's that other people will be using. Say you have a class and something important happens with varying frequency, maybe the program may have to react maybe it wont, with events you dont have to worry about whether its needed or not... Code example (because my writen descriptions suck). /* Without Events */ //inside the dll class MYCLASS { int X; public virtual int x{ get{return 1;} set{X = value;} } } ////the dll users code class fMYCLASS : MYCLASS { override int x{ get{ someonewaslookingatx(); return X; } set{ someonechangedthevalueofx(); X=value; } } void someonewaslookingatx(){...} void someonechangedthevalueofx(){...} } //With Events //Dll Code class MYCLASS { int X; public delegate void PointlessEvent(); public event PointlessEvent xget; public event PointlessEvent xset; public int x{get{if(xget!=null)xget();return X;} set{if(xset!=null)xset();return X;} } } //thier code no inherited class they can just classinstance.xget += new EventHandler(functionname).... as you can see there is no need for a inheriting class with events, this style of solution can be used much better than shown but hopefully you get the idea.
-
How do i get the icon for a file (all i need is the filename of the icon so i can load the icon...) Even shortcuts aswell, windows knows which icon to use therefor the information must be stored somewhere, C# is prefered for any examples. Thanks
-
I wrote up a very simple bitmap manager using a hashtable, but when i use the remove function it eventually throws the error (at a seemingly random point) "An unhandled exception of type 'System.InvalidOperationException' occurred in system.windows.forms.dll Aditional information: Collection was modified; enumeration operation may not execute." Well lets see here keywords MODIFIED, MAY. MODIFIED of course it was modified, i just removed almost all of its members your dang right modified. MAY i dont care if it may not continue it dang well should and will continue however. If anyone can give me a hand that would be great public void Flush(string KeyContains) { //hbitmaps is the hashtable in question, all keys are strings all values bitmaps. foreach(object t in hbitmaps.Keys) if(((string)t).IndexOf(KeyContains) != -1) hbitmaps.Remove(t); }
-
Im trying to add two scroll bars to a form (through code not the "designer") with the following properties: The Virticle Scroll bar is 24 Width and Form.Height-24 Tall at (Form.Width-24,0) (24 wide,streching from the top to 24 short of the bottom anchored on the right) Same for the Horisontal but its on the bottom streching the width - 24 (and 24 tall) here is my code (its for a map editor for a recreation of Sid Meiers Railroad Tycoon). public class mapVScroll : VScrollBar { protected override void OnResize(EventArgs e) { base.OnResize (e); if(Parent == null) return; Maximum = (((MAPVIEWER)Parent).Height - Height)/((MAPVIEWER)Parent).TileViewSize; if(Value > Maximum) Value = Maximum; } public mapVScroll(){} } public class mapHScroll : HScrollBar { protected override void OnResize(EventArgs e) { base.OnResize (e); if(Parent == null) return; Maximum = (((MAPVIEWER)Parent).Height - Height)/((MAPVIEWER)Parent).TileViewSize; if(Value > Maximum) Value = Maximum; } public mapHScroll(){} } public class MAPVIEWER : Form { mapHScroll hscroll; mapVScroll vscroll; GTEXMAN TexManager{get{return ((clsMapEditor)MdiParent).texman;}} public int TileViewSize{get{return 64;}} public MAP map{get{return((clsMapEditor)MdiParent).map;}} public MAPVIEWER() { SetStyle(ControlStyles.DoubleBuffer,true); SetStyle(ControlStyles.AllPaintingInWmPaint,true); MaximizeBox = false; hscroll = new mapHScroll(); vscroll = new mapVScroll(); Controls.Add(hscroll); Controls.Add(vscroll); hscroll.Location = new System.Drawing.Point(0,Width-24); hscroll.Size = new System.Drawing.Size(Height-24, 24); hscroll.Anchor = (AnchorStyles)(AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right); vscroll.Location = new System.Drawing.Point(Height-24, 0); vscroll.Size = new System.Drawing.Size(24, Width-24); vscroll.Anchor = (AnchorStyles)(AnchorStyles.Top | AnchorStyles.Bottom| AnchorStyles.Right); OnResize(new EventArgs()); } protected override void OnPaint(PaintEventArgs e){base.OnPaint(e);} protected override void OnClick(EventArgs e){base.OnClick(e);} protected override void OnResize(EventArgs e) { base.OnResize(e); if(Height < TileViewSize*6) Height = (TileViewSize*7) + 24; if(Width < TileViewSize*6) Width = (TileViewSize*7) + 24; if((Width-24)%TileViewSize!=0) Width -= (Width-24)%TileViewSize; if((Height-24)%TileViewSize!=0) Height -= (Height-24)%TileViewSize; } } Why will the scroll bars not go where they are supposed too? (Currently for me the virticle scroll bar appears to be about 12 pixels to the right of where it should be and im yet to find the horisontal one (im guessing its just below the form))
-
I dont think so I think all you can do to improve it is to use hardware, can you persay use DeviceType.Hardware, CreateFlags.SoftwareVertexProcessing ? EDIT[(requres less (as far as i know) than Hardware | Mixed, actually thinking about it your only allowed one of either Software hardware or mixed arnt you?] Scratch that i read Mixed instead of Multithread my bad. But i still think that your best bet is to use HardWare,SoftwareVertexProcessing
-
Proof of problem with sprites DX9.0C? The following program is just a simple WindowsApplication with the following adjustments //Add Refrecnce to Directx,Direct3d,Direct3dx ... using Microsoft.Directx; using Microsoft.Direct3D; ... Device dev; Sprite s; Texture t; public Form1() { InitializeComponent(); PresentParameters pp = new PresentParameters(); pp.Windowed = true; pp.SwapEffect = SwapEffect.Discard; pp.BackBufferHeight = 768; pp.BackBufferWidth = 1024; this.Show(); dev = new Device(0,DeviceType.Hardware,this,CreateFlags.SoftwareVertexProcessing,pp); dev.RenderState.Lighting = false; s = new Sprite(dev); t = TextureLoader.FromFile(dev,"C:\\Test.bmp"); Render(); } void Render() { for(int i = 0;i<600;i++) { dev.Clear(ClearFlags.Target,Color.Black,0,0); dev.BeginScene(); s.Begin(SpriteFlags.None); s.Draw2D(t,new Point(32,32),0,new Point(32,32),Color.White); s.Draw2D(t,Rectangle.Empty,Rectangle.Empty,new Point(512,384),Color.White); s.End(); dev.EndScene(); dev.Present(); Application.DoEvents(); } } Note The Form is set to start Maximized. The above code does indeed render both sprites fine, however if I comment out the first s.draw2d neither render! Problem is that i want to draw my sprites using the second type of rendering but it doesnt seem to draw without the other being called first!
-
What i want to do is create a color track bar (a gradient triangle with a slider) I had a great one working by inheriting a trackbar and overriding the on paint, but i cant find a way to disable the apparant minimum size of the trackbar object (the size i want is 150x10) but it refuses to go that small and takes up roughly 2.5 - 3 times that height. How can i get rid of this problem?
-
Web site with a ???? so i can put up my crappy game
rifter1818 replied to rifter1818's topic in ASP.NET
Found it I had been searching for GDI + ASP, GDI in asp, GRAPHICS IN ASP GOD #*@* it etc, i plugged in C# applet and found what i was looking for, the trick is to program a dll that contains a controll (: usercontroll) then you can load it into the web page using one line of html, of course being .net it then only works in IE, only can be hosted on IIS compatible whatever so ill probrably just learn java anyways but using the GDI is so braindead easy, although i guess i could in theory use directx (mindless overkill). -
Web site with a ???? so i can put up my crappy game
rifter1818 replied to rifter1818's topic in ASP.NET
Im working on getting the basics of asp down but no matter how much i search i cant seem to be able to find how to access the GDI, the closest ive gotten is using it to create a image save the image and then load the image at site startup but that is a)done once and b)too slow a process for what i need. So i guess my real question is how do i create something that i can render to using a system.drawing.graphics object. -
I really have about 0 knowledge in ASP.net but as usual i want to learn by jumping in the deep end and then trying not to drown so please feel free to make your answers very step by step/simple. What i want to do is create a page with a ?applet? on it, what ive done is created a rather simple game (Automoton, but extended it slightly) using C# and System.drawing (GDI?) so the not so simple next step is to fire the game on a website, but i have no idea how to create an area which i can render my game on. Once that is all sorted out you can face the wrath of my unstoppable 30 second AI (Make list of possible moves and choose randomly). Anyways Thanks in advance for your help.
-
Another deffinition of idle Could be that the cpu hasnt been used by anything other than windows. (having trouble thinking of examples of idle other than no user input).
-
If im not mistaken Your rendering 2d Text, and all your missing is as follows Sprite s = new sprite(device); s.begin(SpriteFlags.AlphaBlend); font.drawtext(s,text......); s.end(); .... and that works for rendering 2d text, my problem is 3d text however.
-
Im having trouble with 3d Text (Mesh.FromText) in the fact that no matter what font i send to it its allways the same new Font("Arial",12) == new Font("Arial",4) == new Font("Courier",32). Someone help me avoid the facist font ideals of Directx! System.Drawing.Font f = new System.Drawing.Font("Courier",12); This = Mesh.TextFromFont(D.device,f,"This game was made using",0.001F,0.3F); f= new System.Drawing.Font("Arial",16); MESH2 = Mesh.TextFromFont(D.device,f,"My Lame atempt at a Game Engine",0.001F,0.5F); f= new System.Drawing.Font("Courier",8); V = Mesh.TextFromFont(D.device,f,"V1.0.0",0.001F,0.2F); Not my final choices in fonts but right now when i render all three mesh's are the same font and size. PS, if you cant allready tell ive decided to make my posts as obscure as possible whilst remaining on topic. Thus Font Nazi! Cheers
-
Pent? Are you Sure about this? World = Matrix.Translation(2,0,0); World = Matrix.Translation(-2,0,0); Leaves it at (0,0,0)? I thought it would leave it at (-2,0,0) but i guess it shows you learn every day. Oh well just my $0.02 worth, and by the way nice responce you nailed the question better than i did, oh well.
-
Sprites, Come see the amaising invisible Sprites
rifter1818 replied to rifter1818's topic in DirectX
My Bad The Sprites do work its just that the color supplied is more like Lighting than Transparancy, So i guess the next question is how to apply transparancy to a texture, as far as i can tell the way to do it is to get the surface of the texture make a copy the use UpdateSurface to update the texture surface using the copy while applying a color key, but my attempt to do so failed to make the color transparant i will post code shortly but im without internet right now so it may take a while. -
Im having trouble rendering with sprites device.clear(....) device.beginscene() sprite.begin(SpriteFlags.AlphaBlend) sprite.draw2d(Texture,Rectangle.Empty,new Rectangle(0,0,100,100),new Point(),Color.Black) sprite.end() device.endscene() device.present() Simple enough render sequence but the sprite is no where to be found. (What i want is to render a texture with Black Transparant) Help please? Edit Directx 9.0C
-
If your going to be doing it purly in 2d it might be easier to use a sprite to render textures instead of a Vertex Array, However your question pertains to said array so ill see what i can do to help you there, most of the graphics i use Directx for are fully 3d So here is my suggestion to you, You should only need 1 Vertex Array for all the tanks (assuming they all look the same) then just have different colors or textures to tell them appart (easy part). Now the way i do my tranformations is as follows, Simply Translate the world matrix to what you want device.transforms.world=Matrix.Multiply(RotationMatrix,TranslationMatrix); Render that object and then transform the world to the next object and render that one, You might want to play around with the multiplication thinking about it maybe its supposed to be the other way around (Translation * Rotation) but thats a miniscule point. The important part is that changing the world matrix doesnt effect anything that has been rendered only what you are rendering (with the current world matrix). Anyways thats my suggestion for your question hope this helps. Edit Almost forgot the other part to your question. All the corrordinants are in Units (general) how many pixels each is depends on your Viewport and projection etc, the easiest way to picture it for me is like a camera, 1 unit could be 10 pixels but if you zoomed in it could be 50 pixels so its really all relative. The best thing for you to do i think before you start on the game is just play around with 1 or 2 objects and the "camera" until you get used to it (assuming you are using 3d) The "camera" is adusted by using Matrix.LookAtLH() or Matrix.LookAtRH() as your view matrix, the Projection Matrix can then be thought of as the type of lense you use, you can set Near and Far clip plains and the View Angle (which if you are crafty with it can be used for creating a zoom lense like effect). Then i guess comes the options of whether you move all the objects and leave the camera stationary, or move the Camera.... Oh yes and ill randomly through this in, to get from Screen Space to World space and back you use Vector3.Project() and Vector3.UnProject() which can be a little tricky, at first but once you get used to them its easy as pi. I guess all of Directx is like that really, leaving only the question how easy is pi?
-
I think you got it there That sounds about right, Ill have to apply some normals when i get a chance, just the transparancy problem left to go and one more project effectively done! (with many debts owing to the people here).
-
This is odd but when i enable lighting everything disapears, however Ambient is set to white? Also i still cant get my engine to use Black as transparant. d3d.Dev.RenderState.Lighting = true; d3d.Dev.RenderState.Ambient = Color.White; d3d.Dev.RenderState.CullMode = Cull.None; d3d.Dev.RenderState.AlphaBlendEnable = true; d3d.Dev.RenderState.AlphaTestEnable = true; d3d.Dev.RenderState.ReferenceAlpha = Color.Black.ToArgb(); d3d.Dev.RenderState.AlphaFunction = Compare.NotEqual; d3d.Dev.RenderState.AlphaSourceBlend = Blend.SourceAlpha; d3d.Dev.RenderState.AlphaDestinationBlend = Blend.InvSourceAlpha; d3d.Dev.RenderState.ColorVertex = true; d3d.Dev.RenderState.AlphaBlendOperation = BlendOperation.Add;
-
Capture a form rectangle to bmp...
rifter1818 replied to AlexCode's topic in Graphics and Multimedia
here it is in C# pretty much the same in vb bitmap = form.backgroundimage.clone(); bitmap = bitmap.clone(rectangle,bitmap.pixelformat); bitmap.save(FileName,ImageFormat); The Image format is a enum in System.Drawing.Imaging and can be bmp or jpg plus many others, the rectangle can be either a Rectangle or a RectangleF, the form is well a System.Windows.Forms.Form and the bitmap is well a System.Drawing.Bitmap. Good luck! -
well darn i liked not having to strongly type every variable... oh well its not that big of a deal, and shouldnt k = 2, i = 2,b = 3 after the abouve mentioned code as arnt the ++ operaters supposed to be acted opon after the function? example while(cin >> Array[index++]){} well fair enough thats not actually a function but you get my point. anyways thanks for your input you two :D
-
As far as i can tell : is not inheritance/implementation (yes i now code in c#), the usage allows you to pass multiple of the same value type, like lets say a vertex has 2 texture coordinants (usage 0 and 1)... EDIT that would be for say 2 textures (aka compleatly different coordinants just to be clear).
-
in C++ i could just state say #define Lerp(a,b,t)(a + ((b-a)*t)) and be on my way but this does not work quite so happily in c#, anyways i like my loosly defining simple equations (i mananged a close to 75% code reduction with perlin noise (to the point that i can now understand my code where as it took me a month to fully understand Ken Perlins code (although granted i didnt know c++ at the begining of that month). Anyways thanks in advance.