Jump to content

  • Log In with Google      Sign In   
  • Create Account

Gamedev.net will be down tonight at approximately 9pm EST for site maintenance

Servant of the Lord

Member Since 24 Sep 2005
Offline Last Active Yesterday, 02:41 PM

#5263668 Best comment ever

Posted by Servant of the Lord on 26 November 2015 - 12:27 AM

I dont know if that is good style (its in a "details" namespace) but its quite convenient to have something like that.

I can't comment on the validity of that (despite doing similar aliasing in other places smile.png), but I can suggest that the struct itself test for std::is_trivially_copyable via a std::static_assert.

template<typename stype>
union Bytes
	static_assert(std::is_trivially_copyable<stype>::value, "'Bytes' requires trivially-copyable types");
	stype data;
	unsigned char bytes[sizeof(stype)];

I can however confirm, with an acceptable margin of error, that your warning comment is amusing. tongue.png

#5263222 Multiple callbacks for one build error?

Posted by Servant of the Lord on 22 November 2015 - 10:33 PM

How ive seen it done in most compilers, is showing the error as one and then have a foldout to show the individual problems. Because many times the first one is not very informative. Also like how vsc++ does it is they have the output window (which has all the information warnings bugs compiler messages, status messages etc) and then they have error list (with the errors and warnings which can be sorted in a variety of ways). This is how i would handle it.


Isn't that the IDE's responsibility? For example, GCC outputs multiple messages just like the example above, and QtCreator (the IDE) gets to decide how to display them. In your case, Microsoft's compiler (which has no GUI) outputs multiple messages and Microsoft's IDE (Visual Studio) is responsible for displaying it in a friendly manner.


AngelScript is the non-GUI compiler part (like GCC and Microsoft's compiler), and it's up to the caller to decide how to display that info (like QtCreator and Visual Studio). By providing more details (like different fragments of errors pointing at different lines) it gives more power and flexibility to the IDEs to decide what they want to display, and how they want to display it.

#5263220 Put game data to files or using database tool

Posted by Servant of the Lord on 22 November 2015 - 09:53 PM

** Is this ok to put all those harcoded attribute at class? 
   ..or should i put the attribute value in separate data file, then load it when everytime creating a Foe instance?

It is okay to hardcode *default* values, but you should load the attribute values from a data file into a common Foe instance.

Foe1, Foe2, Foe3 are not okay. Anytime two classes are identical except for the values of variables, that almost always means you should pass the values into the class as constructor parameters.

For example, if you give 'Foe' a custom constructor:

class Foe
      Foe() = default;
      Foe(int sizeW, int sizeH, int maxHealth, int maxShieldPower, int damagePower, string weaponType)
: Size_W(sizeW), Size_H(sizeH), Max_Health(maxHealth), Max_ShieldPower(maxShieldPower), DamagePower(damagePower), Weapon_Type(weaponType) { }


...and then do this:

const Foe Bat(...values for bats...);
const Foe Goblin(...values for goblins...);
const Foe Grue(...values for gree...);
const Foe Sheepsie(...values for sheep...);

You can later do this:

//std::vector<Foe> allFoes;

void GameWorld::createNewBat(Position position)
    Foe newBat = Bat; //Create the new foe using 'Bat' to initialize basic Bat-like values for it.

** To save data in separate file, for char.attributes or game progress,
i'm considering to save those into encrypted files or using (maybe)a light-weight database tools.
Which method is probably better?  (considering the balance of "runtime loading process" and "data management issue" )

A) You don't need your files to be encrypted.
B) You absolutely don't need a database. wink.png 

I'd save it as binary into a basic custom binary file format, or use a text format like XML (since you are already using XML) or JSON or YAML, or even just a basic "var = 27" map-like file.


In my own game, I save my files in a text-based format for development, but then save them in a binary-based format for when releasing the game. I automatically keep the two in sync using programming magic, otherwise it'd be a nuisance to keep any files saved in a binary format from breaking any time I changed the variables in the class.


For your first game, this is overkill, so I'd definitely suggest sticking with a text-based format. It's just much easier during development, and most likely fast enough for your needs anyway.

#5263082 Easing my camera towards a target that is also moving.

Posted by Servant of the Lord on 21 November 2015 - 10:38 PM

Currently you are easing based on time, but you can just as easily ease based on distance.


Easing algorithms don't need to be passed time. You can, for example, ease a color based on the position of an object, just as easily as you can ease a color based on an amount of passed time.


Ease functions are just given a value between (0 and max), and currently you are making "max" be a time duration, and the passed in value being the amount of passed time.

Instead you can make "max" be the target's current location relative to the camera's starting position, and the passed in value being the camera's position relative to the camera's starting position.


This means your "max" of the ease changes every frame, which is perfectly fine.



Though I think the simplest answer to your problem is you are giving your ease function an outdated value. Instead, each time update() is called, you want to pass 'ease()' the current position of the target, not your saved out-dated value.

#5263081 Easing my camera towards a target that is also moving.

Posted by Servant of the Lord on 21 November 2015 - 10:24 PM

The second half of Khat's post covers how to make it ease:

If you want to smoothed you can adjust the speed according to the distance to the target.

Though, rather than just using the distance, I'd do it based on "distance traveled" and "distance left until reaching target".
Something like:

Constants: AmountToTravelBeforeReachingFullSpeed, DistanceFromTargetBeforeSlowingDown, PixelsToMovePerSecondWhenAtMaxSpeed;
Inputs: distanceTravelled, distanceFromTarget;

float maxSpeed = std::max(distanceTravelled / AmountToTravelBeforeReachingFullSpeed), 1.0f);
/* Optional: */ maxSpeed = EaseInAlgorithm(maxSpeed); //Apply an ease if you desire.

float minSpeed = 1.0 - std::max((distanceToTarget / DistanceFromTargetBeforeSlowingDown), 1.0f);
/* Optional: */ minSpeed = EaseOutAlgorithm(minSpeed); //Apply an ease if you desire.

float currentSpeed = std::min(maxSpeed, minSpeed);

float speedInPixelsOrWhatever = (currentSpeed * PixelsToMovePerSecondWhenAtMaxSpeed);
cameraPos += speedInPixelsOrWhatever;
distanceTraveled += speedInPixelsOrWhatever;


#5262915 Can't learn c++

Posted by Servant of the Lord on 20 November 2015 - 01:32 PM

Programming is fun and frustrating. Don't let the frustrations make you think you're not cut out for it.

#5262524 Can't learn c++

Posted by Servant of the Lord on 17 November 2015 - 09:43 PM

For learning in general C++, here's my advise:
  • Understand that there are different versions of C++. Make sure you enable C++14 in your compiler.
  • You can write code online in IDEone.com, but that's not a good substitute for actually using a downloaded IDE like Visual Studio.
  • Download and use the latest Visual Studio, and make sure C++14 is enabled (if it's not already by default). I don't use Visual Studio myself, so you'll have to google how.

  • This is personal preference, but I find that after coding, I can sometimes "relax" by reading about code, and I can still learn even after learning, by changing my body position and medium of learning. If you think you might be similar, buy a C++ book, or borrow one from the library, but it has to have been written in 2012 or later. That's very important. Read the book on your couch, not at your computer. With the breadth and depth of information online, getting a book is mostly optional.

  • If you do buy a book, don't get one that teaches "game development". And if it says "C++ with <something else>", ignore it. Get a book that only teaches C++. Not SFML, DirectX, SDL, Allegro, OpenGL, Vulkan, or anything else. Just, plain, regular, vanilla C++.

I'm not the type of guy who can just read something and then go program the new elders rolls game (metaphorically).

Nobody can do that, metaphorically speaking or not.
Skilled programmers aren't people who are just work up one day naturally talented. It's not "a type of guy" who becomes good programmers. It's people who study and program who are good programmers.
There's some truth to some people having some natural talents that make it easier to pursue it, but dismissing yourself as 'not one of those special magical people' is a terrible excuse some people use to hide their own laziness or lack of effort, or because they got discouraged that they didn't learn the entire science of computer engineering in 21 days or 24 hours as the books all promise (in actuality, it's a lifelong process, and it takes years to become competent).

My school has to use Chrome books so for the class I can't install a program to code with so it's very hard to learn c++ like that


Yes, it is very hard to learn C++ like that. C++ is not supposed to be learned like that.
If you have a class that's teaching you C++, and you have to use Chromebook computers, ask your teacher what she/he recommends, and what the rest of the class is going to be using.
If you are talking about learning C++ outside of your class, then you aren't limited by the Chromebook shackleslimitation.
Have you already tried Googling "learning C++ on a chromebook"? There seems to be some rudimentary options available. But ultimately, this is not the best way to learn C++.

#5262513 Hacker game design

Posted by Servant of the Lord on 17 November 2015 - 08:34 PM

Have you played Uplink?

Not 100% realistic, but enough realism in it.

#5262349 Which style would have better appeal?

Posted by Servant of the Lord on 16 November 2015 - 09:19 PM

I'd suggest you pick one of the dozens of other easy art styles that aren't voxels. As awesome as voxels are, they are being currently overused, and any game that uses voxels automatically gets a few points knocked off of it for lack of creativity by alot of gamers.

#5262295 Slider menu for programming more efficiently?

Posted by Servant of the Lord on 16 November 2015 - 01:03 PM

One option is to just store as many of the variables as possible that you are tweaking in a config file, and (possibly) hot-reload them.

#5262178 Professional Versatile Composer

Posted by Servant of the Lord on 15 November 2015 - 05:41 PM

Thanks for reviewing my thread and I hope I can i get started with the Indietalk community ASAP


When you posted your ad across multiple websites, you forgot to change the name of the forum you were posting on. laugh.png

Also, your SoundCloud link is broken. It says, "Sorry! We can't find that playlist.", which might mean you have the playlist set to 'private'.


This community actually has a special area where recruitment or contracting occurs: Classified: Contractors for Hire

It helps keep the forums uncluttered. e.g. the Visual Arts subforum is about discussing art and getting feedback, not about recruitment, and ditto for the Music and Sound subforum: It's for discussing audio software and hardware, and getting feedback from other composers about your work.

#5262030 Member function pointers?

Posted by Servant of the Lord on 14 November 2015 - 10:50 AM

The downvote was a mistake on my part. ph34r.png Since I couldn't undo the downvote, I had upvoted post #9 to compensate.

#5262028 Which Software Game Engine to use

Posted by Servant of the Lord on 14 November 2015 - 10:36 AM

Welcome to the forums! We frequently offer engine and tool advice. Most often, we have to explain what you probably already know: that there's no engine that perfectly does everything for you. It still involves work on your part to custom the engine's generic features into your game's specific features. That's the nature of a programmer's work. smile.png 

Be able to load images of various layers of different clipart with transparent backgrounds to create one uniform image.

Why have this specific weird unusual request, when you can just load as many images with transparent backgrounds as you want, and draw them over each other or draw them into a new image?
Why look specifically for an engine that happens to do some weird crazy feature that you can easily write yourself?

These images will need to be placed on specific locations on the screen; especially in order to ensure that they line up correctly on top of each other

That's the programmer's responsibility: You can use any graphical API to draw images.
It's your responsibility to place them at 'specific locations' in the 'order' you want, and make sure they 'line up correctly'.

That's just called "drawing an image". Any graphical API can draw an image

If you want to draw images A, B, and C... then you order them how you want and draw them.

Draw(imageA, sameLocation);
Draw(imageB, sameLocation);
Draw(imageC, sameLocation);

You don't need special engine for that. That's the work that you, as a programmer, do.
An engine is unlikely to provide:

DrawMultipleImagesOverTheSameLocation(imageA, imageB, imageC, sameLocation);

I'd hate it if an engine tried to do that for me. It'd immediately tell me that the engine is trying to micromanage too much, and I'd spend half my effort fighting against the engine, to get it to do what I want, instead of what the engine thinks I might want. sad.png

Be able to have a great database capabilities,

Very very very few games use databases - they are mostly only used by online games, and only on the server-side of things.
Sometimes we hear a term or phrase, and we think that's what we need, because it sounds impressive, but we really don't need it.
Do you know what a database is, or when and why they are used?

so that I can load thousands of separate images and be able to code which images should be generated based on a user’s request for one uniform image

How large are these images? Why do you have them loaded all at once? Are every image on-screen at the same timehuh.png

Unless the images are very large, and you need every of them loaded into RAM at the exact same time, you won't have a problem - and databases add complexity to solve a problem you probably don't actually have.

I need a program with built in libraries

In this context, what is a library, and why do you need it 'built in'?

that will allow me to create 2-D environments to place the pictures they create into.

That's up to the programmer to write. All that's required is for the API to provide the ability to draw images and get mouse input, and the programmer writes the code to place images where the mouse was clicked.

For example some images I my want a black background; others, like if person selects bird I may want a cloud background.

That's up to the programmer to write.

People should be able to be able to point to a place on the image and words should describe what is there.

That's something programmers write. That's game-specific logic.

Be able to quickly handle thousands of data,

What is "data"? That's a rather generic term. happy.png 
It's like saying, "I need to do thousands of 'things' involving 'stuff'".
"I need to do thousands of 'data' involving 'handling'" is the exact same meaninglessness when you are communicating to someone who doesn't know your project.
It makes sense to you, because you already know what you actually mean, but to me it's just frobbing a particularly insipid wodge. laugh.png  

and based on a user’s input a specific image will be generate to locate a group of clip art images based on the specification they requested

The API provides the method of getting the input, and the programmer writes the code to take that input and generate the images.

I am not an expert at C++ programmer, but developed a few little games using IRRLICHT game engine; so I do not mind coding, it is just the GUI and the libraries are very nice to have; I do not want to code for things that could be standardized for me

If you're looking for standard GUI desktop interfaces, Qt provides those. Qt is a huge set of libraries with alot of GUI-related (and non-GUI) features and tools.

But if you're making a game, you probably want something like SFML (which doesn't have any GUI). SFML provides you with the ability to create the window, get input, load images, and draw them on-screen. You'll need to pair it up with something to draw the GUI. Maybe SFGUI, though I've never used SFGUI myself.
This may require alot more work on your part than you're used to. sad.png
You're going from an engine (Irrilict) which tries to do as much as it can for you, but is targeted at a very specific and narrow category of programs, to a generic API which you yourself will have to build ontop of to make your narrow and specific and custom game.
The plus side is you won't have to pay anything for any of this. The only cost is your time and sweat learning a new set of APIs.

#5261641 Problem with variable arguments

Posted by Servant of the Lord on 11 November 2015 - 12:42 PM

You shouldn't add functions in namespace std. I forgot the exact rules, but the vast majority of the time you'll be in undefined-behavior land.


I didn't - I added it to the global namespace.

#5261611 Problem with variable arguments

Posted by Servant of the Lord on 11 November 2015 - 10:54 AM

@louie999: Congrats on getting it working!


The things in the <> brackets are what get used to generate a real function from the template function.

The things in the () brackets are what get passed to the function after its been generated.

#include <iostream>
using namespace std;

template<typename Type, int FixedTemplatedValue>
void TemplatedFunc(Type value)
	std::cout << "Fixed templated value: " << FixedTemplatedValue
	          << "\tPassed in changable value: " << value << std::endl;

int main()
	auto FuncSeventeen = &TemplatedFunc<std::string, 17>;
	auto FuncTwoHundred = &TemplatedFunc<float, 200>;
	//NOTE: These functions always print "17" as their fixed value, 
	//because it's now BUILT INTO the function.
	//They also always take a std::string as their first parameter, because it's BUILT IN at compile time,
	//but they let you decide at run time what the value of that string is.
	//NOTE: These functions always print "200" as their fixed value, 
	//because it's now BUILT INTO the function.
	//They also always take a float as their first parameter, because it's BUILT IN at compile time,
	//but they let you decide at run time what the value of that float is.
	return 0;

This prints:

Fixed templated value: 17	Passed in changable value: Meow
Fixed templated value: 17	Passed in changable value: Purr
Fixed templated value: 200	Passed in changable value: 0.257
Fixed templated value: 200	Passed in changable value: 1.5

Test it here


When you do:

TemplatedFunc<std::string, 17>("Meow");

It's the same as:

auto FuncSeventeen = &TemplatedFunc<std::string, 17>;

The compiler at compile-time creates the function "TemplatedFunc<std::string, 17>" from the template, by passing in the template arguments <std::string> and <17>.

Then, at run-time, the program calls the function, with the function arguments ("Meow").


@Servant, I completely forgot to declare args... D: and isn't std::make_unique only for C++14? I'm using C++11.
Yes, std::make_unique() was forgotten in C++11, so they added it in C++14.
However, you could just add it to your code yourself, and then remove it when you get access to the real thing.
//std::make_unique implementation (it was forgotten in the C++11 standard, and will be added later).
//Once it's added, I can just remove this function from here.
template<typename T, typename ...Args>
std::unique_ptr<T> make_unique( Args&& ...args )
	return std::unique_ptr<T>( new T( std::forward<Args>(args)... ) );

Or better yet, you could just enable C++14 in your compiler, and start using those features. It doesn't break any of your existing code, and adds some cool features.

But if your current compiler doesn't support it, then I understand.