Jump to content
Xtreme .Net Talk

Nerseus

*Experts*
  • Posts

    2607
  • Joined

  • Last visited

Everything posted by Nerseus

  1. Are you selecting the controls from the Designer (not from code view) and deleting them? It seems easier to start a new project than trying to delete the controls every time you want a new empty project for testing. Normally, you'd have to also remember to delete any extra classes, functions, and other code as well as the controls. -Nerseus
  2. I think you need a personal trainer, wyrd. Not to help you code but to push you into coding every day. Distractions seem to be more the rule than the exception :) -nerseus
  3. Ah, you must have chosen VB6 compatability when you setup Visual Studio. The F10 key corresponds to F8: step into. Step Into means pressing the button on a call to a function will next walkthrough code inside of the function. If you press Shift-F8 (or F11) - you'll step Over a function. Meaning the code inside the function runs (and will still stop on a breakpoint if one is set), but you won't stop on any lines inside the function. If I'm running through a loop 250 times, I don't usually put a breakpoint with a count of 250. I just set a breakpoint on the line after the loop - unless of course you want to walk through the loop but only on the 250th pass. :) -Nerseus
  4. I've found that in some cases, one generic class for a game entity just won't work. For instance, I use a Ghost object to hold a ghost's data (in a Ms Pacman clone) - position, speed, state, AI, etc. - and a GhostUI class to handle the graphics portions. Splitting it apart means I can change the graphics easily without worrying about the "real" ghost. The graphics are, after all, just for display and having nothing really to do with a Ghost. Having said that, the Ghost object DOES use the GhostUI for a few things, such as the size of the sprite (to calculate how close a Ghost can be to a wall before going through it). I also have some manager type classes that do nothing but handle the graphics used by each class. For instance, I have all the sprites in one bitmap. I don't want a separate copy of the whole bitmap for each instance of GhostUI. The manager class really came about when I went to DirectX. The performance of having a separate texture per object and all the extra vertex buffers (rather than one large one) caused some performance issues. I was getting 20-30 FPS one a simple 480x640 (taller than wide) version of Ms Pacman with not a whole lot going on. I isolated it to the rendering and did some research, found out what worked for me and changed things. The full details of the implementation aren't that important in themself. I only bring them up to point out that if you have your Data-related "stuff" in a class AND have the Graphics-related "stuff" in the same class, you may run into complications later when you try and change something. You can start with the cleanest code in the world, but one little problem may force you to rethink how all of your classes work and/or are structured. The key is to code some sample projects (prototypes) to be sure of how things work before really starting on your "final" version of the game. Many business apps don't need this prototype for speed or workability issues. They use screen prototypes to see if the design is good, but they usually don't do much. With a game, the prototype is all about "will this work" and not as much about how it looks. -Nerseus
  5. Even if they're both done in DirectX or GDI, why not create another? I thought the point of programming such as simple game (for Wyrd, from another topic) was to get some experience? You *could* make up your own idea for a simple game. But, if you start with a well-established idea you can skip that step and get to the coding part. On a new game, just defining all the rules and options is a major piece. There's nothing wrong with borrow from a solid idea to get your feet wet. -Nerseus
  6. What does the dbmon application report? dbmon.exe is located at: C:\DXSDK\Bin\DXUtils If you run it, then run your application in Debug mode, the dbmon window will show some diagnostics, including more descriptive errors than what you get inside Visual Studio. -Nerseus
  7. The @ (at sign) is used to designate something as a variable in SQL Server. Since you're executing a single line SELECT, there are no variables (normally they're used in stored procedures and user defined functions). I think you just want: DA.SelectCommand = "Select title,titleid from titles where title LIKE '" + txtTitle.Text.Replace("'", "''") + "%'" I assumed your textbox was called txtTitle and that you're building this SQL string "by hand". The replace is in case the user enters anything with a single quote in it. -Nerseus
  8. Well to use Debug.Write or Debug.WriteLine, simply add a using (or Imports in VB) statement at the top of the class for the library "System.Diagnostics". Or, you can use System.Diagnostics.Debug.WriteLine() (I prefer the using/Imports line). It writes out to the Output window by default. If you don't have one open, press Ctrl-Alt-O. It should come up every time you run as it shows the build process, warnings and errors, etc. It has limited usefulness as you have to recompile to add a new Debug.WriteLine statement. But, if you want to put one in every event you can trace the order of events and such. The autos/locals windows are immensely helpful as you can drill down to see any property of any object (more or less). Not much to explain there - if you think variable a has a value, expand the treeview window and look at the property to see the value. There's a CallStack window, too. If you set a breakpoint in a function or event, you can open the CallStack and see everything that's executed up to that point. Double clicking takes you back to the code that called it. Bold items are YOUR code, grey lines are system DLLs or other code that's unavailable in source mode. If you use breakpoints to stop your code and look at the state of things (always a good idea), then you should be aware that you can't walk into an event. Meaning you can normally press F11 and step INTO a function (or F10 to step over it). If you're on a line of code such as "this.Show()" or "Me.Show()" and you know the next event is Form_Load, it will not step into Form_Load (an event). You'll have to set a breakpoing in Form_Load to continue walking through the code there. If you have any specific debugging questions, such as how to do a certain something, let me know :) -Nerseus PS I forgot to mention that breakpoints can now be conditional. Meaning, you can right-click a breakpoint and select properties. You can then have the breakpoint only trigger on the 2nd time it hits, every other time it hits, etc. Very neat-o stuff. Not to mention, breakpoints and their properties are now saved with your project :)
  9. I did some research into the static constructor... sorry about the mistake. Unfortunately, my test was using "public static Class2" instead of just "static Class2" - I didn't really read the error message, just assumed you couldn't have a static constructor. The static constructor seems to work like Sub Main in a DLL in VB6. It only gets called once and only when you first create an instance of the class. So if you have two constructors, one static one not, the static one gets called first then the non-static one. Even when all instances of the class are disposed and collected and then a new instance is created, only the non-static constructor is called. Hope that helps :) As for the original problem, for the most part I wouldn't worry about the cleaning up of the objects as far as performance is concerned. You're going to load bitmaps for a game so just load them. As Volte said, as long as there is a reference to the object the GC will not collect it. When you're truly done with the reference, you'll have to clear it (use Dispose followed by setting the variable to null). Let the GC collect it when it's ready. If you start loading more images and the system is running out of memory or handles, the GC will detect it and clear the unused images for you. The only time I can think of that you wouldn't want the GC to run automatically (meaning you start handling some of the memory management yourself) is if you were doing a LOT of loading/unloading of images (or resources in general). If, for instance, you were loading a WAV file every time you wanted to play it. Since you're leaning towards loading the bitmaps once only, I wouldn't worry about the performance of the GC running. -Nerseus
  10. If you're using Bound Controls, you don't care about the controls in the Save button. As changes are made to the controls the new values are automatically saved in the DataSet. You can get the current row through the BindingContext if you need it (instead of using the NewRow variable). Normally if you're allowing the user to press a "New Row" button, you're letting them add multiple rows and change multipe rows and then saving ALL the changes at once. First, are you using Bound controls? Second, what's the scope of a transaction? Meaning, is a transaction just ONE insert/update/delete, or is it multiple records? Can it be multiple records from multiple tables, or just from one table? -Nerseus
  11. I'd take a look at early Atari 2600 games as an idea for a first attempt at a game. Then move on to a more advanced Atari 2600 game, then maybe an early Nintendo game (a scaled down version of Mario *maybe*)... then, well don't get too far ahead til you've tried one or two of the easier ones. They may seem childish now, but back then Pacman was $50 for the Atari 2600 version - people made careers coding them. Just because it's not high tech glossy 3D doesn't mean you can code it in a weekend. :) btw, I revise my original statement: stop spending 2 hours a day posting and instead start planning a game *then* code it. Forgot the planning part in my original statement. :) -Ner
  12. Well your new code is simply calling ToString on the returned object which will ALWAYS work. In the original code you were assigning a specific variable type to the value, which needed converting. Using the ordinal position versus column name would have no impact on the original error. Using the ordinal is probably slightly faster but less readable. That's about the only difference... -Ner
  13. Easy answer: You can't have a static constructor or destructor :) If you really need them around all the time, you can use internal, private, etc. static variables. Wrap them in a property that first checks if the variable is null and instantiates it and loads the image. On future calls to get the image the if will be false (image already loaded) and just return the image reference. -Nerseus
  14. No. I don't know of any way to get a partially blended form. Certain versions of windows support the transparency of a form, but I don't think it works other than as a single value for the whole form. I understand what you have/want, but I'm not sure it's possible without breaking up the form into multiple forms. As far as DX is concerned, it MUST be tied to a window to do any drawing. I don't think I've ever heard of tieing it to the desktop. As for drawing, you can't draw outside of the form's boundary. So you'd have to be able to make the form fully transparent but still have DX drawing show up. I don't know if that's possible - I think I'd stick with the regions. -Nerseus
  15. Maybe you can explain what it is you're trying to do... Are you wanting to create a new bitmap (new image data as well) that uses the Palette of an existing bitmap? So Bitmap1 is a house, Bitmap2 is a car and you want Bitmap1 to use the palette of Bitmap2? Or maybe something else...? -Nerseus
  16. In the "New" button, add a row to the DataTable (as it sounds like you did), but don't change any control's properties. Instead, set the position property of the binding context to the new row, the bound controls will clear automatically (or will show any default values in your DataSet). To set the position, use: 'maybe Count - 1... BindingContext(dsCountry.Tables("Country").DefaultView).Position = dsCountry.Tables("Country").DefaultView.Count; If you don't reposition the BindingContext, you'll always be pointing to the first row in the DataTable. If you have next/prev buttons, you can have them increase and decrease the Position property. -Nerseus
  17. I would say "yes" it's Ok, but it's hard to say without trying it out. I've never tried to do AddNew on the BindingContext object, I always go through the table (ds.Tables[...].Rows.Add()). I know the BindingContext array (or indexer) sees the table differently than the DefaultView of the table and will give you two different references, but since I don't know what the AddNew is doing it's hard to guess what will happen :) If the AddNew is adding a new, empty row to your DataTable, then I would think it would be fine. Depending on your RowFilter, the new row might not show up if the initial values aren't set that would allow it to be included in the filter. If you don't plan on filtering or sorting, I would bind directly to the DataTable. The DefaultView has a tiny bit of overhead since it's essentially an array into the real DataTable to allow filtering and sorting. -Nerseus
  18. I doubt the program is using DirectX to draw to the screen. Most likely, the form is using a concept called Regions. It's built into windows and allows a form to take on a non-rectangular shape. The shape is up to you but can be semi-standard such as an oval, or follow the shape of a bitmap. Check out regions in the MSDN help for some samples and then search Google for the various Region related function names for sample code. -Ner
  19. A normal is a common graphics term, you can read more on MANY websites on 3D graphics. Basically, there are vertex normals and polygon normals. The kind you're using are polygon normals. Since you're polygons are always simple triangles and they're all facing at very standard angles (all at right angles from each other), you can use a normal that always points in a particular direction (straight up, down, left, right, into the screen or out of the screen). The DX help has some pictures to help explain what a normal is and also contains a lot of info on how DX uses them to calculate lights. -Ner
  20. If by labels you mean you want to draw text and not draw a Label control, you can use the methods of the Graphics object you created. Look at it's methods such as DrawText and DrawImage. -Nerseus
  21. You can't have a Palette with that many colors. A Palette is a specific object with ONLY 256 colors. The 256 color bitmap contains indexes into the Palette. So if the first pixel is 1, it points to the Palette's color 1, not the actual color of 1 (which would be almost black). If you want a 16bpp bitmap that's fine, but you don't need a Palette. You can set each pixel's color to any value you want. You have 16 bits per pixel (5 red, 5 green and 6 blue maybe, if I remember right) to choose from. While an artist might call the selection of colors a "palette", in computers it means something much more specific. -Ner
  22. It sorts the columns? Do you have any special code to do this? If your SELECT lists out the columns in the order you want, the grid should "honor" that SELECT. As long as you have: SELECT first name, surname, address1, address2... and not SELECT address1, address2, address3, address4, first name... you should be Ok. -Nerseus
  23. I know in SQL Server you can't alias a table in the UPDATE clause. But you'll get a different error than what you've said. Otherwise, the query looks fine to me (in SQL Server - never tried a subquery in Access before). -Nerseus
  24. I would *first* use the CommandBuilder. It will set all of the above properties for you. You can then view them (Debug.WriteLine, use the Locals, Autos, or Watch windows, etc.) to see what they look like. I would recommend setting them once (not in a sub, but in a constructor or similar place). They work with a DataSet's changes, of course. So to see it work you'll have to have a DataSet with at least one row modified, added, or deleted. The DataAdapter will call the proper command for each row. Now, if you have MANY inserts, updates or deletes, you may not want to use the DataAdapter. If you have 10 or 20 I wouldn't worry, but if you get many more than that you may want to rethink your code as you will want to either limit the amount of changes at one time or pass XML up to the database to be worked on in one chunk (only available in SQL Server). -Nerseus
  25. I haven't seen any property exposed to do that, no. But, I imagine with a little API help you could locate the window handles for the scrollbars and set their Small/Large change values. I've never tried it, but it might be worth looking into if you really need/want it. -Nerseus
×
×
  • Create New...