Jump to content

  • Log In with Google      Sign In   
  • Create Account

Khatharr

Member Since 24 Apr 2010
Offline Last Active Private

Posts I've Made

In Topic: Style preferences in for loop structure

26 August 2016 - 08:51 PM

[

if (condition == true)
...
if (condition == false)
vs.
if (condition)
...
if (! condition)
Back in my unexperienced days, I would use the latter because all the cool kids were doing it :cool:, but I'm find myself using the first form a lot more to make it easier to read. The more I code, it seems the more I work towards readability.

 

That suggests that you're naming your variables poorly. A properly written if() should read similarly to English:

if(dude.isAbiding()) { ... } //"if dude is abiding" ...

if(!moving) { ... } //"if not moving" ...

In Topic: Style preferences in for loop structure

25 August 2016 - 05:56 PM

for(int i = 0; i < MAX; i ++) {
  if(someExemptionFromWhatFollows) { continue; }
  
  if(someCondition) {
      foo();
      bar();
  }
}

In Topic: Enums and their extendability via mods

25 August 2016 - 05:53 PM

Half-decent hashing can significantly reduce the performance impact of using strings.

 

What you're describing is something that scripting languages are really specifically designed for though. Be careful not to spend months working on patchwork solutions and then decide to embed an interpreter and end up throwing all that work away.


In Topic: Player follow as seen in Donkey Kong Country 2

25 August 2016 - 05:45 PM

Looks like it's got a few techniques that it's delegating to based on distance from the player character. If it's too close it backs away slowly, if it's slightly too far then it plays back recorded player positions, if it's significantly far then it just approaches the player as quickly as possible.


In Topic: Handling Mouse Movement

24 August 2016 - 12:27 AM

If you're using system mouse coords then I believe you can just avoid the whole thing by simply changing the cursor image when you set up the window. Clip the mouse if you need to, then just query its position whenever it's relevant.
 
Refer to:
WNDCLASS::hCursor 
 
GetCursorPos()
 
ScreenToClient()

and ClipCursor(), which Frob mentioned earlier.

 

Deltas are more useful when you're doing something like a first-person shooter, where you're interested in motion rather than position.


PARTNERS