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!


Member Since 07 Nov 2002
Offline Last Active Today, 02:16 PM

#4999971 Switch vs if else

Posted by alnite on 11 November 2012 - 12:30 PM

While this might be language-dependent, you can't normally switch-case objects like strings. switch-case could only be used on integers, as it creates a jump/branch table. Additonally, in some languages, you are allowed to fall through a case statement.
switch (x) {
	 case 0:
	 case 1:

if x = 0, doSomething() and doSomethingElse() are executed. This style of coding could be useful in certain cases (no pun intended).

#4999095 Already know C++ - where to learn game programming?

Posted by alnite on 08 November 2012 - 07:30 PM

C++ by itself does not contain any library to access the video, input, and sound hardware, which is what you need for games. So in order to do that, you'd need to use a 3rd party API. SDL, SFML, as people mentioned are good candidates.

Once you familiarized yourself with the API, then you can start working on the core of the game. There isn't any 'de facto' Tetris tutorial, as there's no one correct way of making a Tetris (or anything else really). How you make it is up to you. Other people's source code should be good as points of reference. Here's one: http://code.google.c...e-tetris-clone/

As a beginner, I wouldn't suggest trying too much organizing your code. Your lack of experience will probably backfire -- chose the wrong patterns, premature optimizations, and all that. Do it as best as you can, but the most important thing is to actually complete your game. After you complete your game, your knowledge of project structure will skyrocket, and you'd know how to do it better next time.

#4999082 Industry's look on tattoos etc.

Posted by alnite on 08 November 2012 - 06:46 PM

I'm currently studying to become a games developer/programmer and have a tattoo sleeve but due to it being around an inch above my wrist I can easily cover it up (long sleeved shirt etc.) if need be. also was thinking of having a flesh tunnel in one of my ears (around 5mm - not like it matters) what are the views upon these things in the games industry (employment wise) anyone who has been in the industry and knows about the policy.
All answers are greatly appreciated

Depends on the company, but most game developers are pretty open-minded. As long as you don't flash gang tattoos and dress up in wife-beaters, you are fine.

#4996778 How powerful is Java?

Posted by alnite on 02 November 2012 - 11:46 PM

Over 9000

#4995503 Moving from Java to c++

Posted by alnite on 30 October 2012 - 12:16 PM

Hmmm. that actually sounds like a good idea, my main goal here is to learn everything thoroughly and properly from the beginning so I can be a good c++ programmer soon. I think forcing myself to do that will help me learn things that I'd usually just happily ignore and let my IDE do it for me. How important and how hard is learning all that? Anyone else think this is a good idea?

A command-line compiler is a great tool to learn. You will use it at some point in your career, and I'd recommend using that over an IDE at this point in time. IDE like VS can spout out error because of IDE config errors, not your code. This can confuse beginners a lot, thinking that their code is wrong while in fact, the IDE is messed up.

Also while I'm here, should I start with c++ 11? I know nothing about the different versions, is it backwards compatible? is it or will it be the standard soon? which version do you recommend I start with and why? The only concern I might have about that is that its new and might not be as well documented, I love have a wealth of resources when learning something new and complicated like c++.

I don't know much about C++ 11, but last time I tried to use it, the compilers have yet fully support all the features of C++ 11. You will get different results depending on which compiler/IDE you use (GNU, VS). I would suggest that you stay away from it for now. It's an extension of the language, not a whole redesign, so you won't miss a thing.

Anyone have any other general suggestions for learning resources or tips? I wanna learn this as thoroughly and as well as possible but I'm also eager to get my hands dirty with some real programming as soon as I can

I would focus on pointers, ctors, and dtors, as that's one of the main differences between Java and C++. When objects are allocated/deallocated in C++ is a whole different thing.

#4993991 Performance issues in simple program

Posted by alnite on 25 October 2012 - 07:15 PM

The main algorithmic improvement here is diving only by numbers up to the square root of the number.
...code snippet...

Nice. Here's my version:

int largestPrimeFactor = 2;
for (int i=2; i<=n; ++i) {
    while (n % i == 0) {
	    largestPrimeFactor = i;

#4989221 Advice for managing two different codebases for one game using Git (browser a...

Posted by alnite on 11 October 2012 - 01:51 PM

Yes, this is a good example for preprocessors. What preprocessors do basically format your code before passing it on to the compiler. So essentially, you can add/remove certain parts of the source code depending on the flags of the preprocessors you have setup.

For example: you have this code:

#elif WEB

Before compiling for iPhone, you set IPHONE variable to true, and WEB to false, and thus the code after being preprocessed will look like this:


#4986618 Communicating with Programmers

Posted by alnite on 03 October 2012 - 07:16 PM

Well yes, English. Beyond that, your knowledge in technical aspects is the only ticket to loosen out that tension.

Most frustrating communications I ever encountered with artists, or graphics designers, or UI designers, is that they don't usually understand the enormous task necessary to implement their artwork. Adding just one layer in Photoshop could equal to 10K lines of code with rigorous testing depending on what you are asking for.

This is an example that I run into just recently.

UI Designer created an assets for some product. It is obvious in the spec he created that the locations of every single thing is hardcoded in pixels. 10 pixels between button A and B, 23 pixels between button C and D, font size 12, etc. That's not going to work when you create a product on which the environment can be of any resolutions -- yet somehow he didn't get this and continue to give specs in pixels.

You artists have the benefit of working on a constrained environment. Your canvas has fixed width and height. You can fine tune each pixel or voxels or polygons, and paint brush imperfections. Programmers work on open-ended environments, in which he has to abide to the principle of generality. One code fits all. The code has to run on every single hardware combination with every single resolution on every single machine out there. So, we tend to approach problems as a whole, and fix the whole thing in one shot.

This introduces something that we all programmers hate, special cases. Special cases like "Can we bold the letter R right in the middle of that text, and then have the letter Z flash red every 10 seconds, and have the whole thing spin around, and only to do this when the hero died from the backstab wound, but in every other case, the text must flash blue-green and spin on the z-axis, because I think that'd be cool?" will drive programmers nuts.

Unfortunately there's nothing you can do to understand us except putting yourself in our shoes (learn coding) and see it from our perspectives. I have had the most pleasant experience working with artists who also happen to have done coding themselves.

#4981845 how to unlearn a language

Posted by alnite on 19 September 2012 - 04:05 PM

You want to step away from tutorials at this point. You need reasons why writing clean code is better than messy code. At this point, your brain can't tell the difference, and likely won't make a change unless you are running into situations where clean code is preferable than messy code.

1. Read your own code from a few months back. If you can still read it and understand it, you are in the right direction.
2. Work on a small app or game, and try to make it bug free. It's the hardest thing, and that's where your messy code will hurt you the most.
3. Then try reuse that code you wrote. Are they reusable? Is it easy to reuse them, do you have to strip off a lot of dependencies for using just one small chunk?

Repeat this process infinitely, your code will get cleaner and better, and less buggy.

#4980227 Asynchronous I/O vs resource loading thread.

Posted by alnite on 14 September 2012 - 05:55 PM

Yeah, I was thinking mostly in the context of a Skyrim type of game with open world exploration.

Then it'd be best to use an I/O thread.

Otherwise, you'd see hiccups when you hit certain boundaries in the game. You can see that a lot in older games from the 80s.

#4979501 Threads and c++?

Posted by alnite on 12 September 2012 - 04:49 PM

Both responses where very very helpful. in fact i have experienced this problem with I/O when trying to load geometry. the process of loading geometry hangs up the entire program and the more complex the geometry the longer the wait. So from what i understand threading would allow me to load geometry on the side of my program with out halting the main thread? I am assuming it would still take time but it would not stop one from continuing interaction with the main program being run by the main thread?

Yes. Although it sounds very simple, you would need to design your multi-threaded app very carefully. You now have multiple lines of code running concurrently, which thread access which lines first cannot be controlled. This could introduce a slew of bugs that are hard to debug.

A good practice is to keep the code separated between threads. For example, I/O code only accessible by I/O threads.

#4970776 Anybody develop (or interested in developing) games using SVG, Scalable Vecto...

Posted by alnite on 18 August 2012 - 02:56 AM

PnZjerry, I don't think you understand game development. Your tools is great, but hardly usable for game development. "knock out 50% of your time", "how SVG can increase productivity and interaction with the users" are some pretty wild marketing claims!

There have been vector-art games out there since 1980s, and just the fact it's vector art does not make it easier to develop, or "increase interactions with users."

Btw, judging from your web design, it looks like you haven't been on the web since 1990, there's this thing called Flash games. Look it up. The majority of the games there uses vector art.

#4964644 Vector memory and Binary files!

Posted by alnite on 30 July 2012 - 05:04 PM

You should try saving integers to a binary file using std::ofstream. Then, try adding strings, and see if you can read them back from the file you just saved using std::ifstream.

Once you are successful at that, you should get an idea how to write/read the primitive data types to/from files. Classes are composed of primitives, so saving a class is just a matter of saving and reading primitives in a particular format.

#4961132 Java vs C# - Experts points of view

Posted by alnite on 19 July 2012 - 07:54 PM

Many IDEs and command line tools I use daily are based on Eclipse (which runs on Java). With large projects, you always run into the default memory limit. You google the error and go change the command line settings or config file to manually specify a larger memory limit.

Eclipse is a crappy IDE. I still have no idea why a lot of people are supporting and using it, as if it's the only Java IDE. I open my project, Eclipse complains 100+ errors. Close project. Close Eclipse. Reopen Eclipse. Reopen project. Errors are gone! wtf?

I have been using IntelliJ, personally and professionally, and I couldn't be any more happier. Intuitive shortcuts (i.e. Ctrl + / to toggle comments!), great refactoring tools, syntax highlighter, seamless versioning integration, even more than what Visual Studio comes with. It has the free community edition too.

#4960624 Java vs C# - Experts points of view

Posted by alnite on 18 July 2012 - 01:56 PM

I think it was a bad analogy, I'd look at it more like tools in general, a carpenter won't use a hammer to divide a board in 2 parts, he'll use the saw (And if you see a carpenter trying to bang a nail in with a saw, well... either he is a programmer who thinks one tool is all you need or he is insane)

I thought of using that analogy, but I think it's slightly inaccurate. You can't properly cut a board with a hammer, but any programming language can be used to make almost all sorts of applications. Both Java and C# can be used to make games. They both can accomplish the same thing. So I avoid using the tools analogy, as I don't want to imply that different languages are used for different things. Other programming languages might fall into that category, such as Ruby/PHP/Javascript for web development, but at least, not these two.