Jump to content
Xtreme .Net Talk

Nerseus

*Experts*
  • Posts

    2607
  • Joined

  • Last visited

Everything posted by Nerseus

  1. Thnaks? Sounds like a yummy snack :) The DefaultView is a built-in DataView. That means you can bind to a DataView and later add a RowFilter or a Sort without rebinding. Binding to a DataTable means always showing all records, unsorted (unless you sort in the DB or your control allows it's own sorting) and unfiltered. -Nerseus
  2. Optimization is great, but readability counts for a lot! I'm not sure how you're deciding what buttons to enable/disable, but you might want to consider using an enum for the buttons. An enum can be specified with a [Flags] attribute which is ideal for things like this. Here's some sample code with a new version of your abilita function: [Flags] public enum ToolbarEnum { NoButton = 0, Button1 = 1, Button2 = 2, Button3 = 4, Button4 = 8, Button5 = 16, Button6 = 32 } public void abilita(ToolbarEnum enabledButtons) { long mint = (long)enabledButtons; for (int i = 0; i < toolbarMain.Buttons.Count; i++) toolbarMain.Buttons[i].Enabled = (mint & (1 << i)) != 0; } // Here's how you would call the new function // to enable buttons 1, 2 and 5: abilita(ToolbarEnum.Button1 | ToolbarEnum.Button2 | ToolbarEnum.Button5); -Nerseus
  3. Have you tried Application.Exit()? It will completely end your application. If this is a game with a DoEvents in a loop, you should provide a cleaner solution. Meaning, when the user chooses to exit, set a variable, maybe bExit, to True. Exit your main loop if the variable is true. -Nerseus
  4. A similar function that would be nice is to have the "Submit Reply" button take you back to the forum you were just on, instead of the bottom of the thread you posted to. I generally hit "Preview Reply" and it's a small pain to have to wait to see the thread I just saw and then click and reload the forum link(and network traffic, too!). It could save you a nickel (a nickel, a nickel?, a nickel?)... -Nerseus
  5. I would seriously start coding the first game first (stop spending 2 hours a day posting and code instead!) :) I'd go with whatever seems simple enough - Tetris is a good start. You'll be surprised just how much code goes into a "simple" game, if done right. By "right" I mean more than just the game immediately starting and playing. I mean menus, pause mode, saving high scores, etc. It doesn't have to have ALL of that but... keep in mind that a more advanced game WILL, and learning how to pause a game, show a menu, etc. will be easier to work out now in a simple game. -nerseus
  6. I'd suggestion making it a user option. If you don't want that trouble, use Wait. I've never heard of DoNotWait crashing a program but it might cause "tearing". In a 2D game that will look especially bad. It means drawing may occur during a screen retrace, which means the top half of the screen (or some portion, maybe not exactly half) will be slightly ahead of or behind the bottom half. Sometimes it's only a few pixels, sometimes 8, 16, 32 or more! Even a few pixels in 3D games can look quite noticable especially during laggy portions (where the time between frames is greater, the tearing will be worse). -Ner
  7. This is a guess, but it looks like all of your normals are... well, weird. :) Normally a normal is a unit vector (dot product is 1). You've got some normals defined as (-5, 0, 0) which is odd. Since the only geometry I see is a cube (12 triangles), your normals are very likely to be either (1, 0, 0) or (0, 1, 0) or (0, 0, 1). Other normals (something like (0.2, 0.4, 0.1)) are generally created by a 3d Drawing program. When the normal is off, the lighting calculations built into Direct3D behave oddly, including making things too dark or too light or just not having the light blend across a surface quite right (compared to what's expected - the math is working right). I noticed that in loadGeometry, you also define 3 vectors: v0, v1, v2, and v3. They're used in calls to PositionNormalTextured as both the position AND normal vector. I think you'll probably want only one vector for the normal. The position vector can change according to the position you need (I didn't check your code for accuracy on position though the cube does draw). -Nerseus
  8. You can't use the Format16bpp... format for a palette. The only bitmaps that use a palette (that I know of) are 8 bit indexed. If you change that to Format8bppIndexed instead of Format16bppRgb565 you'll have a palette. Two other notes. 1. I'm not sure why you need 269 ColorPalette objects. You only need one for the code you have. You're not defining the number of colors in the palette - that's built into the ColorPalette object itself. You're actually defining 269 objects. 2. It's perfectly fine to assign a variable NewPalette (or NewPalette[0] like you are) to TMPbmp.Palette. But it's just another reference to the same object (a ColorPalette is a class, not a struct). You get code readability only. You don't need to use: TMPbmp.Palette = NewPalette[0] to get the palette updated. You're always referencing the same palette whether you use TMPbmp.Palette.Entries... or NewPalette[0].Entries... -nerseus
  9. Yes, you'll get the same error when using smallint. It's a pain, but if you REALLY want to use the smaller column size, you'll have to convert manually. Use something like: Dim wag As SqlTypes.SqlMoney = System.Convert.ToInt32(DR.GetSqlMoney("Wages")) Or, convince your client/boss that smallmoney isn't going to save you but 4 bytes per row. At 1 million rows that's 4 mil bytes - 4 meg of hard drive.... not worth it if you ask me. We convinced our clients that smallint wasn't worth it using the same calculation (more or less). -Nerseus
  10. The only reason you would need a 3rd table is to support a many-to-many relationship. First, is that what you need? If so, proceed. If not, skip this and redesign your data structure :) For a many to many in a DataSet, you're going to have to cheat a little. If you really want a DataView, I'd suggest adding a column to one of the tables. It should be an expression column with the Foreign Key from the 3rd table. You can use the Child or Parent "function" in the expression (look at the help) to essentially pull out a value from a table and have it appear as a column in the parent or child table. Once you have that column, you can simple filter as normal. If the point is merely to filter Chairs by a particular table or vice versa and fill a combo or listbox, you can always loop and add items manually to a control. If you need binding, you'll have to use the first method. There is a 3rd alternative (maybe more - this is all I can think of right now) - use a new class called JoinView that essentially works like a View from SQL Server. It's similar to the first option on you don't add a new column to the DataSet, you define a JoinView (like a DataView) to have the other column. The only problem is the JoinView class is only provided as-is via source from Microsoft, and only in VB.NET. I ported it to C# but I can't share it (I had to bill a client for the time spent). I can say it took about 3 or 4 hours doing it by hand but it works fantastically well. Good luck! -nerseus
  11. I'd really have to see some code and current structure to give any meaningful advice. As a very vague rule, pick classes for one semester first. If you have any classes that can't be combined, save them in a hashtable or as a new row in your table or some other way. Or, build your class list for the next semester and exclude any classes you already have (from the first semester). If your structure is built right, this shouldn't even be a question. Meaning, the data should naturally support a way to build up a class list. If it doesn't, then you need to look at how you're storing class and other information to help you code your application. It's perfectly fine to add fields to a table to help with coding - that could be making a schedule work easier, make a join easier, make a search/report easier, etc. -Nerseus
  12. If the search string is: Bob's Diner OR '; DELETE TABLE Table1 -- You might run into problems... Make sure you double up your single quotes or you will get unexpected results and maybe worse. Use something like: dtvwCourses.RowFilter = "course_code LIKE '*" + search_str.Replace("'", "''") + "*' OR course_name LIKE '*" + search_str.Replace("'", "''") + "*'"; Of course, I should mention that the above code (your original search) is extremely inefficient. Normally having one search that uses * on both sides is bad, but to have two of them with an OR is just... so slow. If you get any more than a few hundred records you'll be having to change some code I'd imagine. -nerseus
  13. Personally, I don't have the time. But, if you'd like - feel free to upload the source for it and see if anyone takes a look. You'll probably get more takers than asking for someone to ask YOU for the program. -nerseus PS Remember - no binaries! That includes DLLs, EXEs, etc. :)
  14. I can try this tomorrow but I wonder... have you tried using a stand-alone manifest file to see if it behaves the same as if you embed the file? If you need a copy of a simple manifest file let me know - I can send you one tomorrow. -nerseus
  15. If you're asking why the testfunction, which assigns test3 to test2 also increments the private variable i inside of class2, it's because the contents of a class are not copied even when a function is declared as by val (meaning you did NOT use ref or out). To have testfunction work on a copy of the test class passed in, you'd have to perform a shallow copy and work with that. You could also define the testclass Class to be a struct. The contents of a struct is passed by value so incrementing a member variable would affect the copy, not the original. Otherwise, things are working as expected - at least they are to me. It's a matter of realizing what's working so you know what to expect then coding with that knowledge in mind. -Nerseus
  16. Very nice. My favorite feature - Size (I like 200% - I'm old). -nerseus
  17. There is no way to turn off case-sensitivity in C#. To automatically correct (or mostly automatically), you can press Ctrl-Space anywhere on your variable. If it finds only one match, it will case it for you. If it finds more than one, it will give you a list of matches. It's also useful for completing a long variable or function name (in VB and C#). For instance, if you have a function named MySuperGroovyFunctionName, you can type "mysu" and then press Ctrl-Space to complete it for you. Note that you don't have to type the first part in the right case (MySu), you can leave it all lower if you want. If Ctrl-Space is too awkward, change it through the Tools-Options-Keyboard settings. As for the original question, I change my answer. I choose C# as the best game programming language. Keep in mind I'm hugely biased since it's what I know and why would I choose a language I don't know enough about? And you think I trust the C/C++ programmers that there's is faster? Then you have to debate with the ASM programmers (who type a because it's shorter). -nerseus
  18. If you keep in mind what's going on, you'll know what to expect. Reference the image below. The list of blocks at the top represent the memory occupied by the Bitmap object. Keep in mind that this is a class not a struct. The variable test is a separate piece of memory that points to the Bitmap object. Since you defined the parameter b in the function without the "ref" keyword, the parameter will be passed by val. That means that the memory occupied by the variable is copied and sent to the subroutine. If you look at the top portion, you'll see that I've shown "b" as a separate memory chunk that points to the same underlying data. That means when you assign b to a new Bitmap, you're only repointing that variable b's memory to a new chunk of memory (similar to the bottom portion of the picture). If you changed that declaration to use "ref b" instead, then what you would be sending into the subroutine is NOT a copy of the pointer, but the actual pointer "test". That means modifying b would be modifying test, which would mean losing your old bitmap. In either case, if you were to change the contents of the Bitmap (using b), such as creating a Graphics object and doing some drawing, you would affect the picture. It may appear that you've copied by reference, but it wouldn't really be true. Now for structs. Structs work just like basic datatypes (Date, String, Int, etc.) in that they are truly copied by value. In the bottom portion of the picture I've drawn what happens when you pass a struct to a function. Instead of copying the pointer (but the pointer still points to the same memory as the original variable), the entire chunk of data is copied. This means modifying b's data will not modify test's data. In the example above for class's, if you modify the value of a field in a struct using b.FieldA = new value, it will NOT affect the value in the variable test. A final note on struct's memory. Technically, the bottom of the picture isn't accurate as there really isn't a separate chunk of memory that points to a struct. The variable really represents the place in memory where the struct's data begins, rather than using a pointer to the real chunk of data as with a class. So yes, even in C# and VB it helps to know about pointers and memory (at least as far as understanding what's going on when you declare and use objects). -nerseus
  19. I didn't know if that's an option that could just be turned on (versus custom code). I've seen it on ezboard and really liked it. Any idea if it's a feature of version 3? -Nerseus
  20. . I'd disagree - as Jon pointed out, you may not think that you're learning anything related to the real world, but you are. You only get out what you put in, as was made so clear in Karate Kid. Wax on, wax off - why learn THIS when I want to learn THAT? Hopefully if you're really learning, it will all become clear when you do get to the "real world". [ Soapbox ] Or to not use a 20 year old movie as a reference... Some may say I learned Modula 2 and Pascal in college (for the most part). But looking back, I may have learned the language but only as a tool to learn programming. The Ifs, Whiles, variables, and structures are the building blocks to programming. Also, all the other classes in a university contribute to your understanding of topics you might otherwise dismiss as extraneous. Why take Biology if you're never going to care about a Tibula or Fibula? Well, besides making you bit smarter about general knowledge which some might question the benefit of, you probably learned how to memorize better, take notes, and more. And you probably met some people in class you might not otherwise have met. Everything in life contributes to who you are... don't dismiss anything as extraneous. [/ Soapbox ] -nerseus (again)
  21. It halts on the line: lRet = mciSendString("open sequencer!" & MidiFile & " alias midi", "", 0, 0) Maybe the file isn't found (though it's in the bin folder)...? -Nerseus
  22. Since no moderators would probably be watching a "Reporting" or "Crystal Reports" forum, why not make it a "Non-Moderated" forum and the game programming questions can get jammed in there. Two birds with one stone! :p Nerseus: Function: noun Etymology: Middle English, from Late Latin muchos humorous
  23. It didn't work for me (problems playing the MIDI file), but after I commented it out, it worked just fine. I wouldn't worry about using DirectX at this point. The code is very small though, so converting yourself should be quite easy AND if you really want to use DirectX you'll have to get your hands wet sometime. Why not now? Check out DirectX4VB.com for samples in DirectX9. Plus there are a number of attachments on this board as well. -Nerseus
  24. As far as I know, you can't load that PAL into any .NET datastructure directly (though I've never looked). Normally, those files are very simple in structure - nothing but Red, Green, and Blue values one after another. You can read the whole file into a byte array, loop through and set your bitmaps palette manually. Just a suggestion if you can't find anything else. -Ner
  25. It sounds like you'd be happiest going to DigiPen, even if it means the tough road of getting through calc and differential equations and such... but only you know for sure. -Nerseus
×
×
  • Create New...