Jump to content

  • Log In with Google      Sign In   
  • Create Account

Servant of the Lord

Member Since 24 Sep 2005
Offline Last Active Yesterday, 11:58 PM

#5308418 defend sacred animals quest

Posted by on 28 August 2016 - 08:54 PM

Or let the player kill everything and everyone for no reason.


Don't forget to eat the hearts to gain their courage. Their rich tasty courage.

#5308270 Tactics RPGs with an actual "game" (world exploration, etc)?

Posted by on 27 August 2016 - 03:35 PM

Have you tried Final Fantasy Tactics for the PS1?

(There were some other installments for the GBA, but the story was supposedly less interesting)

#5307518 Would You Like Fires With That? (Business Logic)

Posted by on 23 August 2016 - 09:18 PM

If one is relying on a small number of videos, that's probably true (Wasn't it $6 per 1,000 views?), but a skilled composer should not have to rely on a small number of videos.  In addition to ad revenue, YouTube has a donation feature integrated into their site.

A quick google suggests X per 1000 ad views (varies depending on ad demand, but the number I saw was $7.60), and the ads aren't shown for every actual view. And that's before YouTube takes between 30% and 45% (and before your YouTube Partner network's cut). Also depends on how much viewers engage with the ads, which I imagine would be quite less with music (because they'd run it in a different tab while doing other things).


People with millions of subscribers (not views, full subscribers) pushing out four or five videos a week that constantly hit million views or more, even with branding deals and referral fees, still aren't making livable wages and often need to work jobs on the side.

When I want to listen to a composer's work, I'm looking for specific songs. The *one* song out of the 20 or 30 in the game. Unless you made the soundtrack to Chrono Cross or Symphony of the Night, there's no way I'm going to listen to the entire soundtrack, even if the game itself was extremely popular.

I bought some music off Amazon about a month ago. Notice the lack of entire game soundtracks:


I'm not an audio person - I bought these for the purposes of adding to my game design folders. And I'm the abnormality, in that many consumers would've just pirated them. And I've rarely bought this much music before in my life (again, not being an audio person), so it was an almost one-off occurrence.

In many games, I don't care about any of the music in the game enough to pay for it. I'm sure similar applies to other people who listen to music on YouTube. What are they even supposed to google for, "Song that played during level with the tower in Game Y"?

If you made One Wing Angel, it might bring in some ad revenue (ignoring the 200 YouTubers who'll post your music on their own channel giving you no revenue). But even then, for one of the most popular videogames of all time, that's pretty much the only song people remember. Sure, they'll recognize the tune of the others if they listen to them, but they won't go out of their way to listen, and you'll get virtually no ad hits for them.

Bands do a bit better. They have a popular song and then people say, "Hey, I like this band." and check out the other songs. Much much less so with games, I'd guess.

All of Halo's soundtrack might as well only be Rock Anthem to Save the World. The average fan doesn't remember anything else, and the average consumer doesn't even remember the name of that one.

#5307304 Errors that effect a computer's system.

Posted by on 22 August 2016 - 07:17 PM

Depends on the hardware and operating system. Since you mentioned DirectX, I'm assuming you're using a Windows OS.


In modern OSes like Windows, the RAM is sandboxed (i.e. protected), so dangling pointers and etc... are unlikely to cause permanent damage.


Yes, it's possible to permanently damage pieces of a computer, but it's so very very very very very very unlikely, that it's not worth any of your time to even consider worrying about.


You're much more likely to mess up your operating system by deleting the wrong files in Windows Explorer than you are by using code.


It's unlikely you'll even crash your computer (crash your program? Sure! The entire OS? Rarely), and when you do (likely from crashing your videocard), your computer will almost certainly boot back up just fine.


Again, it is possible, but so unlikely as to not be worth your time (as a beginner) worrying about.

#5307234 C++ Librarys - When to use .lib vs including .h/.cpp

Posted by on 22 August 2016 - 11:04 AM

Most source bases need to be configured for each build target, so a library has that already done. When build process is somewhat complex you always prefer a pre-build binary. Of course if you do not have the pre-build binary for your compiler/operative system you go nowhere, while with source code you can always compile and eventually fix compilation problems "on the fly".


I don't prefer pre-built binaries. I've had too many time-consuming bugs from the libraries being built with different build targets and compiler settings than the executables. Now I just by default want to build everything from source, because it makes my life simpler.

#5307111 IFSTREAM: take coordinate from file and convert 3 digit coordinate into integer

Posted by on 21 August 2016 - 09:47 PM

What's the deal with that? I thought c++ could convert a string really easily. Do I need to use pointers, and go indirectly?


The compiler told you what the deal was:  :wink:

cannot convert 'std::string {aka std::basic_string<char>}' to 'const char*' for argument '1' to 'int atoi(const char*)'|

Error messages are sometimes worded pretty stupidly, so you have to get the hang of reading them.


Basically, the message is saying this:

For the 1st argument of 'int atoi(const char*), we cannot convert 'std::string' to the required 'const char*'.

atoi() expects a C-style string (const char*), not a std::string. calling c_str() on your std::string, will return access to it as a C-style string.


Or you could use std::stoi() instead, which takes a std::string directly. Read atoi as 'char-array to int'. Read stoi as 'string to int'.


Note: std::stoi() is part of C++11 and later, so you'll need to have that enabled on your compiler, if it's not enabled by default.

#5307100 Win loop errors

Posted by on 21 August 2016 - 06:33 PM

Your idea of using an int instead of a bool worked wonderfully and I was able to cut out a several lines of code that ended up being unnecessary.  Thank you so much for the suggestion!


It'd be better to use an enum for that:

enum class Winner {Nobody, PlayerOne, PlayerTwo};
Winner winner = Winner::Nobody;

The reason is because you are assigning hidden meaning to each value, and it'd be good to be explicit about what those meanings are, especially because you use those same values (with the same meaning) in more than one location in your code.

#5306971 Which Software?

Posted by on 20 August 2016 - 09:50 PM

Sometimes using multiple tools is required. Sometimes the choice is between a single tool that can do everything poorly, or separate tools that do one thing and do it well.


For myself, I use PaintShopPro (it costs money, but nowhere near Photoshop's cost) and I also use MSPaint, often with both open at the same time, because they are good for different things.


Depending on the type of art you do, you might want to check out Paint.NET (which is free). And if you use a Wacom-style tablet and stylus for drawing, you might try Fire Alpaca.

#5306966 Friends living abroad have really laggy connection to me, why?(using raknet,...

Posted by on 20 August 2016 - 09:40 PM

Why would someone use UDP and write code to add TCP functionality ( right order, reliable packets ) instead of just using TCP. Of course there should be a very logical reason, and I know I'm missing something. Do you have any suggestions why this may be?  


TCP provides multiple features that are useful in different scenarios that aren't all useful to real-time software like games, and can be slower than UDP because of that.


Thus, games often take UDP and add ontop of it only the requirements they need. Even in a single game, not every packet needs the same garuntees. In the same game, some packets might need reliability. Others might need correct ordering. Some packets might need both, some might not need either.


If you continue reading that same paragraph, you'll see:

RakNet can automatically resend packets that did not arrive.
RakNet can automatically order or sequence packets that arrived out of order, and does so efficiently.

"Can" implies that it's optional:wink:


If you keep reading slightly further, it says:


RakNet does not incur overhead for features you do not use.


...which is the difference between TCP - where it costs you, regardless of whether you want that feature or not.  :)


TCP is great for many purposes, just not real-time applications with large numbers of packets going back and forth.

#5306735 Level loading causing lag/stutter

Posted by on 19 August 2016 - 09:39 AM

marked for tracking 



#5306584 C++ what is in string after std::istreambuf_iterator< char >(sourceFi...

Posted by on 18 August 2016 - 12:26 PM


Using C++-style casts, instead of dangerous C-style casts, would've also helped highlight the problem.

thanks for the reply.
can you give me an example of what you would do?

Fast code is important, but you should write clean code first. Clean code can always be made faster when needed, but fast code is harder to make clean. Clean code contains less bugs, and is easier to find the bugs when they do occur. Write clean, not fast. Clean code is often very fast anyway, and can easily be made faster when required.


std::string LoadFileAsString(const std::string &filepath, bool *successful)
	if(successful) *successful = false;

	//Open the file for reading.
	std::ifstream file(filepath.c_str(), std::ios_base::in);

		Log::Message(MSG_SOURCE("FileFunctions", Log::Severity::Error)) << "Failed to load '" << Log_HighlightCyan(GetFilenameFromPath(filepath)) << "' at " << Log_DisplayPath(filepath)
																		<< "\nDo I have sufficient privileges? Does the file even exist?" << Log::FlushStream;

		return "";

    //Read the file into the stringStream.
    std::ostringstream stringStream;
    stringStream << file.rdbuf();

    if(successful) *successful = true;
    //Convert the stringStream into a regular string.
    return stringStream.str();


std::vector<std::string> Separate(const std::string &str, char divider)
	std::vector<std::string> stringArray;

	size_t startOfSegment = 0;
	for(size_t pos = 0; pos < str.size(); pos++)
		if(str[pos] == divider)
			//Grab the past segment.
                        stringArray.push_back(str.substr(startOfSegment, (pos - startOfSegment)));

			//Mark the beginning of a new segment.
			startOfSegment = (pos + 1);

	//The final segment.
	stringArray.push_back(str.substr(startOfSegment, (str.size() - startOfSegment)));
	return stringArray;

#5306441 C++ what is in string after std::istreambuf_iterator< char >(sourceFi...

Posted by on 17 August 2016 - 06:02 PM

Using C++-style casts, instead of dangerous C-style casts, would've also helped highlight the problem.


By doing this:

return (char*) (s.c_str());

That's already an indicator that something was wrong, but the (char*) is telling the compiler to shut up and stop telling you that it's wrong.  :)

When you type (char*) or similar, you're saying, "I know you think this is wrong, Mr Compiler, but trust me - I know better than you, just do it anyway.". You disabled the safeguards. 


Or, to put it in more technical terms, you unlocked the cage and the raptor ate your face.  :P


C++-style casts are also disabling safeguards, but in a more controlled way, whereas (char*)-style casts disable every type-conversion safeguard at once.

We've all been bitten by that kind of mistake numerous times; this is the C++ learning process.  :wink:

#5306271 Level loading causing lag/stutter

Posted by on 16 August 2016 - 08:02 PM

This isn't SFML related, so SFML shouldn't be in the title of the thread. It's level-loading related, but more specifically, where you load your level.


You should not load your level every frame, you should only load your level when you reach a new level (unless you are streaming a large level, in which case the same logic applies at a different scale: You shouldn't load the same level segment every frame, you should only load a new level segment when you reach the new level segment).


Ignoring how you load your level, can you post the code that shows *where* you load you level? That is to say, can you post the entire function that calls "LoadFromFile()" and the entire function that calls that function, and the entire function that calls that function, all the way back to main()?


I need to see the complete code for the entire callstack of LoadFromFile(), because that's almost certainly where your problem is.


I heavily disagree that you should look into multithreading your program - that'd be way too much over-complication at your level.

#5305614 Is this function correct?

Posted by on 13 August 2016 - 04:14 AM

Yep, that's correct.


However, I'd write that function like this:

template<typename Element> //Templated for flexibility.
bool Exists(std::vector<Type> &container, const Type &valueToFind) //Pass the container by reference, not by pointer, unless the parameter is optional.
    for(const Element &element : container) //Range-for for speed and safety.
         if(element == valueToFind)
             return true;
    return false;

#5304891 For Loop Max Bug

Posted by on 09 August 2016 - 08:44 AM

This is part of the reason I wish C++ had syntactic sugar for implementing properties. A struct could store x, y, width, height, and then have properties for left, right, top, bottom. It would remove all the ambiguity.


My class looks basically like this:

class Rect
    Point position;
    Size size;

	//The left-most extent of the rectangle (taking its position and size into account).
	//WARNING: Right() and Bottom() is 1 *past* the end of the rectangle, just like std::vector::end() is one element past the end of the vector.
	//		   This is intentional. This means Right() = (pos.x + size.width), which is what we want.
	inline int Left()	const { return this->position.x; }
	inline int Right()	const { return (this->position.x + this->size.width); }
	inline int Top()	const { return this->position.y; }
	inline int Bottom()	const { return (this->position.y + this->size.height); }

	//The corners of the rectangle (taking its position and size into account).
	//WARNING: BottomRight() is 1 *past* the end of the rectangle, just like std::vector::end() is one element past the end of the vector.
	//		   This is intentional. This means BottomLeft() = (pos + size), which is what we want.
	Point TopLeft() const;
	Point TopRight() const;
	Point BottomLeft() const;
	Point BottomRight() const;

	//The center of the sides of the rectangle (taking its position and size into account).
	Point TopCenter() const;
	Point BottomCenter() const;
	Point LeftCenter() const;
	Point RightCenter() const;


	//The horizontal center of the rectangle.
	int HorizontalCenter() const;
	//The vertical center of the rectangle.
	int VerticalCenter() const;
	//The center (horizontally and vertically) of the rectangle.
	Point Center() const;

        //Many other helper functions, including ANDing / ORing / Contains(point/rect) / SnapToGrid() / Pad(), and so on.