SadisticPenguin

- friends
1,834 link karma
1,962 comment karma
send messageredditor for
what's this?

TROPHY CASE

reddit is a source for what's new and popular online. vote on links that you like or dislike and help decide what's popular, or submit your own!

Question regarding C++ by Symphonymin learnprogramming

[–]SadisticPenguin 0 points1 point ago

Instead of keeping a count variable, you can also just use myInt.size(). The vector keeps track of the size for you.

Hey r/Touhou, I'm making a platformer featuring Chen! by SadisticPenguinin touhou

[–]SadisticPenguin[S] 2 points3 points ago

I would but the class Diagram thing from VS2010 gets mad at me because it's too large, I think. The project is currently 124 files, but that includes files for some other projects (the same base engine was used for First, and another game unreleased.) It also has a ton of template library stuff, since for my own projects I try to rewrite things from boost myself to learn how they working instead of using them directly (I love reinventing the wheel!)

There's two parts to the graphics engine, a scene graph mainly for keeping things together in space, and then a graphics engine that manages layers and binning by style to minimize thrashing on the GPU. I'm trying to keep the requirements low so that it'll run on netbooks, but I have classes that will do lighting and such quickly on CPU with no shaders.

The physics engine provides an abstract base class, PhysicsObject, which you can derive from. You can then implement a few methods for collision detection and set the shape of the collision object (the game uses swept collision detection, raycasting against minkowski sums.) I'm much more comfortable in graphics, so this has been a challenge, but it seems to finally be working pretty well.

In terms of the game, I'm trying a polymorphic approach there too - a base actor class, a level is full of actors, everything directly visible inherits from actor. I've tried complex message passing systems before, but making interface classes in C++ seems easier and faster.

For characters, I have a CharacterController class that has a finite state machine to handle different cases (unit is attacking, unit is recovering from getting hit, on ground, in air, etc.) You can then pretty easily plug a user controlled character or AI character into that, but I'm trying to make sure that you have a lot of control there too.

So, err, that scratches the surface.

Hey r/Touhou, I'm making a platformer featuring Chen! by SadisticPenguinin touhou

[–]SadisticPenguin[S] 2 points3 points ago

C++. It's using my own graphics and physics engines.

“How much math do I need to know to program?” Not That Much, Actually. (with a D&D combat sim example in Python) by AlSweigartin learnprogramming

[–]SadisticPenguin 1 point2 points ago

I'm a bit biased, since I work on engines and professional work on CAD tools but it's frustrating to see this. You can get away with very little, but if you want to innovate, you should learn. With games I've seen people grapple with shaders due to not knowing the technicalities of how 3D graphics work, misunderstandings of floating point numbers, not to even mention the myriad data structure abuses. Maybe you can get away with some applications without knowing the details, but ignorance is not a virtue.

[c++] Calling delete before the program exits? by geartriggerin learnprogramming

[–]SadisticPenguin 5 points6 points ago

If you use RAII techniques you should rarely have to manually track memory and call delete explicitly, that's the answer I'd go with.

[c++] Any idea why my interfaces aren't working? by bambam93in learnprogramming

[–]SadisticPenguin 1 point2 points ago

How are you casting? You should be using static_cast.

What are some Applications to the field of Computational Geometry? by newgradq1in compsci

[–]SadisticPenguin 7 points8 points ago

Anyone working with CAD tools could almost certainly use better tools to do operations on huge sets of geometry faster while retaining accuracy. If you have impressive work in that field, then I'm sure someone will be interested.

Touhou Achievements? by Sinful_Malicein touhou

[–]SadisticPenguin 2 points3 points ago

I love ReimuB for the shotgunning, you can do more damage than MarisaA if you get right up next to enemies. With Flan you can end some attacks very quickly this way, but MarisaA does constant damage from the bottom of the screen.

Touhou Achievements? by Sinful_Malicein touhou

[–]SadisticPenguin 10 points11 points ago

Whoa, people actually recognize me.

My first 1CC was actually EoSD, with MarisaB Masterspark spam. I then graduated to SakuyaB private square spam, it took me a long time to actually come back and beat Flan. I actually beat Ran, then Yukari, then Mokou then Flan, and Maze of Love always gave me trouble as well! I was so scared of that card that I thought it would make Flan impossible to pacifist, but by the time I got around to trying it I guess my control got better or something.

Touhou Achievements? by Sinful_Malicein touhou

[–]SadisticPenguin 13 points14 points ago

Timing out Saigyouji Flawless Nirvana, No-Death Flandre, and Pacifist Mokou probably are my top 3. After each of those I could hardly breathe.

Question about operator overloading, C++ (homework help) by smeltanddealtin learnprogramming

[–]SadisticPenguin 0 points1 point ago

bool operator < (Person p) const;                

should probably be

bool operator < (const Person& p) const;  

to avoid a whole ton of unnecessary copies. (I know you can't edit this for your assignment, but you'd get lynched in the real world.)

Also, a neat fact - from operator <, you can derive every other comparison operator.

I have a moderate background in C++. Should I start with Qt or .NET framework? Or what else? by spvnin learnprogramming

[–]SadisticPenguin 0 points1 point ago

It depends on the application, such as whether this is for a game or not. Also winforms and such is migrating with Windows 8 through WinRT and metro, so you might want to consider sticking with native since it seems that things are heading back around that way. You might also want to do native if you're doing scientific computing, or otherwise for some reason need to be close-to-the-metal.

To get something up and running and out tomorrow, .NET right now is a good choice.

Roll your own autocomplete solution in a few lines using Tries. by v1v3knin programming

[–]SadisticPenguin 1 point2 points ago

Tries need more love. They're tricky, but it's pretty awesome when you see stuff like Judy arrays.

Shifting Elements of an Array in C? by thisisnotabusin learnprogramming

[–]SadisticPenguin 0 points1 point ago

Ah, right you are, oops.

Shifting Elements of an Array in C? by thisisnotabusin learnprogramming

[–]SadisticPenguin -1 points0 points ago

given that you are using C, this would just work using memmove.

That is -

int somecrap[10];
int i;
for (i = 0; i < 7; ++i) somecrap[i] = i;
memmove(somecrap+3, somecrap, sizeof(int)*7); //memmove works with overlapping bounds.

And you're done (and likely using an ASM optimization, like memcpy, memset, etc.)

edit: this doesn't clear out the original values though, but that should be easy enough to do with a memset or something if you want to clear them to 0 or some other default.

What course in college turned out to be the most useful for your computer science career? by incomodo_a_la_gentein compsci

[–]SadisticPenguin 0 points1 point ago

Well, I went to Digipen (a game programming school), and so I'd say the game classes where you had two semesters to make a full game. The thing that always ended up fueling my research and programming ability was making games that pushed the bleeding edge of my skills, since I'd always have to go and hit the books.

How I feel as a young voter educating myself on politics in the US. by irate-turtlesin funny

[–]SadisticPenguin 4 points5 points ago

Sorry Kevin, no karma for you.

Fopen C++ Question. Working with binary data. by grimlock123in learnprogramming

[–]SadisticPenguin 0 points1 point ago

because that is doing floating point math, not integer math. It's therefore transformed from the raw bytes into a floating point representation, but you want the actual raw bytes.

using a union should work -

float charsToFloat(unsigned char c1, unsigned char c2, unsigned char c3, unsigned char c4)
{
  //unions store variables in the same memory...
  union { unsigned int i; float f;} converter;
  converter.i = (c1) + (c2 << 8) + (c3 << 16) + (c4 << 24);
  return converter.f;  //so this has the bytes from the chars in it.
}

Fopen C++ Question. Working with binary data. by grimlock123in learnprogramming

[–]SadisticPenguin 2 points3 points ago

Or just declare buffer as int*.

Fopen C++ Question. Working with binary data. by grimlock123in learnprogramming

[–]SadisticPenguin 1 point2 points ago

In this case you could actually simply make buffer an int* instead of a char* and it'll work perfectly.

If you want to combine chars into an int explicitly, do something like

int charsToInt(unsigned char c1, unsigned char c2, unsigned char c3, unsigned char c4)
{
  //a left shift by 8 means offset by one byte.  Whether or not the shifts should be big to small (big endian) or small to big (little endian)
  //is system defined, but most likely you're working with little.
  return (c1) + (c2 << 8) + (c3 << 16) + (c4 << 24);
}

but it isn't required here, since the ints are written out correctly, so you don't need to "rebuild" anything here.

Fopen C++ Question. Working with binary data. by grimlock123in learnprogramming

[–]SadisticPenguin 0 points1 point ago

Nope, since he's writing out the actual binary integers.

I am so sick of reading "I learned to code in a month" blog posts by pninifyin learnprogramming

[–]SadisticPenguin 0 points1 point ago

I've been programming C++ for 8 years and I still learn subtle things about it, and if you want to talk about idioms and best practices then you're going to be learning the hard way - forever.

view more: next