Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 19 Aug 2002
Offline Last Active Yesterday, 11:52 PM

#5286527 C++ Rotating 2D shape in list

Posted by Nypyren on 12 April 2016 - 03:28 PM

It still has problems. I don't think I should provide any more hints - you should be able to solve this, but the code you're writing indicates that you don't understand some pretty fundamental things about the programming and debugging process.

Read the code that you have written, line by line, think about what it does. Think about what is going into each variable, and how it's being used. ESPECIALLY consider how each line of code will affect the OTHER lines of code that are going to execute later.

Compare this with what you think it should be doing. If you don't know what it should be doing, that's what you need to figure out first. Just copy/pasting code in different arrangements and saying it doesn't work is not how programming works.

You should step through it line-by-line in a debugger, watch what it's doing, and see where it isn't doing what you expect it to do.

#5286498 C++ Rotating 2D shape in list

Posted by Nypyren on 12 April 2016 - 11:27 AM

Your x and y variables are set in the wrong place: they use the position of ONE vertex instead of the loop vertex. So you're doing the same calculation for every vertex.

#5286427 Declaration of structures

Posted by Nypyren on 12 April 2016 - 12:48 AM

Now... are you talking about defining a structure inside a structure? If so I wasn't even aware that was a legal action.

It's allowed. I haven't seen it in real code yet, though...

I don't know of anything Mono or Unity specific regarding structs that differs from the usual .Net, either (besides internal implementation details, of course).

#5286347 Declaration of structures

Posted by Nypyren on 11 April 2016 - 01:02 PM

I'm going to take a wild guess that you're trying to use an array of structs as a member of a MonoBehaviour or ScriptableObject.

If that's the case, you need to put the 'Serializable' attribute on your structs for them to appear in Unity's inspector and get serialized to asset files:

[Serializable] // using System;
public struct SimpleStruct
    public int Foo;
    public int Bar;

public struct StructOfArrayOfStructs
    public SimpleStruct[] Elements;

#5286335 Declaration of structures

Posted by Nypyren on 11 April 2016 - 11:55 AM

public struct SimpleStruct
    public int Foo;
    public int Bar;

public struct StructOfArrayOfStructs
    public SimpleStruct[] Elements;
When you say "Doesn't appear to work for Unity", EXACTLY what do you mean?

#5285877 Is it good practice for game development to learn multiple languages?

Posted by Nypyren on 08 April 2016 - 12:57 PM

Learning a new language can be fun; occasionally you will find something neat that gives you a new idea of how you can solve a problem in other languages you already know.

As far as good/bad practices go, it's hard to know at first. Eventually you'll start to get some insight about what's good and what's bad after using different things yourself, and participating in discussions about particular ways of doing things. For now I suggest to just keep doing whatever works, and if you start running into headaches, try to find out if you're doing something wrong at that point. Usually it's not too hard to go back and fix mistakes. Most of our programming time is spent trying to decide how to do something in the first place. It's pretty easy to take a solved problem and implement it differently.

Sometimes when something feels hard to use, it's because the way it is meant to be used is different from how you're trying to use it (if you see people say "idiomatic", that basically means "the way we usually do it in this language/library"). I usually try looking for complex samples that demonstrate how things are supposed to be used. This kind of thing bit me hard when moving from WinForms to WPF.

I haven't used SFML. Last time I used allegro was during the DOS era, so I'm not sure what it's up to lately.

#5285702 Keyboard input Windows

Posted by Nypyren on 07 April 2016 - 09:23 PM

Don't clear your list between frames. Remove keys when you get the WM_KEYUP or when your application loses focus. Ignore redundant WM_KEYDOWN if your list already contains that key (you can use an flag array rather than a literal "list" that you add/remove from). Keyboard auto-repeat will only ever repeat the last key you started holding down.

#5285696 Typing skills

Posted by Nypyren on 07 April 2016 - 09:12 PM

As programmers, any time we encounter situations where we're actually limited by typing (curse my meat digits!), we invent systems to automate the process (macros, code generators, auto-complete).

#5285521 I am beginning to hate the IT and gaming industry (Part 2)

Posted by Nypyren on 06 April 2016 - 07:52 PM

...I'm trying to find out what I'm doing wrong...

We need to know what your interviewers, coworkers, and managers see when they see you.

Things that go through the employer's mind in rough order of precedence:

- Need: Are your skills/knowledge something the company requires?
- Investment: Are your skills worth what the employer pays you?
- Competitive Ability: How does your motivation, speed, and correctness compare to others?
- Competitive Knowledge: How does your domain-specific knowledge compare to others?
- Team Fit: How well do you communicate? Do you get along well with others?

Good companies will try to give employees periodic reviews to let them know which areas they think need improved. Interviewees almost never get this kind of feedback, though.

How have your periodic reviews gone? I don't recall seeing you ever mention them.

#5285453 If statements are all you need

Posted by Nypyren on 06 April 2016 - 11:24 AM

At first I thought it would just be if statements instead of other control flow techniques. But no, it's much worse than that.

if (printHPMax - 90 >= 0)
    hpTen = 9;
else if (printHPMax - 80 >= 0)
    hpTen = 8;
else if (printHPMax - 70 >= 0)
    hpTen = 7;
else if (printHPMax - 60 >= 0)
    hpTen = 6;
else if (printHPMax - 50 >= 0)
    hpTen = 5;
else if (printHPMax - 40 >= 0)
    hpTen = 4;
else if (printHPMax - 30 >= 0)
    hpTen = 3;
else if (printHPMax - 20 >= 0)
    hpTen = 2;
else if (printHPMax - 10 >= 0)
    hpTen = 1;
else if (printHPMax - 10 < 0)
    hpTen = 0;

#5285098 Currently perusing a Computer Science degree, but I think I may be on the wro...

Posted by Nypyren on 04 April 2016 - 02:38 PM

I find that I am very bored/uninterested in my programming courses. I only really care about programming games but not so much anything else. I feel as though the Computer Science BS is not for me and I'm not sure where to turn. Just wanted to put this out there and get some thoughts.

That's just how programming is; mostly boring with very few naturally interesting parts. It's a kind of masochism; you have to embrace the boring stuff in order to MAKE it interesting.

#5284647 Dealing with unstable contractors?

Posted by Nypyren on 01 April 2016 - 02:18 PM

Based on the text, the other person is not a native English speaker, and is using machine translation to write their response. You probably had a breakdown in understanding due to this.

Forget unstable attitude; I wouldn't work with someone who can't clearly communicate.

#5283812 When you realize how dumb a bug is...

Posted by Nypyren on 28 March 2016 - 01:05 AM

Unhandled exception at memory location 0x000000c

Always first assume any small memory addresses (even if they aren't exactly zero), are due to (null)->member. :)

#5282546 GIT vs Mercurial

Posted by Nypyren on 22 March 2016 - 01:20 AM

I've never used Perforce. Based on some quick looking it doesn't seem to provide significant benefit over Subversion. Is merging branches better or something?

- It doesn't create .svn folders everywhere.
- It's more robust and is easier to figure out what to do when something unexpected occurs.
- Client specs are awesome.

- Kind of a pain to use for personal projects with remote backups compared to git or svn. With git, there isn't really a server so much as remote locations you can push to if you want. SVN has various online hosting services. I don't know if there are any free private cloud services for Perforce due to its license. I haven't used Perforce in about 5 years, so something could be out there by now.

#5282507 GIT vs Mercurial

Posted by Nypyren on 21 March 2016 - 08:49 PM

I prefer:

Centralized: Perforce over Subversion.
Distributed: Git over Hg.

The Git learning curve is absolutely terrible, though. I've been using it for four years and there's still things I run into that make me say "what the hell, git?" Git lets you shoot yourself in the foot with almost every single command, and overloads commands seemingly for no reason other than to make it easy to accidentally pick the wrong use of that command. Try to avoid the CLI at all costs and do things in a good GUI.

The third-party GUIs in order from best to worst: TortoiseGit, Visual Studio 2015's integrated Git interface, SourceTree, and way behind everyone else: SmartGit.

My only real, technical complaints about Git are: submodules and large files need some major reworking. Submodules COULD be handled much more conveniently than they are and would make my life much easier. Large files are common in games and without mitigation strategies like recreating a new repo every year, you end up with 30 gig repos for a 500 meg game.