Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 06 Oct 2009
Offline Last Active Yesterday, 07:17 PM

Posts I've Made

In Topic: What now?

Yesterday, 01:30 PM

I have some ideas for some games, but they are too advanced for me to create at this point.

Still, I want to create the engine myself, for the knowledge.

Where can I possibly learn this?


I have also heard that to make games with C++ you need DirectX or OpenGL.

What are these, and why do you need them with C++, and not Java?


Also, thank you for the links! I will read them!


Actually, depending on what kind of game you are making, you won't necessarily need either Direct X or Open GL.  Have a look at NetHack, for instance.  That is a full game where all you need is the console.  Also, if you are making a Othello, Chess, Mine Sweeper kind of game, you can just use a normal canvas type of GUI object for your operating system.


Of course, Direct X and Open GL are graphics libraries that are closer to the hardware itself, and are much faster than any canvas any GUI component can give you, at least it were so in the past.  It is also specialised in processing graphical data, wether it is 3D or 2D, so it beats anything you would do in pure software.  Nowadays you can even offload computations formerly done on the CPU to the processor on the graphics card.  It is also much more complex (but not necessarily so much more complex than to write graphics application in pure software, which is slow), so it really depends on which aspect of game creation you are looking into at the moment.  You don't explicitly need C or C++ to use Open GL, I believe you can nicely make Open GL applications in Java.  Here is one project aimed to enable that, that I know nothing about: http://jogamp.org/jogl/www/


If you start small, you will slowly master the art of making games.  It is much more fun to make a Mine Sweeper clone than you think.  There are some hidden things that are not apparent right from the start, for instance, what if you click a large area that has no surrounding mines?  There you would stumble across making a recursive search to find all the adjacent safe slots on the map.  Recursion is not really hard once you have learnt it, but it may be hard entry point, just like the concept of pointers, for instance (which Java doesn't have, just references).  


Good luck!  You are into a lot of fun learning. :)

In Topic: Functions

17 July 2014 - 07:36 PM

I was going to elaborate a bit more than I did, but I had too many distractions around me when I posted, so it was hard to think.  Servant of the lord filled in a lot more than I would think about too.


I just wanted to add that if you are thinking that you will skip declaring functions, and just put everything above each other, consider this example:

int functionA(int count) {
  count = functionB(count);
  return count;

int functionB(int count) {
 if (count > 0) functionA(count);
 return count;

void main(){
 functionA(10);  //Yes you can call functions that return some value, without keeping the value.

Here functionA needs to be above functionB, but functionB needs to be above functionA.  This is obviously impossible.  I know that this exact example is artificial and silly, but there are times where you can't avoid it.  I am not sure if it only happens with recursions, but I couldn't come up with any better examples right now.


To solve this problem, you just add the declarations for the functions at the top:

void main();
int functionA(int);        //The only thing C/C++ cares about, is the size of the input variable
int functionB(int count);  //But for us humans, it is easier to read if you also add the name

You can think of it like this:

Pretend that you are reading your own source code one line at the time from the top, evaluating what is happening as you go through the lines.  You know nothing about anything you haven't read yet.  (Ignore the fact that you actually wrote the code and _do_ know for this exercise.)  Then you see that there is a functionA, so you start processing that function.  Inside, there is a call to functionB, but you have never heard of such a function.  What does it do?  How many parameters does it take?  What size are those parameters?  What does it return?  (Note that the return value is not part of the signature at link-time, but that is a different concept, see function overloading.)


You don't know any of those things.  The same goes for the compiler.  That could be solved by having one pass just to collect this information, before the real compilation phase.  Another solution is to do what the designers of C did - add prototyping to the language.  Then you can do both things you needed two passes for in just one pass.

In Topic: Functions

17 July 2014 - 04:45 PM


Alright im not to sure if im using the right terms. Anyhow i wanted to know if there is a difference in declaring/initializing a function before the main or after it.


- Is it better to declare it before main or after?

- What affect does it cause?



// function delcared before main()
char askYesNo1()

// main function
int main()
return 0;

// function delcared after main()
char askYesNo2()



If you do like this:

char askYesNo1();
char askYesNo2();

// main function
int main() {
 return 0; 

char askYesNo1() { .... }
char askYesNo2() { .... }
You can have main() on top, and everything after, if you want, it is really the 'proper' way to do things.  How would the compiler know what functions you are having if you are not telling the compiler somehow, unless the compiler would do a two-pass operation?



In Topic: Hard Copy or Soft Copy?

17 July 2014 - 04:35 AM

I honestly feel like storing all my data on DVDs would be a mite bit crazy.  That's over 200 4.8GB DVDs just to store a terabyte of data.  That's 7 pounds of pure DVDs, almost a foot high (based on some random website).  They just don't have the density for viable large-scale backup.  Even at smaller scales, flash drives are more efficient in my book.


If you're serious about backing up all your stuff, the best solution is to have multiple vectors.  Personally, I've never had a hard drive fail, but since that is a real threat, a RAID system of some kind coupled with a remote backup of some sort (cloud or another RAIDed machine) should be all you need.  The odds of both your local store AND remote store simultaneously dying in a horrible accident are about as high as the odds of a tornado hitting your papers anyway.  Unless a massive EMP destroys everyone's electronics, in which case your tax records are no longer terribly important in the grand scheme of things.


Because the zombies are coming.


In the 90's I had hard drives that just outlasted their usefulness, but in the beginning of the 2000's, I had so much hard drive failures that I started questioning how viable hard drives would be, with the failure rate I experienced back then.  One of the drives was even subject to a massive class action lawsuit in USA because of its massive failure rate.  I was fortunate though...  The hard drives started 'clicking', while the whole system stalled as a pre-warning that it was going to die really soon.  That enabled me to copy all the data off the drive before I stopped using the defective drive.  I also had a drive that died, but if I cooled it down a bit, it lasted long enough that I could start it up for a little while.


Oh, and about SSD's that LennyLen is talking about, one colleague of mine had a drive that stopped working in aeroplanes, and ended up with a nice 'sector 0 not found message', losing all his data.  I am not sure if he decided to send the drive for recovery or not, but losing data is a really bad feeling, even if the data is not really that important.



Edit: (Added this here since I discovered that I had the last post anyway, despite GameDev telling me there were new posts here.)

I do get annoyed by people thinking that only storing on the cloud is a backup (e.g., Google's advertising from ChromeOS, saying you don't need to back them up - you do).


That is a bit ironic, since if you ask anyone on the Google Drive team, they will clearly tell you that Google Drive is NOT a backup service.  In fact Google won't take any responsibility for any data you lose in the cloud, for whatever reason, stating that it is YOUR responsibility to make sure you have enough redundancy on your data.


If you think about it, it is pretty obvious that you have to take care of your own backup strategy, not rely solely on one single backup strategy.

In Topic: Funniest line of code ever ?

17 July 2014 - 04:12 AM


This was during a C programming class, someone wrote that code to 'use' a null terminated string. Both me and the teacher spent quite a while staring at it, trying to 'guess' why it crashes.

void use_str(const char * str)
	//do something with char in *str

Also, a nice attempt to hardcode the password in php that someone I know did on their personal filesharing website (I'm not good with PHP, so this code might be wrong, but you get the idea laugh.png ).

if ($pass === "password1" || "password2")


Ah that zero terminated string thing must have been crashing bad unless you sent NULL to it... biggrin.png


The PHP code example, I believe is more common that you would like to know.  Seems like perfectly legal PHP to me, but I assume the point is that you should never put your password in clear text in the source file?  


It has been a while since I have touched PHP now, but I used to do a trick like this to make sure I had number values from user input fields:

$user_input += 0;

//Then use in an SQL query, safely knowing it can't be escaped...

Not sure if that is still regarded as a safe trick to force number values.


-- Oh, and I actually used the 'eval' function on data that was sent from the user once...  Not a good idea unless you really are knowing what you are doing.


I should have written down all the stupid errors I have done during the years, and I would be able to fill a whole book lol...  biggrin.png