Jump to content

  • Log In with Google      Sign In   
  • Create Account

Banner advertising on our site currently available from just $5!


1. Learn about the promo. 2. Sign up for GDNet+. 3. Set up your advert!


Bregma

Member Since 09 Dec 2005
Offline Last Active Apr 28 2015 06:24 AM

#5210451 Aliens as citizens of the Empire?

Posted by Bregma on 13 February 2015 - 05:45 AM

Don't forget the interesting aspect of what happens even within the superior race(s) of your empire.  Refusal to airdrop the disease-infested blankets on colonized planets; citizens caught selling intoxicating rocket fuel to lesser species on the reserved wasteland left to them on their native planet;  breakaway planets forming an alternative federation and eventual civil war over freeing the slave races; million-lightyear marches over the lack of civil rights for the disenfranchised species; organized crime including intoxicant running and illegal planet-hopping among the second-tier species; space police violence and subsequent species riots; lynching poor refugee insectoids from their own spinnerets after accusations of stealing your women, etc.

 

Maybe you're just better off wiping out every alien species where you find it.




#5208414 An invalid iterator that is null while checking collision detection

Posted by Bregma on 03 February 2015 - 10:02 AM

Do not use for(it) and erase(it) in the same loop.  You will know grief.




#5208380 Comparison of STL list performance

Posted by Bregma on 03 February 2015 - 06:15 AM


o me it sounds a bit too much that std::list would use additional "next" and "prev" pointers for every element, when it could speed up performance simply by using buckets.

A std::list that invalidates iterators after erase() or insert(), and does not support remove() and splice() as defined in [23.3.5.5], would be non-conforming.  If you want a deque, use a deque.




#5207918 How to import a custom module?

Posted by Bregma on 31 January 2015 - 01:29 PM

Python does not know where to find the module you're trying to load.  It normally only looks in the configured system installation path, and that depends on a number of factors (given you're running KDE my guess is you're on Linux, so I'll point out it depends on the Python version and the distro you're running).

 

To add additional search paths for importing modules when running Python, use the PYTHONPATH environment variable.  In your Konsole shell, try

 

  PYTHONPATH=~/pythonpractice python

 

This is assuming you have a file called ~/pythonpractice/pyperclip/__init__.py (which is the file Python will be looking for when you import pyperclip).




#5205977 Encapsulation through anonymous namespaces

Posted by Bregma on 22 January 2015 - 07:03 AM

BTW, it's the same as:

Not entirely: there's an important difference between names with static linkage and names with extern linkage. For example, templates can only be instantiated with names of extern linkage. Names with extern linkage get involved in link-time resolution, names with static linkage do not (so giving things static linkage where possible can speed up build times, sometimes remarkably).

Names at namespace level (including the :: namespace and the anonymous namespaces) by default have extern linkage. Adding the 'static' keyword gives them static linkage instead.

Still, it is the traditional C way of encapsulating things, used since the early 1970s. There are worse things to reinvent.


#5205566 c++ Heap corruption w/ std::vector

Posted by Bregma on 20 January 2015 - 10:24 AM

What is the smallest, simplest program that reproduces the error for you? The code you posted contains no errors, we can't guess at the code you did not post.


#5205290 why C++?

Posted by Bregma on 19 January 2015 - 08:29 AM

The answer is at your fingertips.


#5205012 Porting my game to Linux

Posted by Bregma on 17 January 2015 - 10:00 PM


While I'm at it, Ubuntu has an app store, and I hear that it's not working (or harder than it should be to install) on Linux Mint 17. One of my goals is to get this on that distribution channel. Do Mint users commonly have this installed?

The Ubuntu App Store only distributes Ubuntu click packages for the Ubuntu phone (it's actually pretty easy to get your app there, but not (yet) applicable to the Ubuntu desktop).  It might be you're thinking of the Ubuntu Software Center, which is just a GUI front end to the Ubuntu software archives (whence most software for Ubuntu and Mint comes).  Getting your software into the Ubuntu archives might be a little tricker:  it has to pass several technical and social challenges first.  They also prefer you get it into the Debian archives first, and that's a major challenge given the tight clique circle-jerk that is Debian.

 

Keep in mind most distros will build the binaries for your application from source: you only have to worry about "working on other distros" if you're distributing binaries.  If you're distributing binaries, you're not going to get in to the equivalent of an app store for a distro.

 

Also, Ubuntu accounts for about 80% of all installed Linux desktops out there, and Mint is just a copy of Ubuntu with the thin veneer of a different desktop shell lacquered on top.  Targeting Ubuntu 14.04 LTS is probably all you need to worry about.




#5203676 About computer instruction in relation to RAM consumption

Posted by Bregma on 12 January 2015 - 09:19 AM


Although it may look attractive to jump into the deep and quickly get a feel of moving towards your dream, it will not help you to actually become a proficient game programmer. That's why I always - sometimes against popular belief - recommend to start out with raw assembly (preferably on a 65xx emulator or DOS in real mode) and then move up to C or any other compiled language, and finally move to scripted languages. That way you can see all the way down at any stage and really know what's going on under the hood.

You have not learned to appreciate how computers work until you have smelled the rosin core of your solder.

 

Seriously, there are really good hands-on ways to understand the basics of a computer.  Be forewarned, this can be a (worthwhile) time an money sink.




#5202603 Silly question about classes/libraries/headers

Posted by Bregma on 07 January 2015 - 09:00 AM

The technical term in C++ is "namespace-level function".  It's often colloquially known as a free function or a non-member function, both terms implying the normal state for a function is as a member of a class.  It is an untrue assumption.

 

The technical term in C is "function".

 

The technical term introduced by FORTRAN well over 60 years ago is "subroutiune."

 

The technical term for moving a namespace-level function into a separate .cpp file is "separate compilation."




#5202219 Looking for a good way to make games in C/C++ on linux for cross-platform

Posted by Bregma on 06 January 2015 - 07:30 AM

what is the best way to distrubute after i make a game in C++

 

(1) Both libSDL2 and SFML are available on popular GNU/Linux OSes and have been ported to the Mir display server and the Weston API for Wayland, so they'll continue to be available on future iterations of those OSes.

 

(2) The way to distribute software on most popular GNU/Linux OSes is via software packages (generally either RPM or DEB format), and packages generally need to be targeted at a particular OS.  Some newer package formats (eg. how Steam works) are now being supported that are more cross-platform because you ship and install all the dependencies in one huge, expensive-and-slow-to-download tarball.  Generally, licensing and security issues get ignored with the latter, so be prepared for problems down the road.

 

I'd say first get your game working, then worry about distribution.




#5201824 Linking Words as Conditional Statments

Posted by Bregma on 04 January 2015 - 05:28 PM

I suspect you're trying to map natural language constructs into programming language constructs, because apparent some computer programming languages use tokens identical to natural language words to identify mathematical processes or operations not terribly unlike those denoted by the natural language word they mimic.

 

The problem is that it is not an ontological relation between the vocabulary of a natural language and the underlying mathematical concepts denoted by a programming language.

 

Don't be mislead by the superficial resemblance between programming languages and natural languages.  The likeness is not coincidental, but is about as meaningful as using invisible whitespace to give significant meaning to program code.

 

If you want to look at an attempt to give a natural-language-like semantic veneer to a programming language, read up on COBOL.  It was supposed to be so natural to use any non-engineer to whip up a bank payroll or military missile guidance system without introducing any errors at all, and be able to explain it to his pointy-haired boss..  "ADD ONE TO ACCOUNT-INDEX GIVING NEXT-ACCOUNT-INDEX.  MOVE PAYROLL-RECORD AT NEXT-ACCOUNT-INDEX FROM INPUT-FILE TO WORKING-PAYROLL-RECORD."  Go wild.




#5200989 So something's not working correctly..

Posted by Bregma on 31 December 2014 - 09:15 AM

To clarify:  the condition of the "if" statement is declaring a new variable named 'y' that hides the parameter named 'y' in the simpleDivision() function, and initializes it to zero which is an expression equivalent to 'false' so control falls through to the "else" clause.  The scope of a variable declared in a control statement is the end of the scope of the control statement, in this case that is the closing brace of the "else" clause associated with the "if" statement.  You then divide by zero, and the universe proceeds to implode in an orderly manner.

 

So the most important lessons learned here is to use '==' and not '=' to compare two values for equality in an expression:  if you had done that, the code would not have compiled.  Don't worry though, I still sometimes accidentally use '=' instead of '==' after more than 30 years of C programming.  Algol-based languages use ':=' for the assignment operator to avoid the problem, Fortran uses '.eq.' for the equality comparator to avoid the problem.  Sucks that the language war winner was pretty much the most undeserving candidate.




#5200131 Getting Rid of "char*"

Posted by Bregma on 26 December 2014 - 02:54 PM


Most std::string implementations keep small strings on on the stack for you automatically, and store larger strings in dynamically allocated memory.

The SSO (short string optimization) is required of any ISO standard-conforming implementation, as of the 2011 version of the C++ standard.




#5200061 Getting Rid of "char*"

Posted by Bregma on 26 December 2014 - 08:05 AM

Like Ryan_001 said, you'll either need to provide an interface for your family of String classes and program to that interface, or provide a family of function overloads for each member of your String class.  I'd recommend the interface method, since you can't overload on a return type so you'll need to explicitly instantiate such templated function overloads at the call point instead of relying on deduction, and that can quickly make you code messier.

 

Don't worry about all the bloat that using a separate class for every possible string length will introduce. Modern computers have more than enough memory and disk space to handle that and statistically speaking you're unlikely to have more than a few hundred such classes (or function overloads).  If it turns out all the code fragmentation blows your cache coherency noticably, get a bigger i7 with more cache.






PARTNERS