Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


Servant of the Lord

Member Since 24 Sep 2005
Offline Last Active Today, 12:05 AM

#5194712 Optimizing 2D Tile Map

Posted by Servant of the Lord on 25 November 2014 - 08:38 PM

Servant of the Lord, yes, they are text files, although by using Boost, switching to binary is very simple.

 

Hold on a second. I don't mean just switching from Load(MyTextFile, AsText) to  Load(MyTextFile, AsBinary). It's still a text file (even if you save it as "binary").

 

I mean rewriting your file format entirely, so nothing is stored in strings, and things are stored directly as integers and bools and whatnot.

I don't mean saving it as an integer stored as a string saved as a 'binary' file. I mean zero conversion from strings to integers.

 

It's almost certainly the string parsing that is killing your load times. dry.png

 

If you have hundreds of files you're trying to load at once, it's probably the hard drive overhead for each file. But if you have a map stored in a single file, and that single file is taking a long time to load, you need to redesign your file format, not just swap out one function call for another. You need to write it so you don't have to process the loaded data (converting strings to ints or whatever). Load it already in a suitable format.

 

Compression is likely not the issue. Databases are likely not the solution.

 

170KB? Not a problem. A single photograph can be several MB (ten times your map file, and that's with compression), but ten year old computers can open them nigh-instantaneously. smile.png

 

Post your map-loading function.




#5194705 The "action" systems that 2D game frameworks all now have...

Posted by Servant of the Lord on 25 November 2014 - 07:13 PM

Are you seriously saying that that is not common? 

That's how I like to do it. However, Qt, being a desktop application GUI toolkit, wants to control the main messaging loop for me, so I have to write my code to react in response to callbacks. Not too much of a hassle, since I still have React(), Update(), Draw(). Having dozens of different callbacks that I'd need to react to would be annoying, depending on how high-level the API is.




#5194538 Optimizing 2D Tile Map

Posted by Servant of the Lord on 24 November 2014 - 10:12 PM

Load speeds mostly come down to how your file format is laid out, and the amount of content being loaded.

 

What do your map files look like? Are they text files? If so, you can pretty much get an instant speedboost by using binary files instead.




#5194337 My Pokemon Game

Posted by Servant of the Lord on 23 November 2014 - 05:28 PM

you also say you don't intend to infringe on it, you still are infringing on it,

 

Yea, that's always amusing on YouTube. "No infringement intended!"... but it's 100% infringement.

I can't punch someone in the face and say, 'no pain intended'.

 

Regardless of whether a game is commercial or not, it still costs Nintendo money if other people make Nintendo-branded games for free. It weakens and damages Nintendo's property.

 

That said, congratulations on completing a finished project! smile.png  With the skill you've learned, maybe your next project could be something that you create 100% on your own, and that you can commercially sell, that could potentially become as big as Pokemon.




#5194318 Advice for simple 2D game

Posted by Servant of the Lord on 23 November 2014 - 02:59 PM

Yeah sorry about that! im trying to be as active as i can!

 

I think he was suggesting to design your game to be 'fast, responsive, and simple'. wink.png




#5194204 question about pathfinding

Posted by Servant of the Lord on 22 November 2014 - 07:33 PM

A* isn't tile-based, though it's often used in grid-based scenarios.

A* is node-based. The nodes don't need to be evenly spaced or on a grid, though they work fine on grids also.

 

See also: Navigation meshes ("nav meshes").




#5194199 Constructors, Factory Methods and Destructor Questions

Posted by Servant of the Lord on 22 November 2014 - 07:30 PM

Is it always necessary to provide the default constructor (zero arguments) for your classes?

Not always. In some rarer cases, it makes sense to not even expose any public constructor (for example, if you want to enforce creation through a factory).

In general, it's good practice to have a default constructor. I think it's even necessary for some of the standard containers.
 

Would it ever make sense to make a constructor or destructor private or even protected?

Yep, see my previous comment about controlling who can construct classes.
 

Then however, why would anyone ever want to reduce access to a destructor?

I've never personally ran into a situation where that was necessary for a destructor, and none immediately come to mind, but I wouldn't totally dismiss the possibility that in some rare circumstance it might occasionally be useful.
 

Is it good practice to always have virtual destructors?

No, not really. By adding virtual destructors to classes that don't already have virtual functions, you automatically require the class to have a vtable, which adds a small performance and size cost to that class. It also guarantees that they are no longer POD-types, which limits some optimizations you can take advantage of in certain circumstances.

You can write your code to protect the programmer from common mistakes, but it's impossible to write your code to prevent the programmer from every mistake, so you shouldn't try so hard to bend backwards to prevent people from doing things like inheriting from classes that clearly weren't meant to be inherited from. That's not something that "accidentally" occurs, that's an intentional decision someone makes that is a bad decision.

Write your code to prevent accidents, but don't worry too much about preventing deliberate stupidity. You'll never be able to prevent it all the time. happy.png

"A common mistake that people make when trying to design something completely foolproof is to underestimate the ingenuity of complete fools." - Mostly Harmless (HHGTTG), Douglas Adams
 

What if I wanted to extend my object?
[...]
I always do this in case I want to extend that class.
[...]
I wouldn't be able to extend my [...], if I wanted to add [...]


Design your classes well, but don't so over-design them that you limit their usability in other ways. Design them well to meet the current requirements you have, and the immediately foreseeable requirements, not the theoretically it-might-someday-be-possible requirements.

 

Usually, I use virtual inheritance when I want two or more types of objects to pretend to be the same type (polymorphism). If I want to extend a class for non-polymorphic reasons, I usually just modify the original class to add what I want, or create a new class that contains the original class internally (if it makes sense that ClassB has-a ClassA), or create a new class with the common functionality of both classes refactored into functions that can be shared between both classes.
 

Since C++ doesn't allow us to declare a class as "sealed" or "final"

We're in 2014, so you should be using C++11 (standardized in 2011), unless you're forced not to for some reason. In C++11 you can declare classes 'final', as well as declare individual virtual functions 'final'.




#5193913 Where can I find wall art similar to Eye of the Beholder?

Posted by Servant of the Lord on 20 November 2014 - 10:54 PM

I'm not aware of any free sources actually what you are wanting, but there are alot of free texture sites (I like this one), and you can create a basic 3D model and texture it and then screenshot it, or even use 2D software like Photoshop, Paint.NET (free), or PaintShopPro (the poor man's photoshop. tongue.png I use it alot), and using the textures and the "perspective" tool, orient the textures so they look 3D. And then afterward, touch up the image with additional effects.




#5193698 Advice for simple 2D game

Posted by Servant of the Lord on 19 November 2014 - 06:18 PM

"IntelliSense: a nonstatic member reference must be relative to a specific object"

 

That error seems to imply you did this:

//INVALID CODE:
class MyClass
{
    public:
    
    int myVariable;
    
    static void MyFunction()
    {
        //... code that uses 'myVariable'...
    }
};

In this example, 'myVariable' isn't a global. It is a member-variable that belongs to one specific "instance" of that class.

 

The function 'MyFunction()' on the other hand, is 'static' which means it doesn't belong to any specific "instance".

Functions that are static can't use member-variables that aren't static.

 

This is a little confusing, but as you keep learning about classes and also keep testing code yourself, you'll come to understand it.

 

There's a difference between a type of class (like "class Dog" is a new 'Dog' type of class) and an instance of a class ("Dog fluffy;" is an instance of the Dog class, named fluffy). The difference between a type and an instance is an important difference, but it took me awhile to learn it when I first started programming. smile.png

Dog fluffy = ...
int currentYear = 2014;

'int' is a type of variable. 'Dog' is a type of variable.

'currentYear' is a specific instance of an 'int'. 'fluffy' is a specific instance of a 'Dog'.




#5193695 Advice for simple 2D game

Posted by Servant of the Lord on 19 November 2014 - 06:06 PM

But i only have one problem left.
I have learned how to call and retrive functions through global classes, but when i try to initialize a global integer i get the Error.
    1    IntelliSense: a nonstatic member reference must be relative to a specific object

I tried to make the int static, but i cant seem to get it right!

My point is to make the int global so that i can access it from any function though out the code.

 

It's actually bad practice to create globals. Globals, in general, should be avoided. There are some cases where globals are very useful though.

 

The temptation to use globals is because "it's easier" to not have to pass in the variable (by reference) as a parameter. But that easiness comes back to bite you the larger your project gets, because it makes it harder to track down bugs and figure out the flow of the program.

 

This isn't to say all globals are bad. Constants, or values that behave similarly to constants, are fine as globals.

Some classes also make sense as globals (like "std::cout" and "std::cin" are actually globals). Error logging makes sense as globals. But in general, you want to be careful with them.

 

One example of a bad use of globals is when you have a function that gives different results even when you call it with the example same input parameters because it uses a global internally. Functions should, in general, always try to give the same result when passed in the same input.

 

That said, now that you know the general guidelines (that important when your projects start getting larger), and understand that it's not a rule and that it occasionally needs to be broken, here's how you use them:

 

Here's how to create a global constant, which is very good to use:

//In any one header file:
const int MyConstant = 12345;

If you define a constant in a .cpp file, only that .cpp file can access it. This is good, if only that file needs it.

If you define a constant in a .h file, any file that #includes that .h file can access that global. This is good if more than one file needs it.

 

Here's how to create a global that isn't constant:

//In myFile.h you do:
  extern int MyGlobal;
//^    ^
//Note the keyword 'extern'.
 
//In myFile.cpp you do:
int MyGlobal = 357;

With non-const globals, the source file creates and initializes the global, but the header file "exposes" it by using the 'extern' keyword. Any file that includes the header file, then has access to the global.




#5193668 Need a short name to replace a really really long function's name

Posted by Servant of the Lord on 19 November 2014 - 02:26 PM

I also use long function names. Most of the time they are automatically code-completed when I start to type them.

 

However, that function name is rather unclear to me, which is a different problem.

 

As Diego says, how does "Set Position By Original Center Point" differ from ResetPosition()?

Can't you just call:

SetPosition(GetOriginalPosition()) anyway? Do you even need a special function for SetPosByOrigCenter()?

 

Now SetPosByOrigCenterOnEvent() sounds like it is setting up some kind of internal callback that will be triggered when a specific event occurs. It doesn't sound (to me) like it is happening instantly.

 

And since the event is completely ignored anyway, you might as well just use SetPosition(GetOriginalPosition()) in that situation as well, unless I'm misunderstanding something.




#5193557 Using RealWorld People in Games and law?

Posted by Servant of the Lord on 18 November 2014 - 10:33 PM

I worked on a game recently where the player-base demands lots of likenesses, but they were impossible to license. The solution this developer came up with was to ship the game with a character creator so players could create the likenesses themselves, and a sharing server so they could give them to other players. n.b. The sharing server has to have a process in place to deal with DMCA take-down notices.

 

And the coin flip goes to, DMCA safe harbor laws! \o/

 

However, if you make it look too closely like you're trying to encourage your userbase to infringe on your behalf, winking at your fans while giving copyright holders the middle finger, a judge might not be too pleased about that, and side with the copyright holder. Point in check: The Pirate Bay doesn't actually host any pirated content - they just let their users upload tiny text files (torrent files) that point to where the real content is hosted (on user's computers, not Pirate Bay's servers). But because it's obvious that, even though they aren't technically infringing on anything, they are trying to facilitate the pirating of content, the government has consistently gone against them in favor of the copyright owners.

 

And regardless, anyone can sue you for anything, and even if it gets thrown out of court, it'll still cost you money to defend yourself, so this route may not be the best route for indie developers.




#5193550 Are there any patent trollers in the games indestry?

Posted by Servant of the Lord on 18 November 2014 - 09:13 PM

There's trademark, copyright, and patent lawsuits and trolls in abundance. I'm too lazy to google the links for ya, but here's a few that come to mind:

 

Candy Crush, as Truerror mentioned. There's a balance here, and though King was clearly on the wrong side of the line, I wouldn't call them a troll.

Tim Landel ("Edge" trademark). Definitely a troll.

The SpryFox lawsuit was an example of a good lawsuit against geniune copyright infringement.

 

Nintendo was sued over the 3DS's glasses-free 3D screen, by some gent at Sony. If I recall correctly, Nintendo lost the lawsuit - though they might've appealed.

Most major MMOs pay patent fees over some dumb 'virtual world' patent. This includes World of Warcraft being threatened, and paying (nuisance lawsuit - cheaper to pay than to fight).

Every rumblepack-enabled controller has to pay fees to some "inventor", except Nintendo, because Nintendo successfully "invented" (and brought to market: The N64 rumble pack) the invention before the inventor did. happy.png

 

The Carmack Reverse was patented (and not by Carmack. Another company discovered it first, a few years earlier)

Marching Cubes, patented

MP3 music files, patented (not unjustly patented - they were patented by the creators, it just sucks that they are so ubiquitous and proprietary) 

Microtransactions in games - patent troll'd. Someone (or more than one) was going around threatening to sue app developers for using microtransactions, unless they pay an extortion fee, instead of suing Apple or Google directly.

 

Thankfully, the USA has recently improved the laws around patent trolling, to make it harder to do "<x> but with a computer!" patents, and in some cases are even making the patent trolls have to pay for the other side's legal fees if they lose the lawsuit.

 

AskPatents (a StackExchange sub-site), is trying to help make it easier to combat patent trolls, by crowd-sourcing users to find prior-art.




#5193372 Character Creation Idea

Posted by Servant of the Lord on 17 November 2014 - 09:14 PM

I am not sure if this is considered an API but I am using Unity and I am programming in C# with MonoDevelop. As for the slider itself I was thinking about making it a click and drag rather than a button increment, or is a click and drag too complicated.

Click and drag (while still holding down the mouse) is fine, and isn't overly difficult.

Doesn't Unity have a built-in GUI library? I don't use Unity myself, but it looks like they have horizontal scrollbars already implemented for you.




#5193347 Character Creation Idea

Posted by Servant of the Lord on 17 November 2014 - 07:55 PM

1. How do you make a slider


A GUI sliderbar widget is a pretty common widget included in most GUI libraries. Many games don't require complex GUI kits, and just roll their own (so it doesn't look like a desktop application like Microsoft Word) but MMOs usually require more complex GUIs, and either use a preset GUI kit.

The basic idea is it's a button you are dragging along a rail, often with another button on either end for smaller increments of movement.
Have you ever made a button widget before?

What language and API are you using to program in? Chances are, there are both native GUI toolkits (like Win32), cross-platform wrappers for native GUIs (like Qt), and more game-related GUIs like SFGUI or Crazy Eddie's.
 
You can also code your own.
 

2. How do you make that slider change the dimensions of the character. For example: weight, height, facial features, etc.


That's a more difficult question. It's easy to make the slider, and easy to make the slider affect things, but now you're wanting to procedurally generate (or at least manipulate) a 3D model. At the easiest method, you can make each "notch" of the scrollbar select a different pre-made component (like different styles of hair), and use the scrollbar's value to tweak the color of the hair.

But the other features like swapping out noses and making sure they still integrate smoothly with the face, raising lowering and stretching ears, and so on, that's not an area I personally have experience in.




PARTNERS