Jump to content

  • Log In with Google      Sign In   
  • Create Account


Servant of the Lord

Member Since 24 Sep 2005
Offline Last Active Yesterday, 06:28 PM

#5176547 C/C++ tilt sensor for Android/iOS

Posted by Servant of the Lord on Yesterday, 05:51 PM

Qt has recently added support for mobile platforms, and has a C++ sensor API.

 

If you aren't already using Qt, you almost certainly don't want to include the giant collection of libraries that is Qt, but luckily, Qt is opensource under LGPL and GPL, so you could look to see how they do it, separate out their sensor code, wrap it in its own separate LGPL'd library, and then use that - dynamically linking to it, so the rest of your closed-source commercial product isn't hampered by the licensing.

 

Or you could just examine it, to see what API function calls they use, and then write your own wrapper (or better yet, submit a patch for SDL so others can benefit) by reading the API documentation.




#5176450 Raster art for beginners.(Tools,problems,tutorials)

Posted by Servant of the Lord on Yesterday, 10:51 AM

Sure enough, i remember when I first started doing computer art.... i said "who the hell needs layers... wtf are they for anyway?" LMAO those were pain shop pro days... when photoshop was too expensive for a lowly 10 year old!

 

lol, layers are sweet. I use Paint Shop Pro XI (about 7 years old, now), and it has layers and does a decent job. Probably not as feature complete as Photoshop, but alot cheaper.




#5176071 Distance formula in c++

Posted by Servant of the Lord on 25 August 2014 - 03:36 PM

Nice! I wasn't aware of the std::hypot() function. smile.png

 

As fastcall22 mentioned, you actually don't need to do a squareroot, unless you actually want the actual distance. If you just want to check if something is within range, then you do:

((x2-x1)^2 + (y2-y1)^2) < (distance^2)   //  '^2' means to square it.

Basically, the same as Pygorean's theorum, but instead of square-rooting the result, you square the distance, which is faster if you're going to be doing it alot - for example, if you need to test which entities are within range of other entities or within range of the player, but don't need to know the actual distance, only if it is within range or not.

 

Probably a pre-mature optimization, but if you're going to wrap it in a convenience function, you might as well write both versions.

 

C++ code




#5176020 Windows Programming

Posted by Servant of the Lord on 25 August 2014 - 10:55 AM

If you are asking about how to make GUIs for desktop applications, I really like Qt.

 

Here's a screenshot of a 2D tile-based editor I'm working on using Qt. The center of the editor uses a different API for drawing (SFML and OpenGL); you can make widgets be OpenGL-drawn as well as have Qt-drawn widgets.

 

Qt is also cross-platform for Windows, OSX, and Linux. Supposedly it's also recently gained cross-platformness for iOS and Android, but I'm not sure how well it works.




#5175905 Possible to prevent device to go to sleep?

Posted by Servant of the Lord on 24 August 2014 - 08:10 PM

Could you design the game so that the game remembers the last time it was used (i.e. 9:09 PM 2014/8/24), and interpolates what "happened" the next time the user logs in? This would solve your problem (even when people shut down their desktops) and annoy users less. I wouldn't even want a browser page open continuously even on my desktop, unless it's something important.




#5175900 Concern on "paying to enter" a project

Posted by Servant of the Lord on 24 August 2014 - 07:40 PM

Maybe he just wants to bum off a free game from you? dry.png

 

My thought exactly!

 

 

Why would you want to mod a game that you don't already play? tongue.png

[...]

I'd also be suss of any prospective modder who doesn't own the game that they want to mod.

 

I disagree. Suppose it's a 3D modeller who saw an interesting project about a sci-fi game, that just happens to modding, say, CounterStrike.

 

Just because he's interested in 3D modelling and interested in sci-fi games, doesn't mean he's interested in CounterStrike or that he owns a copy of it. What does he care about what engine that is used under the hood?

 

That's like saying, "I'd be worried about any level designer that doesn't already own Unity!". The level designer could just happen to be used to Source Engine and Unreal Engine and other engines.

 

But I do agree with, I'd be worried about any modder who's not willing to pony up $15. Ofcourse, $15 USD varies alot in cost depending on your average cost of living. $15 in California might be the equivilent of $20 in the midwestern states, and could be the equivilent of $30 or $40 in another country.

 

Nevertheless, I wouldn't buy him a copy unless I already know the quality of his work based on examples he's shown me, and unless I get a firm comittment from him to stay with the project for at least six months.




#5175897 How would I start a 2d mmorpg

Posted by Servant of the Lord on 24 August 2014 - 07:26 PM

Do you know C++ already?

Have you already made any simple game like tetris or pong?

Have you already made a single-player RPG?

 

Don't think of these as walls in your way, but stepping stones to build up to what you want to make. It saves time in the long run, because otherwise your MMO code would grow into a unwieldy mess while you are trying to learn and figure things out, and you might get frustrated at the vastly larger amount debugging and re-writing you'd have to do, compared to writing some 'throw-away' stepping-stone games to understand and learn how to write game architectures.

 

If you already know how to program games, then Beej's Networking Tutorial contains details of networking sockets at a lower level, and RakNet is now opensource and free.




#5175851 Raster art for beginners.(Tools,problems,tutorials)

Posted by Servant of the Lord on 24 August 2014 - 12:26 PM

Well I want to make a game which is much like Zelda or Hyper Light Drifter or Binding of Isaac.(But not pixel art or flash art.)So its like a 3/4 game with high res art.
These images are similar to my game in sense of the point of view and how far the camera or point of view is.
I could not find high res art with 3/4 view. I am planning to make an indie rpg game with high res art since the indie market is over saturated with games with pixel art.


Perhaps you might be mistaken about what 'hi res' means? You can draw realistic looking low-res art. You can also draw hi-res pixel art.

You can draw realistic low res, medium res, and high resolution artwork.
You can draw cartoonish low res, medium res, and high resolution artwork.
You can draw pixel-art at low res, medium res, and high resolutions.
You can eat it on a train, you can eat in in the rain, you can... Oops, I got sidetracked a second. tongue.png 

My point is, the resolution of your artwork doesn't dictate your art style (though it can affect it).

Making artwork higher resolution does not automatically make it look better or more realistic.

 

If you think you need your character to be 1920 x 1080 to look realistic, you are mistaken!

How you draw the art determines your art style, not what resolution it is.




#5175742 How to program tile transitions (C++/SFML)

Posted by Servant of the Lord on 23 August 2014 - 10:24 PM

There are multiple ways to go about it.
One easy way is to have 2 or 3 layers of tiles. Instead of putting down one tile for each spot on the map, what if there are three (or more) layers of tiles?
 
Then you can put down solid tiles, like entirely water and entirely grass tiles on the bottom layer, and transitioning tiles on the next layer up.
  • Background layer 1 (water, sand, grass, whatever)
  • Background layer 2 (transition tiles)
  • Background layer 3 (bushes, tree trunks, rocks, etc...)
  • Background layer 4 (anything else needed, like maybe flowers in the bush, or vines wrapped around the tree trunk)
  • <Player and NPCs get drawn next>
  • Foreground layer 1 (tree shadows, wall shadows)
  • Foreground layer 2 (tree tops, so they get drawn OVER the player when he walks behind them, and other things like bridges the player walks under)
  • Cloud layer (cloud effects, rain effects, etc...) (This layer is not tiles, but one repeating semi-transparent image that scrolls horizontally and vertically)
Make sure you permit yourself to place any tile on any layer you want - don't limit what layers the map maker can put tiles on!
 
Here's an example of how this can improve the visual quality of your game using just three layers:
 
Layer 1:
Layer_1.png
 
Layer 2:
Layer_2.png
 
Layer 1 and 2 drawn together:
Layer_1_and_2_merged.png
 
 
Layer 3:
Layer_3.png
 
All layers drawn together:
All_layers_merged.png


#5175669 Raster art for beginners.(Tools,problems,tutorials)

Posted by Servant of the Lord on 23 August 2014 - 11:55 AM

The general solution to the resolution issue is often to just draw your sprites as either really large at a high resolution (The largest they'll be seen on the biggest target device)


Dramatically down-scaling images can end up look bad. Some people create their hi-res versions, and manually downsize them using the better algorithms of art programs (instead of the faster and sloppier real-time resizing algorithms), then touch-up the down-sized versions to make sure they look fine, so they end up with 3 or 4 different sizes (Huge, Large, Medium, Small), and then choose the closest-matching size at run-time.

Especially with text - you want to choose a font size that is as close as possible to what you want on-screen. Taking hi-res rendered text and downsizing it a huge amount looks ugly.
Same thing with characters or other things with lots of sharp details - you don't want to loose pixels arbitrarily, but you need finer control over it.

Though, it seems to me, some indie games just render at a fixed resolution, even tiny ones like 800x600, and then resize the entire screen (or let the monitor resize it, when it's at fullscreen). I think Braid was one of these 800x600 games. Just be careful you aren't twisting your game's aspect ratio out of proportions (you don't want things stretched out or squashed).

With the top screenshot, Spelunky, I don't know what they do, but they could just show more cave area, until some preset max resolution is reached (i.e. where the character and GUI elements still occupy enough percentage of the screen real-estate to see clearly), and then switch to up-scaling from there (or rather: let the monitor upscale).

Also, for styling: The Art of Braid




#5175512 So... C++14 is done :O

Posted by Servant of the Lord on 22 August 2014 - 11:02 AM

Pardon me? C++, a portable language? Name mangling, type-size-differences, compiler/os/cpu-specifics, DLL-hell?

 

C++ is source-code portable, not binary-portable. Honestly, if you expect C++ to compile to assembly that's portable for different devices running different CPU architectures, such as MacOSX back in the PowerPC days, or modern day Android and iOS devices running ARM, then yeah, you're looking at the wrong language.

 

Also, DLL-hell has less to do with portability and more to do with having more than one version of the same DLL on the same machine. Further, DLLs aren't in C++'s control, so you can't blame C++ for them. DLLs are used by many languages, and are part of the Windows operating system (just as the design of SharedObjects are part of Linux). Solution: Just ship your own DLLs alongside your executable, and not in shared folders in the OS.

 

Type-size differences is a valid complaint though. This is increasingly getting fixed, however. For example, 'int' is still 32bit on in a 64 bit system, and if you want to ensure type sizes, use the proper uintX_t variables.

 

Now, if you want to use OS-specific, CPU-specific, or compiler-specific features, you're enabled to do so - but you don't have to - and you can still make it portable by writing #ifdef guards. (And if you do so, wrap it in a tiny library (even just the .cpp and .h's added to projects directly) so others can use the entire library as "portable".

 

Saying, "I want my CPU-specific code to be portable" doesn't make sense. You can't use a CPU-specific feature and then complain that it's... CPU specific. If you want it portable without extra work, don't use the CPU intrinsics then! If you want it to be portable and you want to take advantage of certain CPUs, then write both the 'general' code and the 'specific' code.

 

 

My feeling is that if the committee can't write clean, efficient, proper C++ code, how they hell are we supposed to be able to?  If the committee can't write a simple vector implementation, then they need to get back to the drawing board and figure out why they cannot, rather than just pass the buck onto the vendors. I mean the whole reason Boost in its current form exists (and I love Boost) is simply because its the standard library that C++ needs.


Most of the people who work on compiler implementations and their corresponding STL implementations are actually part of the standard committee, and they actually work on the implementations of proposals while they are still in discussion to help nail down design issues.

 

Exactly! Not to mention, some of the primary people writing Boost are also part of the standard committee. wink.png

Boost is sometimes used as an unofficial 'testing ground' for future C++ library features.

 

So the entire idea that C++ doesn't specify the standard library implementation details because of lack of skill is false. Infact, it's just the same idea behind the rest of the C++ language: The language standard only says what to do, not how to do it, and this is the single greatest strength of the entire C++ language and yes, really does allow for huge optimizations.

 




#5175105 So... C++14 is done :O

Posted by Servant of the Lord on 20 August 2014 - 02:24 PM

I would like to see an emphasis on growing the standard library.

 

That's already the emphasis for C++17. C++11 is the major 'feature' update (with minor library expansions), C++14 more of a post-C++11 'fix' update, and C++17 is supposed to be a major library-centric update (though there will be features also).

 

They've discussed taking some well-established existing libraries and standardizing them - some that were already publicly used libraries, some that are more in-house general-purpose libraries from companies like Adobe, Facebook, Microsoft, and Google. Which libraries they end up choosing will be interesting, but one thing they threw out as an idea was even standardized 2D graphics libraries - possibly standardizing (and modifying) Cairo, among others. [proposal]

 

boost::filesystem is another that'll likely get standardized wholesale, already being added to a technical report (a "test release", if you will).

 

Personally, I feel some libraries like 2D graphics shouldn't be standardized, because development might move faster as 3rd party libs. But for more "solved" problems like networking and filesystems, standardization would be nice.

 

This talk goes into what some of the things that the C++ committee is looking at.




#5175085 So... C++14 is done :O

Posted by Servant of the Lord on 20 August 2014 - 12:56 PM

I still think the range-based loops were unnecessary.
[...snip...]
It does not add anything new.

 
Like move-semantics, its primary motivation is to allow behind-the-scenes optimization.
 
range-for enables the compiler to assume:

 - That the iterator is accessed only once for each element.

 - That the iterator visits every element in the range in a predictable pattern. (i.e. it's not randomly jumping around)

 - That the iterator moves in a single direction, in increments of 1 step. (e.g. no modifying the iterator in the midst of the loop body)

 - That no elements are being inserted or removed while the loop is running.

(I might've gotten those wrong; I learned about it in passing a year or more ago)

 

Supposedly, this allows compilers to optimize the most common case of iterating over the entire container.

Don't ask me what optimizations, I'm not a compiler writer. tongue.png Something about being able to better cache values in advance without having to reach back into RAM for them because the compiler can assume they haven't changed. Or something; you can look it up if you're interested.

 

This is similar to the increment and decrement operators. A way to optimize (and syntactically simplify) the most common case of += 1. The increment operator doesn't add anything new to the C language (Well, they also simplify stepping pointers along arrays, but that's hardly groundbreakingly 'new' either).
 
I just wish there was an standard way to iterate backwards or iterate over only a portion of the array - currently I roll my own:

#ifndef COMMON_ALGORITHM_CONTAINERREVERSE_H
#define COMMON_ALGORITHM_CONTAINERREVERSE_H

#include <iterator> //For std::move_iterator

/*
	Provides a way to iterate backwards over containers using C++11 range-for.

	Example:
	for(auto &blah : container)

	To iterate backwards:
	for(auto &blah : Reversed(container))
*/

template <class ContainerType>
class ReversedContainer
{
public:
	ReversedContainer(ContainerType &container) : container(container) { }

	typename ContainerType::reverse_iterator begin() { return container.rbegin(); }
	typename ContainerType::reverse_iterator end() { return container.rend(); }

private:
	ContainerType &container;
};

template <class ContainerType>
class ReversedContainerConst
{
public:
	ReversedContainerConst(const ContainerType &container) : container(container) { }

	typename ContainerType::const_reverse_iterator begin() { return container.rbegin(); }
	typename ContainerType::const_reverse_iterator end() { return container.rend(); }

private:
	const ContainerType &container;
};

template <class ContainerType>
ReversedContainer<ContainerType> Reversed(ContainerType &container)
{
	return ReversedContainer<ContainerType>(container);
}

template <class ContainerType>
ReversedContainerConst<ContainerType> Reversed(const ContainerType &container)
{
	return ReversedContainerConst<ContainerType>(container);
}

/*
	Provides a way to iterate over a container and move each element at the same time.

	Example:
	for(auto  blah : container)		    //Copies each element
	for(auto &blah : container)		    //References each element
	for(auto &&blah : Moved(container)) //Moves each element
*/

template <class ContainerType>
class MovedContainer
{
public:
	MovedContainer(ContainerType &container) : container(container) { }

	std::move_iterator<typename ContainerType::iterator> begin() { return std::make_move_iterator(container.begin()); }
	std::move_iterator<typename ContainerType::iterator> end()   { return std::make_move_iterator(container.end()); }

private:
	ContainerType &container;
};

template <class ContainerType>
MovedContainer<ContainerType> Moved(ContainerType &container)
{
	return MovedContainer<ContainerType>(container);
}

/*
	Provides a way to iterate over *portions* of containers using C++11 range-for.

	Example:
	for(auto &blah : container) //Iterates over the entire container.

	To iterate backwards:
	for(auto &blah : From(container, 5, 8)) //Iterates from the 6th element to the 14th element.
*/

template <class ContainerType>
class FromContainer_Wrapper
{
public:
	FromContainer_Wrapper(typename ContainerType::iterator startIt,
						  typename ContainerType::iterator endIt)
		: startIt(startIt), endIt(endIt) { }

	typename ContainerType::iterator begin() { return startIt; }
	typename ContainerType::iterator end() { return endIt; }

private:
	typename ContainerType::iterator startIt;
	typename ContainerType::iterator endIt;
};

template <class ContainerType>
class FromContainer_ConstWrapper
{
public:
	FromContainer_ConstWrapper(typename ContainerType::const_iterator startIt,
							   typename ContainerType::const_iterator endIt)
		: startIt(startIt), endIt(endIt) { }

	typename ContainerType::const_iterator begin() { return startIt; }
	typename ContainerType::const_iterator end() { return endIt; }

private:
	typename ContainerType::const_iterator startIt;
	typename ContainerType::const_iterator endIt;
};

template <class ContainerType>
FromContainer_Wrapper<ContainerType> From(ContainerType &container, size_t start, size_t elements)
{
	auto begin = std::begin(container) + start;
	auto end = (begin + elements);

	auto real_end = std::end(container);

	if(begin > real_end)
		begin = real_end;
	if(end > real_end)
		end = real_end;

	return FromContainer_Wrapper<ContainerType>(begin, end);
}

template <class ContainerType>
FromContainer_ConstWrapper<ContainerType> From(const ContainerType &container, size_t start, size_t elements)
{
	auto begin = std::begin(container) + start;
	auto end = (begin + elements);

	auto real_end = std::end(container);

	if(begin > real_end)
		begin = real_end;
	if(end > real_end)
		end = real_end;

	return FromContainer_ConstWrapper<ContainerType>(begin, end);
}

/*
	for(unsigned value : in_range(10, 15))
	{

	}

	in_range_step(10, 15, step)

	for(unsigned value : {0, 2, 3, 4, 7, 4, 12, 15})
*/

/*template <typename Value>
auto in_range(Value max) -> std::array<Value, max>
{
	return in_range(0, max);
}

template <typename Value>
auto in_range(Value min, Value max) -> std::array<Value, (max - min)>
{
	std::array<Value, (max - min)> rangeArray;
	for(size_t i = 0; i < rangeArray; i++)
		value = (min + Value(i));

	return rangeArray;
}

template <typename Value>
auto in_range_step(Value max, Value step) -> std::array<Value, (max/step) + 1>
{
	return in_range_step(0, max, step);
}

template <typename Value>
auto in_range_step(Value min, Value max, Value step) -> std::array<Value, ((max - min)/step) + 1>
{
	size_t arraySize = ((max - min)/step) + 1;

	std::array<Value, arraySize> rangeArray;
	for(size_t i = 0; i < rangeArray; i++)
	{
		value = (min + Value(i * step));
	}

	return rangeArray;
}*/


#endif // COMMON_ALGORITHM_CONTAINERREVERSE_H

On the range for-loop thing ... what I don't like about it is doesn't it effectively make "begin()" and "end()" magical member functions?

It makes the stand-alone overloaded functions std::begin() and std::end() the magic functions, which you can overload for your own types. By default, if there is no overload, the fallback versions of std::begin() and std::end() call type.begin() and type.end() if they exist. Member .end() and .begin() use is semi-discouraged in favor of standalone std::begin() and std::end(), because the stand-alone works for every situation, including native C arrays (std::end() has overloads for normal C-style arrays).

 

I do get what you're saying though... C++11 added several areas where the language interacts with the standard library, such as x =  {0,1,2,3,4} creating std::initializer_lists.

 

 

More specifically, do NOT put the std:: in front of them! Use ADL. If you don't put the namespace in front, the compiler can find the begin/end declaration for any type in any namespace

 

Thanks for the heads-up, I didn't realize that.




#5174611 Weapon statistics visualization

Posted by Servant of the Lord on 18 August 2014 - 08:52 PM

I don't want to see an animation play ten different armor tests one by one. Can the visual display be combined into one display?

 

If 'armor' is just a matter of thickness (i.e. a single value increasing), you could display it like this:

Displaying_data_with_non_numerical_visua

 

If there are various 'types' of armor that different bullet 'types' are good or weak against, you could display it as say, 5 suits of armor in a circle or semi-circle, and various amounts of penetration shown on each suit.




#5174586 TBSRPG

Posted by Servant of the Lord on 18 August 2014 - 06:27 PM

Do you know you can create development journals here on GameDev for your design ideas?

 

Blogging your design concepts might be a better fit for what you are doing. The forums are more suited for questions and discussions.






PARTNERS