Jump to content
  • Advertisement

Splinter of Chaos

  • Content Count

  • Joined

  • Last visited

Community Reputation

239 Neutral

About Splinter of Chaos

  • Rank
    Advanced Member

Personal Information

  1. Splinter of Chaos

    Fixing time step

    What happens if your game freezes for an entire second? Whether or not the animation is correct, the world will have advanced a whole second and the user will be confused about what happened in that time. For simple problems, maybe one doesn't need a fixed time step, but there should at least be a maximum allowable amount of time to pass in one frame.
  2. Splinter of Chaos

    Sockets and networking in c++

    I haven't done much in this domain, but when I was researching this before, I though zmq was the best option. BTW: Sockets are old; maybe try googling for C, not C++.
  3. SDL on mac requires an objective c file to define SDL_main, or something. The one provided by SDL's mac devel package also sets up a rudimentary menu. I want that menu to be extended to modify some configurations that were previously only modifiable through a text file, parsed with c++ code. Maybe i'm just not understanding, but when i google it, i get more results about including objective c in your c++ code than the other way around. Pretty new to obj-c so that might just be the problem. So, for some example code, say i got this: C++:AssociativeContainer c; c["some string"] = "value"; The objective c code needs to call operator[] and set it to a string.
  4. Splinter of Chaos

    screen coordinates w/centered player

    Or more simply: int round( float f ) { return f + 0.5f; }
  5. Splinter of Chaos

    How can i compile an SDL program on Mac?

    It was the Cocoa framework! And the .m file. Thanks! Got it to compile, but not run: dyld: lazy symbol binding failed: Symbol not found: __ZNKSt5ctypeIcE13_M_widen_initEv Referenced from: /Users/hakusa/programming/c++/workspace/orbital-chaos/./run Expected in: /usr/lib/libstdc++.6.dylib dyld: Symbol not found: __ZNKSt5ctypeIcE13_M_widen_initEv Referenced from: /Users/hakusa/programming/c++/workspace/orbital-chaos/./run Expected in: /usr/lib/libstdc++.6.dylib [1] 96821 trace trap ./run/code] Then i modified my code to compile with llvm-g++, but it segfaults when i try and run it. I ran it through gdb and got this: (gdb) run Starting program: /Users/hakusa/programming/c++/workspace/orbital-chaos/run Reading symbols for shared libraries ++++++++++++................................................................................................................................... done dyld: lazy symbol binding failed: Symbol not found: __ZNKSt5ctypeIcE13_M_widen_initEv Referenced from: /Users/.../run Expected in: /usr/lib/libstdc++.6.dylib dyld: Symbol not found: __ZNKSt5ctypeIcE13_M_widen_initEv Referenced from: /Users/.../orbital-chaos/run Expected in: /usr/lib/libstdc++.6.dylib Program received signal SIGTRAP, Trace/breakpoint trap. 0x00007fff5fc0106d in __dyld_dyld_fatal_error ()[/quote] I'm really not sure what to make of that. It looks like the problem is it's looking for a standard function that just isn't there... do i not have something installed properly?
  6. Splinter of Chaos

    How can i compile an SDL program on Mac?

    The command line is actually my method, especially considering how much i invested in my makefile. It seems like i need a .h and .m file to get SDLmain to work, but i don't know how to do that. Thanks for the link, but it's not for Xcode 4 and it seems they've changed a lot of things because all the tutorials i've seen (for more than just SDL) are out of date. Feels like i just chose a bad time to invest in a Mac.
  7. Splinter of Chaos

    Setting up headers and project files

    There's no one way to do it so you'll just have to find what works for you. What i'll do is write everything in main.cpp and when i see that several functions operate on a specific type of data, or do a specific subset of things, i'll move those functions to their own headers and sources. I do the same for classes. For me, it's just easier to write and refactor than write it right the first time.
  8. Splinter of Chaos

    VIDEO: A Second Game Industry Crash?

    I think the commercial industry is no where near crashing. Companies come and go, but we still get huge AAA titles that do nothing for gaming or gamers, but still rake in boat-loads of cash. They stopped taking risks, like Hollywood, and stared making money, like Hollywood. This suggests to me that in a capitalistic art industry, this is what's stable. Even books have done a similar thing. I don't think things will get worse, but if books, movies, and music can tell us where the industry is headed, it won't be getting better either. I think you're absolutely right. Think about it. You're a studio, spending two-five years making a game, 100 million dollars (Rockstar's estimate for Max Pain 3) going into it, and you sell it for 60 bucks so i can take your product home and use it for a few tens of hours. The business model of the game industry is insane and it's mind boggling that it's even possible! Plus, while i believe the comercial aspect of gaming has a tendency to make studios take only safe projects, what enables indies to take risks is the lower investment. Give Notch (Minecraft) 100 million to make a game and i bet you he'd pretty much HAVE to make a generic FPS. Gamers demand this because many only want to play games with distinct AAA qualities--meaning there is no lack of demand. I certainly don't think we need the Hollywood model, but i do think that we need to focus on smaller investments in games that take less money to produce, offer a shorter but more detailed experience. If the indies can do it while living off ramen noodles, you'd think the big cats could do it and be even more efficient at it!
  9. Splinter of Chaos

    How can i compile an SDL program on Mac?

    So, i got this game on Windows and Linux and it requires gcc 4.4 or later for the c++0x features. I got xcode to use a gcc i compiled myself (gcc-fsf-4.6), but xcode immediately responds with an error: "Invalid value 'gcc-fsf-4.6' for GCC_VERSION". Not sure what i can do about that except maybe recompile and manually set its version (somehow). I would really like not to use xcode at all, but i couldn't find ANY help online about how to do that.
  10. Splinter of Chaos

    So like, have any decent new books come out?

    In OpenGL, you don't need to use 4.0 to be up-to-date, and you probably won't be using the newest features if you're new to graphics programming. Check how few graphics cards even support it according to wiki: http://en.wikipedia....enGL#OpenGL_4.0 To write modern OpenGL code, just avoid immediate mode functions. Google VBO or vertex array. Even if you did start with 2.0, the lessons will carry over to 3 and 4.0. Since 2.0 is a lot simpler, it makes sense tutorials use it. You can easily adapt 2.0 code to 3.0 once you know the difference. I suspect DX is a similar story.
  11. Splinter of Chaos

    Make a mathematical vector class already!

    Wow, i'm really surprised this got read at all! I only wrote it to link to whenever i'm in a discussion with someone not using them and it's unfinished and doesn't have a "further reading" section or anything. Thanks for the comments! [quote name='JTippetts' timestamp='1314156068'] The problem I have with vector classes is that everyone has one. I've got projects on my drive that link to three or more libraries that all include their own vector classes. Whose vector class do I use? [/quote] I know what you mean. This bugged me when i used DX and again when i tried Irrlitch. I try to use my own whenever possible because it's more generic than any ive seen before it. Though Japro's looks similar.
  12. Splinter of Chaos

    Storing Game Data in Data File?

    Geese, all i was trying to do was give some background on why the IRC people were upset! But i didn't do it in the right way, so i made my bed and it's time to lie down. I just hope to quench this fire quick so we can stay on-topic and get off this DRM-wannabe discussion. I knew there'd be a little whiplash, but i didn't expect every subsequent post to have something about it. Plus, i haven't had anything to add since my second post, so i'm trying to get out of the discussion, myself. [font="arial, verdana, tahoma, sans-serif"] Data hiding is the political topic. Whether or not one agrees with my opinion. Most people think it isn't because it's the norm. People with GNU influences, especially ones ties to open-source and free software ideologies will feel one way about the issue. [/font] [font="arial, verdana, tahoma, sans-serif"] [/font][font="arial, verdana, tahoma, sans-serif"] I see. I respect adding to the conversation. What made me feel that way was that you started your post by saying my name and didn't write anything on-topic until the end. That and the fact i felt victim to a straw man attack. [/font] [font="arial, verdana, tahoma, sans-serif"] [/font][font="arial, verdana, tahoma, sans-serif"]I'm really sorry to hear that! You should have at least said i offended you, but perhaps it seemed deliberate. You don't have to "rag" on someone to let them know they hurt you. I understood originally that it was the IRC people who said nazi; i was trying to make a comment on them in sympathy. The real crux of my argument was really just the last part, which seemed to have been ignored:[/font][color="#1C2837"]"And don't think that by hiding those files, you don't have to worry about copyright. You have do it either way, you're protected either way, why bother? " All i was really trying to say is that you need to worry about copyright no matter what. Someone could stream the audio out of your game using a legal and free program and then use it in their game. Or a hacker could decrypt your file. You can make it harder on the hacker, but if it's worth to do, they will. Even EA cannot thwart hackers. I'm gonna stop watching this discussion and won't dare start any more fires here. Re-reading my second post, the language really was pretty harsh and it really didn't help me state my opinion peacefully. Sorry for upsetting you, Computercodemonkey, and for derailing the discussion, and for not having had much useful to say on it.
  13. Splinter of Chaos

    Storing Game Data in Data File?

    That's not what i said at all. I said it that the OP was using the same form of reasoning: I don't want people doing X, so i'll doing something that inadvertently prevents Y and Z. I was merely explaining why i thought it was reasonable that people on the IRC, and possibly others, would be disturbed by the OP's choice. I was not equating the OP and EA, but was relating them. If i came out harsh on the OP, that wasn't my intent and i apologize, but s/he didn't seem offended. I disagree strongly with the statement you made that anything installed on a user's computer becomes their property and they can do whatever they want with it.[/quote] You don't have to agree. Besides, i was speaking little of the fact it's installed and more of how the art assets and stuff are actually on the harddrive, and the user should have access, like how hackers certainly will. It being installed is irrelevant. But there's no reason for you to agree, It's just an opinion. When it comes down to it, the law isn't on your side when it comes to taking other people's work without just compensation.[/quote] I never said anything to the contrary! I said that there are perfectly legal and legitimate uses of the assets that don't imply stealing someone else's works (in much different words). For example, what if i wanted to make a picture in the game my desktop background? Does that infringe on the developer's ability to make money? *sigh* I knew i'd have to make a post like this if i said that shit... That post was so directed at me that i wonder why you didn't just PM your list of complaints.
  14. I can't count the number of times i've gone on to a forum and seen code like this: (Using a modified example from gafferongames.com) posX = posX + velX * dt; posY = posY + velY * dt; velX = velX + (forceX/mass) * dt; velY = velY + (forceY/mass) * dt; I'm going to use this space to explain why such code is bad, especially in more complicated examples, and how simple it is to make it better. First, i think it would be clearest if i simply showed how this looks if posX and posY are represented by a vector, pos, and do they same for vel and force. pos = pos + vel * dt; vel = vel + (force/mass) * dt; Obviously, this is simpler, cleaner, and more readable. [subheading]Why this code is bad.[/subheading] You have to write twice as many lines of code than necessary, for 2D, and three times for 3D. Even using vectors, a complex physics equation, for example, might take 5 lines, which means 15 lines using 3D math without vectors. You have to make redundantly names variables (posX, posY; redundancy highlighted). It's harder for people to read your code, and for you to maintain it since the lines have to do the exact same thing. Vectors basically take multidimensional equations and lets you evaluate them on one dimension. [subheading]What is a vector?[/subheading] A vector is simply a piece of data representing both a direction and magnitude (or length). The most obvious way to represent that is through a polar vector. While out of the scope of this log, a polar vector is one around a pole, simple enough, with a distance from the center and an angle from an arbitrary axis. A vector used more often in games is simply represented by an (using a 2D example) x and y like so: . We can find the magnitude with sqrt( x*x + y*y ) (Pythagorean Theorem) and the direction from the x-axis by using atan2( y, x ). Even though it contains neither a magnitude or direction, directly, we can derive those values from x and y and thus they make a vector. For an example of a vector: say you had a screen object at (1,1). That's the position vector, s, . If next from you want it to move one unit left, that means its velocity vector, v, is , 1 for one unit left and 0 for no movement in the y direction. s + v = the position next frame. s + v = + = = . If a = and b = , a + b = , [subheading]Vectors are incredibly easy to write! (Without a lot of knowledge about math.)[/subheading] The simplest vector implementation, in c++, is this: struct Vector { float x, y; }; With this, posX and posY become pos, but would not make the above example any prettier. What it does do is simplifies writing a class. One with a position and velocity should have two members (pos, vel), not four (posX, posY, velX, velY). To really see any gains, we need to start adding functions that do common calculations on vectors. For example, adding to vectors: Vector add( Vector a, Vector b ) { return { a.x + b.x, a.y + b.y }; } // ... Vector velDt = { vel.x * dt, vel.y * dt }; pos = add( pos, velDt ); Although the intent of this code is not quite as clear as a simple "pos = pos + vel*dt", it still looks better than seeing two lines of "x = x + velX*dt". Many languages do not allow what's called operator overloading, but c++ does and we can simplify the code further by adding two functions: Vector operator + ( Vector a, Vector b ) { return { a.x + b.x, a.y + b.y }; } Vector operator * ( Vector a, float b ) { return { a.x * b, a.y * b }; } // ... pos = pos + vel * dt; [subheading]Useful Functions[/subheading] Aside the already mentioned ones, you should be equipped with at least a dot and cross product, a function to find a vector's length. When you begin to look up vector equations, these functions will come up a lot. To learn their meanings and uses is outside the scope of this, but: A dot product is the sum of two vectors with their like components multiplied and returns a scaler (non-vector) value: * = a*x + b*y. A cross product is used to find a vector tangent to both a and b. //Using a 3D Vector class: int operator * ( Vector a, Vector b ) { return a.x*b.x + a.y*b.y + a.z*b.z; } // Crosses only make sense with 3D vectors. Vector cross( Vector a, Vector b ) { Vector c; c.x = a.y*b.z - a.z*b.y; c.y = a.z*b.x - a.x*b.z; c.z = a.x*b.y - a.y*b.x; return c; } // The square of a vector, v*v, is the dot product of itself. Vector square( Vector v ) { return v * v; } // This can also be named "length" or "size". Vector magnitude( Vector v ) { // Pythorous' theorem states the answer is sqrt( v.x*v.x + v.y*v.y + v.z*v.z ). // Notice that v*v = v.x*v.x + v.y*v.y ... so the above is equal to sqrt( v*v ). return std::sqrt( v*v ); } // Another name for sqrt(v*v). Often written ||v||. // Note that |-5| = sqrt((-5)*(-5)) = sqrt(25) = 5. Vector abs( Vector v ) { return magnitude( v ); } [subheading]Going Further[/subheading] A vector class can be built to hold ints or floats, but sometimes one is more convenient than another for different situations. That means either you can write a vector for each type or make it templated. You might want a 2D vector for a 2D game, or a 3D vector for a 3D game. Again, you can make a different class for both, but doing that and one for int and float means four classes! Of course, for most situations, you only need a 3D class and just set z to zero if you're making a 2D game, but what if you wanted to make a 4D vector, the fourth dimension perhaps being time? So, if you really need a robust vector class it needs to be templated by size, and type is convenient. template< int Size, typedef T > struct Vector { // Provide typedefs to be able to reference the types this class uses, externally. typedef T value_type; // Do the same for the size. // static_size is barrowed from std::array. enum { static_size = Size } // Since the number of dimensions are variable, we must hold an array instead of individual members. value_type dims[ static_size ]; // Overload [] so that dims can be accessed more conveniently. T& operator [] ( int i ) { return *(data + i); } const T& operator [] ( int i ) const { return *(data + i); } }; Now, defining the operators on this class can be a little difficult. At times, i've written the operators as normal, templated, free function, but depending on the calling code, thanks to standard C++ function lookup rules, you'll get a weird error. Take this example, using the above class. template< class T, int X > Vector operator * ( Vector v, T a ) { Vector vec = v; for( int i=0; i < X; i++ ) vec *= a; } int main() { Vector v; v[0] = 1; v[1] = 1; Vector x = v * 5.4; } The error received on g++, version 4.2, is "error: no match for 'operator*' in 'v * 5.4000...0625e+0'". It doesn't know to convert 5.4 to an int to match the function signature. When a conversion is required, neither the left nor right operator takes precedence. We can see that the float should be converted to a float, but the compiler doesn't know it shouldn't convert the vector to a Vector! We could rewrite it to let the second argument be a different type, but we don't want that. In the + operation, a conversion has to take place whether vec needs conversion to a float, then to be converted back to an int for storage, or a has to convert to an int. It just makes sense that the conversion should happen when the function calls. I wish i could give a link that explains this problem better, or that explains why the solution i'm about to give works, but i don't. What needs to happen is the operator needs to be defined outside the class, but as a friend of it, defined inline. Again, this has to do with lookup rules. The class must be defined like this: template< class T, int X > struct Vector { T data[X]; T* begin() { return data; } T* end() { return data+X; } T& operator [] ( int i ) { return *(data + i); } const T& operator [] ( int i ) const { return *(data + i); } template< class T, int X > friend Vector operator * ( Vector v, T a ) { Vector vec = v; for( int i=0; i < X; i++ ) vec *= a; } // More operators... }; This is how i wrote my own class for my game. The code can be found at https://github.com/splinterofchaos/Orthello/blob/master/Vector.h
  15. Splinter of Chaos

    Storing Game Data in Data File?

    You don't need a System Development Kit to open a zip file. http://www.google.co...250l493l2-2l2l0 That's not the library, but the first link is an example using SDL and zlib. Not being my specialty or interest, i don't know about encryption or opening a password protected zip. On the other hand, the program 7-zip is open source and you could try and figure out how they do it. [font="arial, verdana, tahoma, sans-serif"] [/font]You might not realize it, but that's a political statement. Users have rights too (my political statement). Whatever you payed your artist, Lady Ga Ga's label payed a lot more, but that wouldn't stop me from using an mp3 of hers (for comedic affect, i assure you!) in a free non-profit project that only a few people would see. The logic you're using is the same that DRM-big cats use all the time: that one use of our product that we don't want is bad so all legitimate uses should be disabled as well. With EA, it's making backup copies, which is perfectly legal, but they fear you might distribute them. You're so concerned that someone might use what you payed for in other games for free that you're entirely ignoring millions of other legitimate and legal uses that users have a right to! The law enforces EA's right to prevent people from making copies of their games by letting them use invasive and destructive software. The law does not enforce the rights of users. Users get very upset when their rights are violated. I'm only giving you this long winded rant so you understand why people are (very rightly so) disturbed. Not to change your opinion. As for protecting the files from being used in other works: It's called copyright, or preferably creative commons, a more flexible copyright. There's nothing wrong with letting people use those files for personal use. You have to make it legally clear that they can't be used any other way. Even AAA titles like Oblivion and Fallout don't go through any measures to thwart users from copying the art files, but i bet you'd get in trouble if you used their resources in your commercial game. And don't think that by hiding those files, you don't have to worry about copyright. You have do it either way, you're protected either way, why bother? (Note: i'm not a good person to take legal advice from. This is more a topic for the business section of the forums.)
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!