• Advertisement

antiHUMANDesigns

Member
  • Content count

    60
  • Joined

  • Last visited

Everything posted by antiHUMANDesigns

  1. ? about arrays

    You can access the elements of an array is a second way aswell. [source lang="cpp"]int array[10]; // create the array int *p = array; // create a pointer of the same type and assign it to the start of the array.[/source] Now, using pointer arithmetics, you can access the elements by adding a number to the pointer, such as "p+1", which is the same thing as array[1]. "p" by itself would be the same thing as array[0]. This actually what arrays do, but I think the compiler keeps a note on how many elements the array was created with, to help you with not going out of bounds. Also, you need to "delete" arrays that have been created with "new" by typing "delete[]". Pointer ariothmetics is not just an alternative way of traversing an array, but is something more or less needed, so it's good to know it. I'm a bit rusty on programming atm, so don't bash me too hard if I wrote something stupid or made some silly mistake. EDIT: oh, and using an array normally (array[0]) dereferences automatically, but if you use "p", it's not dereferenced, so you need to write "*p" to get the actual value of the element, instead of the address to it. Just wanted to point that out, even if I felt it was obvious.
  2. total noob here. Can you recommend a c++ compiler?

    [quote name='zacaj' timestamp='1340576162' post='4952457'] This is known as an IDE. A compiler just takes the name of a file and makes an exe, it doesnt include an editor. For Windows the best IDEs are Visual Studio (which is made by Microsoft), Code::Blocks, and Eclipse. I don't know about eclipse but I know Visual Studio and Code::Blocks include a compiler with them. Id recommend you download Visual Studio 2010 Express edition to start. Alternately, there are lots of text editors that you can code in, such as Notepad++ which you can also configure to run a compiler, or even just open a command prompt to run the compiler from [/quote] Dev-C++ is at least as good as Code::Blocks, I would say. Definitely better than Eclipse in my opinion. So ye, I recommend Dev-C++ if you, like me, think Visual Studio feels too cumbersome.
  3. Textured meshes don't look as they should?

    I know why! Because when maya repeats textures, it only works in maya. To repeat textures, you should change the actual UV layout. Maya does something internally which is not exported. That is, assuming you're repeating using the attributes in the window/sidebar to the right. If you repeat the texture in the UV editor, by scaling your UV's up, it'll work, assuming there's nothing else wrong.
  4. Best 3d modelling software for beginners?

    There used to be a great little program called "Nendo", which I started with some 10 years ago. Not sure it even exists anymore, but it sure was lovely to work with. It really felt like sculpting, for some reason.
  5. Newbie

    [quote name='SimonForsman' timestamp='1340562608' post='4952386'] [quote name='Mitsos175' timestamp='1340559334' post='4952377'] In every search that i do everybody says that's is not important to know C in order to learn C++. [/quote] Its not, they're different languages, knowing one of them makes learning the other easier since they are related but learning one in order to learn the other is counterproductive. [/quote] When looking at books and stuff, they often say you don't need to know C to learn C++, and I think that's the kind of thing he, or they, meant, because they're all-inclusive (EDIT: I mean, the book teaches everything without need for prior knowledge) . But the difference between C and C++ really is pretty small (compare C to QBasic and the difference is bigger), so if you learn C++, you know a lot (if not most) of C, for example. If you already know C, then moving to C++ is only a little more than an adjustment. (Not trying to understate the difference, because there sure is a difference, but the difference is small for beginners, I think we can agree.) So, yes it is counter-productive to learn C before you learn C++, if you think about it, but it's not useless to do so. I don't see a reson to downvote what Simon said, because technically he's right.
  6. Newbie

    [quote name='Mitsos175' timestamp='1340559334' post='4952377'] I know a little bit php but a little. So in that case what you tell me to do? In every search that i do everybody says that's is not important to know C in order to learn C++. [/quote] PHP looks a lot like C, which helps. Advanced PHP even has classes and such, like C++. But still, PHP is a scripting language, and C++ is not. Just a little bit of PHP might not help you very much in C++, but at least it helps you understand how programming languages work, which mean you're past the first step. Hey, just give it a try? If you look at a few starter tutorials and think "WTF are they saying?", then... well, play around more with PHP, maybe, I don't actually know.
  7. Newbie

    [quote name='Mitsos175' timestamp='1340558177' post='4952371'] So it's a good of start and study c++? [/quote] If you have no experience at all... nah? I'd love to say yes, but only if you can handle it. If you know a little of some Basic-style language, or even C or PHP, then yes, you should be fine with starting C++. But from nothing, it'll probably overwhelm you.
  8. Few questions - collision detection

    meh? This wasn't supposed to be a new post, just an Edit. 8|
  9. Please simplify my code.

    [quote name='Cornstalks' timestamp='1340555145' post='4952360'] [quote name='antiHUMANDesigns' timestamp='1340554577' post='4952357'] *snip* [/quote] Templates may not be perfect, but if you don't see their value, you haven't been using C++. [font=courier new,courier,monospace]std::string[/font] works because of templates, [font=courier new,courier,monospace]std::cout/cin[/font] work because of templates, <algorithm> works because of templates, [font=courier new,courier,monospace]std::vector[/font] works because of templates, etc. In your own code, templates can help a ton too (for making a generic resource cache, for example, or making a vector (mathematical vector, that is) or matrix library, rather than duplicating the code, increasing the amount of work it is to maintain everything). [quote name='antiHUMANDesigns' timestamp='1340554957' post='4952359'] But if you do'nt use classes, I don't think it's C++ code either. [img]http://public.gamedev.net//public/style_emoticons/default/tongue.png[/img] [/quote] There is so much wrong with that statement I'm not even going to try to correct it... But we're getting side tracked now, and I think some of these discussions would be better in a new thread. Let's not hijack the OP's thread. [/quote] I obviously use std::string from time to time. If I don't see their value, that doesn't mean I'm not using C++. I don't understand your logic here. My personal disposition towards certain bits of code has no impact on what language I am writing in. None whatsoever. It's like saying I don't drive a car just because I chose to never use the cigarette lighter, which is a part of the car. But let me repeat it to make it clear: I do use std::string sometimes. I'm not bothered by it. Can we start scrutinizing your preferences now? This is starting to feel like a witch hunt. Really. EDIT: OH, btw, when I say "...then I don't think it's C++ code either", then that is obviously an opinion, seeing as I used the word "think". Now, I see why you don't want to try to "correct" my opinion. Thank you for that.
  10. Please simplify my code.

    [quote name='Cornstalks' timestamp='1340554126' post='4952355'] For the love of all things holy, people, please trim the quotes! [quote name='antiHUMANDesigns' timestamp='1340549821' post='4952326'] Oh, you're right, I'm known to suffer from over-engineering complex. Might be my asperger acting up. But I'm sorry, I just can't agree that using OOP ever makes for bad C++, even in small applications. We might have different viewpoints on this, and I think neither of us would go as far as to shout "Truth!™". Properly formatted and divided into separate files, even small programs look and feel so much better to work with in OOP. And I still think it makes them easier to update and whatnot. But in this very thread, to me it's about advocating abstraction. [/quote] It's not that you just over-engineered stuff. It's that it's not very good code. You wrote an empty constructor (why?), you used a C header (<time.h> (the C++ version is <ctime>)), you're using C-style casts (instead of C++ style casts), you're not including the header to use [font=courier new,courier,monospace]s/rand()[/font], you're using the [font=courier new,courier,monospace]s/rand()[/font] from C (and not the [font=courier new,courier,monospace]s/rand()[/font] from C++), etc. You're being hypocritical of the "you're using C, not C++." And as rip-off showed, you're using OOP wrong. There is [b]no[/b] need for SlotMachine to be a class (it's got [i]one[/i] function, and no member variables). There's no need for the Application class either, as idiomatic C++ wouldn't be using classes like that. If you want evidence that not everything needs to be in a class, take a look at the <algorithm> header. Some programming languages have done the disservice of teaching people that Everything Is An Object And Belongs In A Class, which is so far from true it's not even funny. OOP is great, but it's unfortunate that it's so misunderstood, and teaching a beginner to over engineer isn't doing him/her any favors. For what it's worth, I commend you for trying to help. The reason I'm being a bit harsher than normal though is because you're being quite stubborn and this is in For Beginners, where details matter. And for the record, you can do OOP in C. It's not just a C++ thing. C++ never meant for everything to be wrapped up in a class, and it intended for free standing functions to be used in addition to its other features that complement OOP. [/quote] Ah, man, I tried to re-write the OP's code as quickly as possible, and I made the constructor thinking I would put something there, and ended up not doing so, but leaving it like that. I didn't know it would come under scrutiny. Most people just write small snippets of code (or even pseudo-code) to show something, but I undertook to re-write it all as an example for a beginner, but it ended up being scrutinized by professionals instead. Had I known... <time.h> instead of <ctime>, once again an honest mistake from trying to rush it. Doesn't change the point I was trying to make, though. If you look back, it's about the C++ way of thinking, not which libraries you use. I disagree that SlotMachine shouldn't be a class. This is a quick prototype, or a first-version of the "game". If I wanted to add things to the slot machine, having it as a class already is a good thing. You might not like it, but to be completely frank and brutally literal, I don't give a shit, because it wasn't written for your enjoyment. It's C++, it compiles without errors, I like it, it allows for further development nicely... I'm happy with it. In OOP, the slot machine is an object. I stand by that. I don't see how it matters what the class contains. The slot machine is an object, and when I pull it's lever, that's a method for that object (or, member function). Making it a function is not OOP, making it a variable won't work, so what would you make it? I chose to make it a class, and until until you can change my mind as to why it shouldn't be (performance is not an issue in this application, for example), I stand firm. And I don't put everything in a class either. In my own projects, I have "lose" functions for getting random floating point values, for example. I never said everything needs to be a class, but I do claim that some things should be classes, because it makes logical sense if you consider how they are being handled. I can probably find some way to make a getRandomFloat() function to become an object, by looking at it like a pseudo-random number generator, but I don't see how I would make an actual slot machine into a function or a variable, and not feel silly about it.
  11. Please simplify my code.

    [quote name='andrew111' timestamp='1340553247' post='4952348'] [quote name='antiHUMANDesigns' timestamp='1340547802' post='4952317'] Don't you agree that C++ without OOP could just be C instead? Most of the improvements in C++ are related to abstraction. If you chose to ignore those, you might as well go with C? Do note that I'm trying to teach a beginner the difference between C and C++. I dont have any other agenda here. But don't get me wrong, I never meant to claim that you can't write C++ procedurally. I agree that it will compile, but I'm also quite sure that the only reason it will still compile is because C++ never got a chance to get free of C. Stroustrup himself says that C is obsolete, and that he wants C++ to be free of it. [/quote] I'm not sure if you've programmed in c, I've used it a bit for writing libraries, and the main problems I have with it, are things that c++ has introduced shortcuts for, and of course its painfully lacking of the standard template library (So you have to implement your own lists, hashmaps etc). So not defining classes isn't really equivalent to c code. [quote name='antiHUMANDesigns' timestamp='1340550633' post='4952331'] And mixing procedural and OOP is the same application simply feels right-off stupid to me. I see no defense for it. (OR, more correcly: I see no defense for ME to do that.) [/quote] I know the feeling, I dislike mixing functional code with imperative code, but I think procedural and oop can fit together fine. I know the feeling of over obsessing with oop from when I first started programming. If you want to see programming from another perspective, to see why oop isn't so important, you should look at a functional language like scheme ([url="http://racket-lang.org/"]racket[/url] is a good implementation) or [url="http://www.haskell.org/haskellwiki/Introduction"]haskell[/url]. Also if you're interested in alternate oop systems, look at [url="http://www.gigamonkeys.com/book/object-reorientation-classes.html"]clos[/url] (common lisp object system), I think it's a vast improvement over the c++/java/c# oop system. Knowing some of these things, I believe will help you put things in a better perspective. [/quote] No, I agree it's not equivalent to C code just because you don't use classes. But if you do'nt use classes, I don't think it's C++ code either. It feels more like some kind of mix...which I don't enjoy. As for procedural and OOP... you know, the term "procedural" is something I probably end up using widely and wrongly. I lack formal education and I may get the terminology wrong. I've always programmed alone, for about 19 years, so I've never needed to express these things in words, to others. I do my best to express myself, but it obviously comes out wrong at times.
  12. Please simplify my code.

    [quote name='Matt-D' timestamp='1340551753' post='4952340'] [quote name='antiHUMANDesigns' timestamp='1340550633' post='4952331'] [quote name='Matt-D' timestamp='1340549177' post='4952323'] {...} (tryign to cut down on the reply history here) [/quote] OK, see, from everything I've read, 99% of people have nothing but bad things to say about templates, and I chose not to use them myself. (Though by doing so it also means I'm not good at them either.) And I'm not exaggerating when I say 99%. I can't recall one single person, besides you, who has said anything good about templates. I just made personal choice not to use them, but I admit that I no longer remember straigh off-hand why that is. And don't get me wrong, I write things procedurally at times aswell. I just don't think it'd be a good thing to teach people to do things the easy way. Maybe I'm at fault, I'm not a licensed teacher. And, perhaps due to my aspergers, I do surely over-engineer things, because I want everything to make sense. And mixing procedural and OOP is the same application simply feels right-off stupid to me. I see no defense for it. (OR, more correcly: I see no defense for ME to do that.) [/quote] Well, I prefer to look at quality over quantity. If templates are good for Abrahams, Alexandrescu, Gurtovoy, Meyers, Stepanov, Stroustrup, and Sutter, they're good enough for me :-) // So, now you'll be hopefully able to recall a few more people besides me who said something good about them [img]http://public.gamedev.net//public/style_emoticons/default/biggrin.png[/img] I would presume that 99% of people you've talked with / read are probably still stuck in the early 1990s "C with Classes" approach and aren't really using C++, since templates are a pretty fundamental feature thereof [img]http://public.gamedev.net//public/style_emoticons/default/biggrin.png[/img] // Chances are they were using ancient (late 1980s/early 1990s) compilers that didn't support much beyond the pre-standard "iostream.h" and simply couldn't compile template-based code well or at all -- so, no wonder they had bad experience ;] I have to say, it takes some major intellectual laziness though to never try a feature again just because a decade or two decades ago one had a bad experience... If you want to catch up, I'd recommend: [url="http://www.moderncppdesign.com/book/main.html"]http://www.moderncpp.../book/main.html[/url] [url="http://www.boostpro.com/mplbook/"]http://www.boostpro.com/mplbook/[/url] If you're already familiar with OOP and design patterns, you can see the first book as trying to achieve the abstraction without the run-time performance overhead penalty -- for instance, what's known as "strategy pattern" in the Design Patterns book (using the OOP) way is really stemming from a common software engineering principle and (re)introduced as "policy based design" (using the GP) in the Alexandrescu's book. You shouldn't trust other people, you should pick up the book, examine it, and determine the costs/benefits yourself! That's why this part of your statement worries me: "and I chose not to use them myself. (Though by doing so it also means I'm not good at them either.)" This is exactly the WRONG approach -- you should FIRST become good at a feature in order to be able to assess whether it's good or bad for your project(s) and choose what's right, otherwise you're unable to do so (and no, reading/listening to other people, including me, is not enough -- personal experience is vital!). Only then you're able to pick and choose optimally. Take the "virtual" keyword, for example -- are you sure that when you need polymorphism in your code it *always* has to be dynamic/run-time polymorphism? If not, are you aware that C++ allows you to have static/compile-time polymorphism with absolutely zero run-time costs /* [url="http://en.wikipedia.org/wiki/Curiously_recurring_template_pattern"]http://en.wikipedia....emplate_pattern[/url] */? Perhaps it will turn out that dynamic polymorphism is exactly what you need. Perhaps not. Similarly, it may turn out that Data-Oriented Design (DOD) will be a better fit than OOP in a particular application -- [url="http://gamesfromwithin.com/data-oriented-design"]http://gamesfromwith...oriented-design[/url] -- or, in completely another application, the costs/benefits flip around. That's the beauty of multiparadigm programming -- it allows you to pick *exactly* what you need, when you need it -- no less and no more. Seriously, I recommend you to pick up GP and TMP as well -- it will make you a better programmer and a better designer. As for mixing -- again, see the links to Stroustrup's FAQ -- no offense, but I'm inclined to take the word of the C++ creator over you and "99% of people" you've encountered for what's wrong and what's right in C++ :-) [/quote] A very well written reply. +1 (Apart from your last sentence.) I understand that there are people who like templates, of course, I just haven't heard of any yet. I didn't count Stroustrup, because... well, frankly, he's biased. You misunderstand me, I didn't chose not to use them because of what others have said. They didn't make sense to me. Aren't they changing/improving templates for C++0x? As I recall, they had a pretty big flaw, which they are [finally] fixing now, so there is/was probably a reason that caused people not to like them, and likely the same reason that caused them to fix/improve it. I have no formal education in programming, so I lack a lot of the terminology, and maybe I use some of it poorly. I do my best. I also side with the creator, once I truly understand the intent and value of it. I just don't see it with templates. They're messy, first of all. I don't like using "++" in statements either, so I don't side with the creator there either, I think it's bad practice to use it in any other way that pretty much only "x++;" on it's own. and there are articles explaining why it's a bad idea, because it causes ambiguity in many cases. But C++ allows it, just like it allows many other bad practices (in different people's opinions). I just think templets fall into that category, which inherently means it's an opinion or matter of taste or style. All I'm saying is that I'm not alone in seeing it that way. And like I've said earlier, I also use C++ procedurally (mostly when testing stuff), but I would never mix 2 styles in one application if I could help it. I actually go to great lengths to avoid doing so, sometimes. Keeping one style consistenly throughout one program is deathly important to me, so that I know where to look and what to expect when I look for things in my code. But if I completely skipped classes in a program, I personally would not consider it proper C++, and I stand by this opinion, for now.
  13. Getting started with open world game development

    [quote name='nagarjun' timestamp='1340514701' post='4952235'] [quote name='antiHUMANDesigns' timestamp='1340503855' post='4952189'] If you have a 3D model of the world, you can quite easily load it into an application and display it with openGL. Moving the camera around is about as easy as it gets. If you don't want to be encumbered by an actual engine, then what I said is really all it takes. No need for an engine that supports audio, physics, animation and so on. No need for an engine at all, really. Export the model into some easy format like .obj, or .rtg, and write or borrow a loader, and you're pretty much good to go. That is, unless you want collision detection for the camera, which I guess would be nice and make sense. Maybe you can add that too, since it's the only thing you'll need to focus on to make it work. And when you're done, you'll feel good about having done it yourself, and you'll have learnt something. [/quote] thank u for your advice.. i want to follow this method rather than using a game engine. but, can you please elobrate the procedure..i have no expernce with openGL...what are the tools i should use for this?? [/quote] [quote name='nagarjun' timestamp='1340514701' post='4952235'] [quote name='antiHUMANDesigns' timestamp='1340503855' post='4952189'] If you have a 3D model of the world, you can quite easily load it into an application and display it with openGL. Moving the camera around is about as easy as it gets. If you don't want to be encumbered by an actual engine, then what I said is really all it takes. No need for an engine that supports audio, physics, animation and so on. No need for an engine at all, really. Export the model into some easy format like .obj, or .rtg, and write or borrow a loader, and you're pretty much good to go. That is, unless you want collision detection for the camera, which I guess would be nice and make sense. Maybe you can add that too, since it's the only thing you'll need to focus on to make it work. And when you're done, you'll feel good about having done it yourself, and you'll have learnt something. [/quote] thank u for your advice.. i want to follow this method rather than using a game engine. but, can you please elobrate the procedure..i have no expernce with openGL...what are the tools i should use for this?? [/quote] Sry for the late response. OK, no experience with openGL... well, if you're decent with C++, you may be OK, because just displaying a model isn't very hard in openGL, using the most basic way, where you just specify where the vertices are, and their texture coordinates and normal. You don't need any "tools", I would say. Just find some code that loads an .obj or .rtg (or something else, if you can find it). That'll usually give you an object where all the vertices and stored, and you just iterate through it and output the vertices using glVertex. (I would definitely make it a display list, though, but that's easy to add once you get the model showing.) If you want lighting, you need to speficy the normals, which will be in that object that loaded your model, so output those aswell. And then you need to speficy light positions and turn on lighting, and some minor stuff like that. It really isn't very hard, so don't worry, just get one thing working at a time using online tutorial. It's no problem at all finding a simple tutorial on how to just output triangles, on google. It's very, very basic. Try googling and reading some of it there, and if something doesn't make sense to you, come back here and ask more specifically what you need help with.
  14. Few questions - collision detection

    [quote name='Aurioch' timestamp='1340545703' post='4952313'] Thanks for answers, both of you. winsrp, I'm making 2D game so BoundingBox and BoundingSphere are out of question... I'll use the tutorial you gave me. It will require complete code rewrite then... Well then, I'll stick to the XNA for now and keep Unity in mind. Few 2D projects first, then I'll move on to 3D... I'll need to learn to use Blender or Maya too >.< [/quote] There's a good and free 2D physics library called Box2D (right?). You could check that out.
  15. Few questions - collision detection

    I did some 3D modeling for a small game that used XNA, and the collision detection/response seemed to be lacking. It acted really weird once the speeds increased. But of course, it might have been the programmer's fault, but it seemed to improve once he switched to another library for physics. ("Bullet" library, I think.)
  16. Newbie

    [quote name='Sid_TheBeginner' timestamp='1340550249' post='4952329'] [quote name='antiHUMANDesigns' timestamp='1340548753' post='4952321'] I agree with that guy. (Only watched the first part). And I did start with a game-specific language (AMOS, which I dare assume is game-specific), but I was a kid and I didn't have a choice, it was all that was available to me at that time. I think I would've been better off going straight to C or C++. To me, it doesn't feel like knowing a game-specific language actually means you know programming. It feels like you're very much limited, and even worse, oyu may become too comfortable in it to ever progress outside of it, though I'm hoping few people would have such a problem. [/quote] Yeah, I watched all the 3 parts before a few days and that's why decided to start learning C++ because I've no clue about what is what and so I decided to take this guy's words by heart. [/quote] Try to see if you can find a friend who is also looking to start with game development, and join forces in learning. Discussing and solving rpoblems together on equal terms might be great both for moral and your ability to progress past hard points.
  17. Please simplify my code.

    [quote name='Matt-D' timestamp='1340549177' post='4952323'] [quote name='antiHUMANDesigns' timestamp='1340547802' post='4952317'] [quote name='andrew111' timestamp='1340521135' post='4952251'] [quote name='antiHUMANDesigns' timestamp='1340513578' post='4952233'] but C++ does not run on a virtual machine like Java does. [/quote] That does not have anything to do with why c++ doesn't have an "Application" class for the main. riverreal is correct in that c++ is a multi paradigm language, which means you use oop where it helps, and procedural or functional (limited) programming etc where they help. And I don't think having an "Application" class helps at all, making a class to be instantiated once (except for cases of inheritance) seems like a wasted effort. [/quote] A very small wasted effort, in such a case. But if a language is meant for OOP, then I think it should be done that way, just like Java (though I don't like Java). In Java, you don' thave the option to stray outside the OOP path, and I don't think C++ benefits from doing so. If you want to write a small program, you can choose to do it in C, and that's a choice. But you can also chose to do it with "proper" C++, which I feel is by going OOP like it was intended. Don't you agree that C++ without OOP could just be C instead? Most of the improvements in C++ are related to abstraction. If you chose to ignore those, you might as well go with C? Do note that I'm trying to teach a beginner the difference between C and C++. I dont have any other agenda here. But don't get me wrong, I never meant to claim that you can't write C++ procedurally. I agree that it will compile, but I'm also quite sure that the only reason it will still compile is because C++ never got a chance to get free of C. Stroustrup himself says that C is obsolete, and that he wants C++ to be free of it. [/quote] I disagree. As said above, C++ is a multi-paradigm programming language. I actually mostly use GP (Generic Programming) with TMP (template metaprogramming) over OOP for code reuse and (static) polymorphism and find it much cleaner and more preferable. Allowing to mix and choose is its strength over C# or Java (they have generics, but they're quite different, resolved at run-time, and rather limited). The whole idea of "pure OOP" where "everything is an object" is simply incompatible with GP or at best uninteresting; see interview with Stepanov, [url="http://www.stlport.org/resources/StepanovUSA.html"]http://www.stlport.o...tepanovUSA.html[/url] Of course that strength really shows when you mix in modern techniques, like GP and TMP, not meaning that you should stay with imperative programming / procedural programming for everything (with C-style code you'd have to deal with C-style errors). And I find programs written in early style / "C with Classes" /* [url="http://c2.com/cgi/wiki?EarlyCeePlusPlus"]http://c2.com/cgi/wi...arlyCeePlusPlus[/url] */ to be a problem as well. // IMVHO, OOP and some of its features are overused to the point of abuse -- I think you should learn templates and get used to static polymorphism/CRTP before you even begin to think about using the "virtual" keyword -- if you want to start with C++ the modern C++ way, learn templates, STL, and Boost first, picking GP and TMP as your main paradigms -- object-orientation second; the imperative & procedural stuff should just come to you in the meantime ;-) In the end: pick and choose what's optimal for your project (now you see why you should be aware of *all* the things to pick and choose from). See: [url="http://www2.research.att.com/~bs/bs_faq.html#oop"]http://www2.research...bs_faq.html#oop[/url] [url="http://www2.research.att.com/~bs/bs_faq.html#generic"]http://www2.research...aq.html#generic[/url] [url="http://www2.research.att.com/~bs/bs_faq.html#multiparadigm"]http://www2.research...l#multiparadigm[/url] [url="http://www.research.att.com/%7Ebs/oopsla.pdf"]Why C++ isn't just an object-oriented programming language[/url] [/quote] OK, see, from everything I've read, 99% of people have nothing but bad things to say about templates, and I chose not to use them myself. (Though by doing so it also means I'm not good at them either.) And I'm not exaggerating when I say 99%. I can't recall one single person, besides you, who has said anything good about templates. I just made personal choice not to use them, but I admit that I no longer remember straigh off-hand why that is. And don't get me wrong, I write things procedurally at times aswell. I just don't think it'd be a good thing to teach people to do things the easy way. Maybe I'm at fault, I'm not a licensed teacher. And, perhaps due to my aspergers, I do surely over-engineer things, because I want everything to make sense. And mixing procedural and OOP is the same application simply feels right-off stupid to me. I see no defense for it. (OR, more correcly: I see no defense for ME to do that.)
  18. Please simplify my code.

    [quote name='rip-off' timestamp='1340547788' post='4952315'] antiHUMANDesigns, your program is actually a poor example of C++. Forcing object orientation into what can be more easily represented as a procedural program doesn't really gain you anything. Your code has some good ideas that would be relevant - splitting the program into smaller functions, but the artifical use of classes actually detracts from the program. There is a tipping point where object orientation starts to make sense. For example, you might create a slot machine class when the slot machine has state - it might record how much money it has and the program would allow the casino operator to take the profits or replenish losses from the machines. This program has almost no state - just the player's money. The money is such a simple concept that wrapping it in a class seems unnecessary - overengineering really. [/quote] Oh, you're right, I'm known to suffer from over-engineering complex. Might be my asperger acting up. But I'm sorry, I just can't agree that using OOP ever makes for bad C++, even in small applications. We might have different viewpoints on this, and I think neither of us would go as far as to shout "Truth!(TM)". Properly formatted and divided into separate files, even small programs look and feel so much better to work with in OOP. And I still think it makes them easier to update and whatnot. But in this very thread, to me it's about advocating abstraction.
  19. Please simplify my code.

    [quote name='Tasaq' timestamp='1340548747' post='4952320'] [quote name='antiHUMANDesigns' timestamp='1340512376' post='4952230'] [quote name='riverreal' timestamp='1340511991' post='4952228'] [quote name='antiHUMANDesigns' timestamp='1340511462' post='4952224'] [quote name='riverreal' timestamp='1340508456' post='4952209'] [quote name='antiHUMANDesigns' timestamp='1340506692' post='4952199'] OK, let me start by saying this, very clearly: This is not C++. This is C. You should learn C++ instead. What book or reference are you using, which claims that this is C++? Throw it out the window, whether literal or virtual, and get a reference of C++ instead. C++ is an object-oriented programming language. This means that you should look at things as real-world object, created from blueprints called classes (or structs). If you have a game with a slot-machine, then that slot machine is an object, I think you'd agree. (In fact, the game itself is an object, isn't it?) So what you need to do is to write a class called SlotMachine, and create an object from that class. And pulling the lever on a slot machine should be represented as a member function (or a "method", as it's called in some languages) of the SlotMachine class. So when you want to pull the lever, you write slotMachine.pullLever(). You have pretty much crammed everything into the main() function. That is not the C++ way, but the C way. I'd love to re-write it all in C++ for you, but... well, I think you should do it, frankly. Otherwise you'd not be learning, I think. EDIT: Oh, don't get me wrong, I'll help you if you need it, and I'm sure others here will aswell. Just try some on your own, with a decent C++ reference in your back, and if you run into problems, we're here. Just... start over, and do it in C++. [/quote] I think you are confused... He uses an object of class osteam called "cout" instead of "printf". Ok, let me say this clearly this is not C. This is C++ You can create a new file, and call it "main.c". Then copy the code above, and compile it... What do you get? A lot of errors!! C can not use objects, and iostream isn't a C library! [/quote] You're going to start being snide? Can we not do that, please? Ask mr Stroustroup (spelling?) if this is how C++ was designed to look. Yes, he may use one of C++'s objects, but if he still codes his programs as if it was C, then he gains no benefits of C++'s improvements. That is not something I should have to argue about. [/quote] You are wrong again... The OOP is just one of the paradigms. C++ is multi-paradigm. Look here: [url="http://en.wikipedia.org/wiki/Multi-paradigm_programming_language#Multi-paradigm_programming_language"]http://en.wikipedia....amming_language[/url] So, C++ can be structured like C. OOP is not the only improvement. You said the code ISN'T C++ and IS C... So go and make a main.c file, copy the code, and compile it... [/quote] If you want to be picky, OK, you win. Technically, what I said was wrong, because it won't compile as C. Now, listen to this: [url="https://www.youtube.com/watch?v=JBjjnqG0BP8"]https://www.youtube....h?v=JBjjnqG0BP8[/url] and see my point. [/quote] If we start with Bjarne Stroustrup, in "Design and and evolution of C++" he wrote: " In particular, I do not try to enforece a single style of design through a narrowly defined programming language. People's ways of thinking and working are so diverse that an attepmpt to force a single style would do more harm than good. Thus, C++ is deliberately designed to support a variety of styles rather than a would-be 'one-true way'. " You try to push oop like the one-true way. This guy stated that he just started learnig C++, and if this is his first programming language, learning oop is like learning how to ride a bicycle befor learning how to walk. He should learn imperative programming first, and since C++ is hybrid, he is using it. And by the way, I love OOP and that's why I use C#. But in my opinion people should start from basics. [/quote] You equate "style" or "style of design" to mean OOP vs non-OOP, when it could mean so many other things. Maybe it's taken out of context, but nothing in that piece of text say that what he's talking about is OOP vs procedural. I push OOP as the one-true way for C++, yes. Maybe I'm at fault there, and if so I apologize. I guess that if that's not an accepted stand-point, I should keep it to myself. And I agree that learning the basics in programming first may be a good idea, but then maybe learning C++ as a first language wasn't a good idea? I think that if you're going to learn C++, you should learn it properly without generating bad habits from the start. Now, as to what is actually bad habits, I don't claim to have the one true answer, I'm just throwing in my 50 cent, for free. If I was cherging for what I was saying, people would have more of a right to bash me for it. As of now, I'm only trying to help.
  20. Newbie

    I agree with that guy. (Only watched the first part). And I did start with a game-specific language (AMOS, which I dare assume is game-specific), but I was a kid and I didn't have a choice, it was all that was available to me at that time. I think I would've been better off going straight to C or C++. To me, it doesn't feel like knowing a game-specific language actually means you know programming. It feels like you're very much limited, and even worse, oyu may become too comfortable in it to ever progress outside of it, though I'm hoping few people would have such a problem.
  21. Government simulation game tutorial

    [quote name='6677' timestamp='1340533447' post='4952274'] [quote name='antiHUMANDesigns' timestamp='1340484535' post='4952100'] C++ remains the most powerful language [/quote]and one of the most difficult for newcomers... [/quote] Can't argue with that, but it's worth it.
  22. Please simplify my code.

    [quote name='andrew111' timestamp='1340521135' post='4952251'] [quote name='antiHUMANDesigns' timestamp='1340513578' post='4952233'] but C++ does not run on a virtual machine like Java does. [/quote] That does not have anything to do with why c++ doesn't have an "Application" class for the main. riverreal is correct in that c++ is a multi paradigm language, which means you use oop where it helps, and procedural or functional (limited) programming etc where they help. And I don't think having an "Application" class helps at all, making a class to be instantiated once (except for cases of inheritance) seems like a wasted effort. [/quote] A very small wasted effort, in such a case. But if a language is meant for OOP, then I think it should be done that way, just like Java (though I don't like Java). In Java, you don' thave the option to stray outside the OOP path, and I don't think C++ benefits from doing so. If you want to write a small program, you can choose to do it in C, and that's a choice. But you can also chose to do it with "proper" C++, which I feel is by going OOP like it was intended. Don't you agree that C++ without OOP could just be C instead? Most of the improvements in C++ are related to abstraction. If you chose to ignore those, you might as well go with C? Do note that I'm trying to teach a beginner the difference between C and C++. I dont have any other agenda here. But don't get me wrong, I never meant to claim that you can't write C++ procedurally. I agree that it will compile, but I'm also quite sure that the only reason it will still compile is because C++ never got a chance to get free of C. Stroustrup himself says that C is obsolete, and that he wants C++ to be free of it.
  23. The Arc Tangent Program

    [quote name='Sid_TheBeginner' timestamp='1340518837' post='4952244'] [quote name='antiHUMANDesigns' timestamp='1340518450' post='4952243'] [quote name='Sid_TheBeginner' timestamp='1340517216' post='4952242'] [quote name='antiHUMANDesigns' timestamp='1340516305' post='4952239'] Your first 2 result are 180 degrees off, see? And you're outputting with +180 in your code. You should check what you're doing there, and you'll figure it out. EDIT: Oh, and change "3.14" to "3.1416" to get a little more precision, if you want. [/quote] Thanks it worked! But Oops! . The formula says " If ? is in quadrants 1 or 4 then ? = tan?1 (y / x). Else if ? is in quadrant 2 or 3 then ? = tan?1 (y / x) + 180° " The Program seems to work fine now but there seems to be some logic problem. I'm adding 360degrees to the 3rd quadrant?!! [/quote] Well, I'm no expert on trigonometry, but I'm thinking that firstly, it depends on whether you supply x,y or y,x, and secondly, yes, you may need to "twist" the value by adding or subtracting 180 degrees, but it really depends on what you're going to use it for. If it's just a practice run for C++, don't mind too much about whether you turned something left or right according to trigonometry (unless you do care, and that's fine too). If you get the answers, but they're 180 or 360 degrees off, consider the task complete and move on, I'd say. Once you're actually using this for something in a 3D game or such, you may want to adjust these things to fit your purpose. [/quote] Yeah, so that means this program is fine. Phew xD Thanks for your reply.. [/quote] Well, yeah, as long as it's just an exercise in programming, rather than actually trying to perfect your trig skills.
  24. The Arc Tangent Program

    [quote name='Sid_TheBeginner' timestamp='1340517216' post='4952242'] [quote name='antiHUMANDesigns' timestamp='1340516305' post='4952239'] Your first 2 result are 180 degrees off, see? And you're outputting with +180 in your code. You should check what you're doing there, and you'll figure it out. EDIT: Oh, and change "3.14" to "3.1416" to get a little more precision, if you want. [/quote] Thanks it worked! But Oops! . The formula says " If ? is in quadrants 1 or 4 then ? = tan?1 (y / x). Else if ? is in quadrant 2 or 3 then ? = tan?1 (y / x) + 180° " The Program seems to work fine now but there seems to be some logic problem. I'm adding 360degrees to the 3rd quadrant?!! [/quote] Well, I'm no expert on trigonometry, but I'm thinking that firstly, it depends on whether you supply x,y or y,x, and secondly, yes, you may need to "twist" the value by adding or subtracting 180 degrees, but it really depends on what you're going to use it for. If it's just a practice run for C++, don't mind too much about whether you turned something left or right according to trigonometry (unless you do care, and that's fine too). If you get the answers, but they're 180 or 360 degrees off, consider the task complete and move on, I'd say. Once you're actually using this for something in a 3D game or such, you may want to adjust these things to fit your purpose.
  25. Hey man, cool project. Possibly the wrong forum, though, since this tends to be programmers, and you're looking for... en engineer? Electrician? I dunno, but we tend to be programmers.
  • Advertisement