• Content count

  • Joined

  • Last visited

  1. Where to start making a game in assembly.

    Yes, libSDL2 and assembly are a good combination for game development. I'd recommend using Linux because the traditional toolchain is slightly easier for assembly development (gas, ld, make, and gdb; simpler and more consistent calling conventions; plenty of Free libraries you can leverage) but you can bend your workflow to fit other tools if that's more your thing. You'll want to stay away from mixing C++ or Objective-C libraries with assembly because of the complication of name mangling. Other languages like Java, Rust, or the interpreted languages would be painful to use with assembly. Good luck and enjoy the trip.
  2. Under no circumstances should you question my obviously superior intellect.
  3. I do not work with bottom-grade programmers who would alter functionality without understanding it first. If you absolutely must blindly follow rigid ideology and make the argument to your copy assignment operator a reference, the code would look like this. VertexBuffer& VertexBuffer::operator=(VertexBuffer const& other) { VertexBuffer tmp(other); this->swap(tmp); return *this; } Interestingly, modern compilers will pessimize that alternative code because they can not take advantage of copy elision like they can with pass-by-value parameters. Your coworker's blind obedience to cargo-cult pass-by-const-reference just cost a thousand CPU cycles. Consider giving them an opportunity to pursue a more satisfying role as a node.js front-end developer where they can cause less harm. One of the big advantages of the copy-and-swap idiom is that it provides the strong exception safety guarantee, whereas the original code did not (again, trace it through). You might argue against the use of exceptions in C++ (after all, we're already speaking of a level of mindless reverence at play in your place of work) but writing the most robust code as possible is usually a win in the long run. Sure, in this trivial example you're unlikely to see an exception, but not all code is so trivial and the copy-and-swap idiom will always apply. As for adding a self-check, consider the cost of adding and maintaining an equality operator (and corresponding inequality operator) and the cost of calling it every time and compare that to how ofter you write code that performs self-assignment. I know I very very rarely write code that assigns an object to itself, but code that is never written costs less and is guaranteed bug-free. Always spending extra CPU cycles and increasing the risk in code to make a single highly unlikely edge-case more efficient seems like a lose-lose tradeoff to me. Really, other than deleting the copy assignment operator entirely or adding debug printfs, why would you ever use anything other than the two-line copy-and-swap I wrote above for all your classes?
  4. No. Trace through the operation of the code I wrote. See how the copy constructor is used to implement the assignment operator? Now, isn't it elegant?
  5. A copy assignment operator should always look like this. VertexBuffer& VertexBuffer::operator=(const VertexBuffer other) { this->swp(other); return *this; } Of course, you need to implement your swap() member function, but that should be fairly trivial. See, the magic of this is it implements the copy assignment operator in terms of the copy constructor, which is generally the expected behaviour, so you only write the meaty function once. Even your base class should implement the operator this way. Trace it through, you'll see what I mean. Also, why would you create a class hierarchy without a virtual destructor in the base class? That smells of a misuse of inheritance.
  6. Goodbye!

    Thank you for your service.
  7. If you're looking to get into server development and management, get yourself VirtualBox (or VMWare) and set up local test servers as virtual devices on a local workstation in a virtual network. You can play with everything you need that way, with backups (in case you mess up) and easy restarts (in case you mess up). Study up on using Docker to wrap and provide your services, and that way you can build and test on your local workstation-encapsulated server network and then migrate (publish) to your live server, with minimal risk and without change. If you want to get a Pi, get a Pi. You don't need a Pi to do any server development. You can even run Docker on a Pi if you're serious about using one as a server.
  8. C++ General C++ class questions

    1. Class static members are secretly just global variables of static storage duration. They are explicitly initialized at their point of definition. 2.The use of exceptions (or not) in constructors is a deeply-held religious belief. Ask this question and you will be proselytized here. The right answer actually depends on what paradigm you're programming in. 3. Execution in a debugger is not normal execution. 4. It is not possible to not fire the destructor on object destruction. Your design is broken. Look up the "rule of three" (or "rule of five') and reference counting, or else use the heap if the lifetime of your resource exceeds local scope. 5. All member variables are initialized in the constructor. If you do not explicitly initialize them in your code, they will have their default constructor invoked. The default constructor for built-in types like ints and pointers is normally "random" although some compilers in "debug" mode will set a known value.
  9. In Python is very easy to monkey-patch mock functions and objects so you can test without hitting actual system, network, database, or screen draw calls. Mocking a method of a class by binding a lambda to a side_effect attribute of the MagicMock lets you get away with injecting captive test data into your system from the bottom and then verifying the results returned by your higher-level functions. Also, thinking about how you're going to mock required dependencies helps you architect your code better.
  10. If you end up with a dangling pointer because two objects share ownership of that pointer, you have maybe chosen the wrong smart pointer semantics to start with. Short answer to your original question: if it works and lets you finish the game, it's an acceptable design.
  11. DX11 Viewports required?

    There's also the fact that most graphics software were originally developed using Fortran, which uses column-major order for its built-in matrix type. It's much much easier to write matrix software in row-major order in C and derivative languages because all the data in a row is physically adjacent in memory (the address of a component vector in matrix[a] is just matrix[a]), so current generations of developers are more used to that approach because who writes Fortran any more?
  12. How to define a function for a problem?

    So, If I understand correctly, you have a vehicle that behaves like a car, you want to perform the manoeuvre known as "parallel parking", and you don't know how to calculate the middle part which is a sort of S-curve path (since the first and last parts are just simple straight-line travel). I would start with looking at using a Bezier curve to calculate the path. The rest is just basic integration of acceleration over time as the vehicle follows the curve. The interesting thing is how to calculate the control points from the position of the blockers.
  13. Coding Guidelines

    CBecause GProgramming VIs Aa NWork POf NLiterature. PIt VMakes PIt AVery VDifficult PFor NHumans VATo VRead CAnd AThe NCompiler PDoesn't VCare. CAlso, IWhat's PWith CAll AThe GCapitalization PIn ASo AMany NGuidelines?
  14. Might I recommend you look at the way the C++ standard library does exactly what you're trying to do. The code is available to you (albiet obfuscated with warts as mandated by the standard, for good reasons) and it's been tested and refined over decades and hundreds of millions of uses, so it's probably worth studying to pick up tips. Your available C++ standard library implementation does not have uninitialized members, getters, or setters; is fast and efficient; and provides strong exception guarantees. You will find answers to all your questions (except maybe WTF how can anyone read this code?) in the source files on your computer.
  15. How is Discrete Math used in video games

    Funny thing, that if you're processing discrete samples over time, you're using discrete math. If you're doing dead reckoning on a computer, you're using discrete math. Digital computers are not capable of doing anything except discrete math. In fact, it's the only thing they're capable of doing. It's great that you understand the theory of what's going on because calculus is really useful to describe it. No argument. The problem is that if you don't understand the discrete math you're actually using to implement these things you can run into all kinds of problems. For example the accumulation of error in your dead reckoning -- such a thing doesn't exist in the theoretical world of calculus and the infinite precision of real numbers and continuous functions, but it can add up quickly in the real world of discrete math until it overwhelms the signal if you take any of the more common naive implementations. Knowing and understanding the difference between theory (calculus) and application (programming) is important. You need to study both if you want to be a programmer, and know when each is relevant.