Jump to content

  • Log In with Google      Sign In   
  • Create Account

Khatharr

Member Since 24 Apr 2010
Offline Last Active Private

#5298664 Draw rectangle Directx 12

Posted by Khatharr on 30 June 2016 - 03:09 PM

DX12 is intended for high-investment/high-performance programming. It's is alternative to DX11 rather than a replacement. Don't make the mistake of thinking that DX12 will give you better performance out of the box; you have to understand what's going on very well in order to make the kinds of changes required to see any improvement. If you're still at this stage of the game then just use DX11 until you have a strong understanding of the pipeline and process. Otherwise you'll spend a lot of extra time just to end up with a slower program.




#5298481 Seeding the random number generator in <cstdlib>

Posted by Khatharr on 28 June 2016 - 07:12 PM

Example of C++ <random>

#include <random>

int main() {
  //create a mersenne twister and seed it with a value from 'random device'
  //mersenne twister is good quality and decent speed. random device is low performance,
  //but delivers the best randomness the system can provide and doesn't need a seed
  //this creates the mt object, which is able to generate unshaped random values
  std::mt19937 rng(std::random_device{}());

  //but we're usually looking for numbers within some specific range, and that's easy to
  //screw up, so instead of just using the random bits indiscriminately we use a
  //distribution object to get exactly what we're after. For example, ints between 0 and 10
  std::uniform_int_distribution<int> zero_to_ten_dist(0,10);

  //then to get an int from it we just say:
  int my_num = zero_to_ten_dist(rng);

  //or if you want a float between zero and one instead
  std::uniform_real_distribution<float> normalized_float_dist(0.0f, 1.0f); //note that distribution ranges are inclusive
  
  //used the same way
  float my_float = normalized_float_dist(rng);

  //or what if we want true/false with 60% probability of true?
  std::bernoulli_distribution sixty_percent_dist(0.6);

  //used the same way
  bool my_bool = sixty_percent_dist(rng);
  
}

Of course some of the names used are confusing, but you don't actually need to memorize those. Once you include <random> your intellisense (or whatever you're using) should be able to find the mersenne twister just from "std::mt", and you'll usually want uniform int or real distributions. For the other stuff you can just look at the list of distributions on cppreference or cplusplus and see which one does what you're after. You can (and should) use the same generator object on a per-thread basis unless you have a good reason not to. The distributions are cheap to construct or move around, but the generators are not.

 

Someone will probably criticize the mersenne twister in here very soon, but in all honesty it can crap out a huge amount of quality randomness in a very short period of time, so I'd recommend putting some science on it (actually measure it) before getting complicated about things. That said, there are a number of other generators in the library, and they're described in the websites mentioned, so it's your call.

 

here's a link to the video I always link to




#5298142 The latest BMP I made crashes the program, other BMPs work fine

Posted by Khatharr on 26 June 2016 - 01:57 PM

Is it better to use a PNG?

 

Yes, but that's not what's causing your error.




#5297653 algorithmicly connecting a graph

Posted by Khatharr on 22 June 2016 - 08:35 PM

Only create edges in the ne,e,se,s directions as you iterate?

 

Though really I'd have to agree that one-way edges is probably better for usage, since you generally want to know what outbound edges are available for a specific node. If your edges are of uniform weight you can even just represent them as a vector of destination node pointers within each node.




#5296884 Problem on referencing a vector of derived class

Posted by Khatharr on 16 June 2016 - 08:11 PM

This appears to be a misuse of inheritance. (refer to https://en.wikipedia.org/wiki/Liskov_substitution_principle) Generally you should be avoiding this type of cast and use dynamic_cast when it's unavoidable (this may be one of those cases). Trying to cast the vector itself is really not a good plan.

 

Could you explain more about what you're using this for? There may be a better pattern for this.




#5296241 Major selling games and language types

Posted by Khatharr on 12 June 2016 - 12:51 PM

The first languages I learned were GWBASIC and Pascal. Years later I learned Visual Basic. Then a while later I learned C. Fast forward another couple years and I learned Ruby, then C++, then Lua, then a glance at Lisp... Then a ton of miscellaneous nonsense. At some point during that, learning new languages was pretty much a non-event. It's a lot more important to me what tools I have available and have something that matches up well with what I want to accomplish. These days that usually means Ruby for trivial tasks, C++ for not being a scrub (come at me), and C# for Windows tools or for working in Unity.

 

Anyway, my point is that I don't use the vast majority of languages that I've learned over the years, and it was over a decade from my starting point before I learned the ones that I use commonly today. However, all that I have learned up until now depends on the principles that I picked up with every language along the way. My advice is to find something that you're comfortable with and can accomplish something with, even if it's not where you want to end up. Get good at something and then expand your comfort zone at a decent pace.

 

Some people can leap headlong into C++ and succeed. Some people struggle to learn HTML. Software really is a moving target, so it's not really about getting where you want to be as much as it's about getting moving at the right speed and figuring out where you want to go from there.




#5296146 whats the "Big O" of this algo?

Posted by Khatharr on 11 June 2016 - 06:01 PM

Big-O is one of those things that can be harmful if you try to pick it up by hearsay. Study it out and check to ensure your understanding.

CAUTION: BIG-O IS NOT A MEASURE OF PERFORMANCE!

It's a measure of how a thing scales. Even for a massive dataset a particular O(n^2) algorithm can be infinitely faster than an O(1) algorithm. Be careful.


#5295525 responsiveness of main game loop designs

Posted by Khatharr on 07 June 2016 - 02:38 PM

someone here or on another recent thread was mentioning button presses on the order of 10ms. at 60Hz, you'd poll every 16.6ms. and polling would take less than 1ms most likely. so you could poll at t0=0ms, finish polling at t1= 1ms, press the button at t2 = 1.5ms, release at t3=11.5 ms, and the next poll occurs at t4=16.6ms. and just like that you missed an input entirely.

 

Yeah, science sucks, lol.




#5295432 C# and Unity for 2D Side Scroller

Posted by Khatharr on 07 June 2016 - 12:36 AM

Not having to learn a made up ecmascript variant is a start. The d-n-d editor is a joke if you plan to make anything more complicated than a dead-simple platformer. GM is terribad for working in teams as well, whereas Unity has settings that make it play nice with version control. Unity has nice tools for automating animation via state machines, good physics and collision that can be fine-tuned as you desire, and works with external editors so you can code in your own environment. The component-styled UI is powerful, and the way it exposes public script members so they can be edited from the UI - even during debugging - is great. The canvas system is more powerful for making and tweaking in-game menus and HUD elements. Unity supports custom shaders without tomfoolery. Both support a kind of object hierarchy, but Unity's is similar to a scene graph, which ends up being much more convenient.

 

Unity also has never decided to simply disable previous PAID versions of their software, leaving people stranded and unable to continue their work unless they upgrade to the new version and deal with the massive slew of breaking changes involved in that process.

 

GM can be used as a tool for people that are code-phobic so that they can overcome that phobia, and it's decent for prototyping, but for serious projects I'm just picturing hours upon hours of opportunity cost.




#5295422 C# and Unity for 2D Side Scroller

Posted by Khatharr on 06 June 2016 - 10:26 PM

?

Unity is overwhelmingly superior to GM in my opinion. You have more to learn with Unity, but that's only because much more is made available to you.

Additionally, Unity's tutorials are more comprehensive.

I am curious about why OP had trouble rendering in 2D though. Were you trying to use GDI or something? If so then maybe take a look at Monogame as well.


#5295344 responsiveness of main game loop designs

Posted by Khatharr on 06 June 2016 - 02:06 PM

Hey, let's do some science. Set up a simple input system that polls at 60hz alongside an input system that simply logs all input state changes as they occur, then see if you can press and release a key fast enough to miss the polling.




#5295059 Ball passing through gap between blocks

Posted by Khatharr on 05 June 2016 - 05:23 AM

Since you're only checking against AABBs, create an AABB that encloses the start and end positions of the ball for your dt. Every brick intersected by that is a candidate. That's your broad phase.

Calculate the time of impact (use FLOAT_MAX for misses) for each block, then pick the one with the lowest time.

Once you find that you advance the ball to that point in time, apply the effects of the impact, then integrate again with the remaining dt, doing however many impacts are necessary until the dt is consumed.


#5294934 What is the output?

Posted by Khatharr on 04 June 2016 - 06:06 AM

TRIGGERED


#5294824 [DirectInput] Get gamepad button name

Posted by Khatharr on 03 June 2016 - 12:19 PM

but is it really common to show gamepad bindings as "Button0"-"ButtonX"?


Yes, apart from XInput it's usually just numbered buttons. It's not hard for the user to figure out during key mapping. If you push a button and it says "Button 1" then chances are you're pushing button 1. There's really no standard to these things, so trying to predict what's what will only piss off the people that you guessed wrong for.

 

If you're interested in a specific controller then you can just have an option to label the buttons for that controller specifically. For example, some XInput games have an option for "Dualshock 3" that changes the XBox button labels to their SCP Driver equivalents. (Usually it's just a matter of loading a different texture for the button images.)




#5294709 [DirectInput] Get gamepad button name

Posted by Khatharr on 02 June 2016 - 04:00 PM

'Fraid not. One of the reasons DInput was deprecated is that gamepads and other HIDs are not standardized. If you're concerned about this kind of conflict the best thing to do is to offer custom key-binding support to the user. If you're exclusively concerned with gamepads then consider using XInput instead, as it has become something of a de-facto standard for gamepads on Windows.






PARTNERS