Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 07 Nov 2002
Offline Last Active Yesterday, 08:32 PM

#5036508 Multithreaded programming

Posted by on 25 February 2013 - 05:13 PM

As people have said, multithreading needs to be threaded carefully (pun intended).


If you truly want to learn it, here's a fun thing you can do: make an audio player.  With SDL/SFML or whatever GUI lib you decide to use, create a Load, Play, Pause, Stop buttons.  Then there should be an audio playing in the background.  Try playing a really big audio file (100MB WAVs), without loading it all up at once.  Playing audio must be done on a separate thread.  Load/Play/Pause/Stop buttons must be able to signal that thread appropriately, and the audio thread must signal back to the main thread.

#5036275 pseudocode!

Posted by on 25 February 2013 - 02:45 AM

I find it strange that some people would write their pseudocode almost like they are writing actual code.  IMO, if you have to worry about syntax, then might as well write the code. My pseudo-code is usually just plain english mixed with coding symbols, which gets translated into comments, and removed once the code is tested and finalized.


For example,

if player's hit points > 0

  player runs around


  player stays, barks, and twirls

#5035971 A question about Github

Posted by on 23 February 2013 - 08:08 PM

They are not out of date, this just show you the latest commit date/message related to the file/directory.

After I switched from using WAV files to MP3 files all of my WAV files are still in the other directory, and they are not in the other.


Another strange issue is that only fetch works for me, not pull, and for my friend, vice versa.


Your local copy is probably messed up.


Every project should have a git url.  Something like git@github.com:username/projectname.git..  Go to another folder, then do git clone git@github.com:username/projectname.git.  git will create a new folder called projectname.  If you go to that folder, you should see the same directory structure as the one you see on github.


Start cleaning up your project from this folder.  You should read http://git-scm.com/documentation.

#5035900 A question about Github

Posted by on 23 February 2013 - 05:32 PM

This looks like either your or your friend probably made a mistake during commits with git.  github (or any other git hosting services) never assumes any directory structure.  If there's two copy of them, then one (or both) of you must have committed them.  I would suggest to sync up with your friend before proceeding, and read up more stuff about proper git logistics. 

#5030353 Motivation

Posted by on 09 February 2013 - 06:18 AM

1)  Only computer I have that is powerfully enough to handle anything is in my exercise/computer room that everyone thinks I spend way too much time in.


That's not a problem, but rather a solution that you spend time in a computer room.  I did the same in college when my laptop broke, and coded a game from the computer lab.  Everyone else thought I did it for a homework.



2)  My direction isn't clear.  Picking up a book and trying to gasp all it's concepts may not be the best approach.  Right now I'm trying to work my way through Android game development for beginners.    Considered also using an engine like uility and or UDK since they allow me to get right into what I want to do which is design the game.


Having your own direction, and stick with it, is the best way to go.  It doesn't hurt to try using a Unity engine or UDK, or anything.  You may decide later if you like them or not.  The most important point here is the fact that you decided to go that path yourself, rather than having somebody telling you to do it.



3) Getting stuck on a few concepts hurts.  I'm the type of learner who will be completely lost about something until I get that click where everything comes together.  Sometimes it is hard finding out what I'm lacking to make that click happen where it all joins. 


That happens when you still learning things.  It still happens even among pros.  Don't let that deter you.



4) Completely unrelated to programming but I have few problems with depression.  When certain people in life get me down I find it hard to do things that I enjoy.   I'm taking strides to get as close to over that as possible.   Doing nothing at all has never made me happy so I have to stop resorting to that as a possible solution.  


Then, it is your responsiblity to seek a medical attention.  FYI, everyone goes through depressions in their life.  It's not a specifically your problem.  Finding it hard to do things that you enjoy is exactly one of the symptomps of depressions.



Getting started isn't my problem at all as is finding excuses to go work so I don't have appear rude.  This is something I wish to and yea, it is taking a lot my time.   For about 6 months I worked a contract job teaching kids about computer science.  We explored games, websites and animation.   I enjoyed it so much it was the only job where I would have been willing to pay to be allowed to go into work.  I have a really hard time finding a balance between going around the clock to doing nothing at all.


That was the deepest second post I've ever made... anywhere.  


See, I don't think you are in as much of a bad shape as you think you are.  From this post, what you experienced seems "normal" to me.  You are learning, you are teaching, you earn money (though temporarily).  A lot of other people can't even function at that level.  When they go through depressions, they can't even get a job or learn anything.

#5027697 Game programmer

Posted by on 31 January 2013 - 07:14 PM

  1. Learn several programming languages, but master one (e.g. C++).
  2. Understand data structures, algorithm complexity, maths (linear algebra, algebra, calculus), and how they are relevant to game development.
  3. Make lots of games.

#5025625 Pushing objects

Posted by on 25 January 2013 - 07:22 PM

You have collision detection, right? From there on, follow these steps:


  1. Find out where player is in relation to the object. If player.y < object.y (assuming origin is on the top-left corner of the screen), then player is above the object. If player.x < object.x, then player is to the left of the object, and so on.
  2. Then, you need to determine when the 'push' happen. You need to figure this out yourself as each game is different.  You need some sort of trigger, when the push happens.  Does keep pressing the object will trigger the push?  What many seconds of pressing the d-pad till it triggers the push?  Or, do you need to press the button while close to the object to trigger the push? Does the player need a special 'push' animation?
  3. Once player is inside 'push' state, then you need to figure out how far is the push.  Different games do it differently.  Does each push pushes the object one tile away? Half a tile? Pixel-perfect push?

So yes, something as small as pushing objects still needs extensive thoughts and planning.


Happy coding!

#5021727 Religons in games

Posted by on 15 January 2013 - 02:34 AM

If you borrowed the religious elements strictly from history, then there's probably nothing wrong with it as it already happened.  For example, if you picked a Crusader class, you will automatically be a Christian.  But if you come up with your own views of what they are, or what the bonuses are for each religion (I don't know, something arbitrary like +25% wisdom for Christianity but +25% gold for Islam), then get ready for furious lashes from people. People will start complaining why religion A/B gets such bonus and attention while history proved otherwise, bla bla bla (pointless religious debate).


It's just better to come up with your own religions.

#5016904 The Beginning

Posted by on 02 January 2013 - 06:00 PM

My question is, like many before me have asked, where should I begin to look at game developing?


My first stop on the road was to look at http://www.gamefromscratch.com/post/2011/08/04/I-want-to-be-a-game-developer.aspx which is about a year out of date, which seems to be a long time in the development circles.


A brief on the article says to avoid C++, is this a wise choice for starting out?


Avoid C++ if you have no background whatsoever in programming.  C++ is merciless to beginners.  If you do have background in programming, then by all means learn C++ if you haven't already.  C/C++ are pretty popular among game developers, so there are plenty of tools and libraries.



My next stop would have to be Java, now I don't know if this is a misconception but I believe that it follows the same syntax and structure as C#, and seems to be widely support on the GDK side of things. Correct?


Java is widely supported for game development, and it has plenty of development tools.  It has, however, always been seen as the 'slow' language not suited for game development.  Having developed games in Java on embedded systems (512K RAM or less), I can say with 99% confidence that it's not true.  The people who say it's slow are usually low-level freaks who are concerned with 1 ns difference in their game loop, or people who don't know how to use Java and abuse the GC.



I'm going to preemptively try and answer a question I think I am going to get asked, and that is "What type of game do you want to make?"


In the long run my aim is to put together a RPG type game, with a few possible starting "Classes", walk around some open spaces, go into some dungeons, kill some bosses, win some loot, save a princess. You know that sort of thing.


I am well aware, that this is a long time goal, and I guess my first attempt would be something along the lines of "snake" or a simple "old school" game.


Yes, do start with something simple.  This is to get you familiar with what game development is like.  It is different from the typical application development.



Thanks for reading this and any help would be much appreciated.




You are welcome and welcome to game dev smile.png

#5011840 A Paranoid Programmer

Posted by on 17 December 2012 - 04:47 PM

I really think that professionals wouldn't call it game programming unless I make my own engine starting from OpenGL

You could make a video game any way you want to, and as long as that method allows you to create your dream end product it doesn't matter how you got there. Plenty of professional and semi-professional studios use unity. Unless you want to take it up as a project for fun, you should never "need" to make your own engine. The people at OpenGL already did that for us.

Yes, this is misleading. People use middlewares, that's why there's Unity, CryEngine, Unreal, Ogre 3D, and all that so you don't have to always start from scratch, even among pros.

It takes time to master multiple skills. To make a nerdy analogy, a fighter-mage combo requires more time to level up than a straight-up fighter or mage.

#5011334 passing an object as a parameter

Posted by on 16 December 2012 - 01:58 PM

Exams are a bitch, as it requires you to read your professor's mind.

Create a fillList() method that takes a reference variable of type Ticket as a parameter

void fillList(Ticket ticket) {
   // insert ticket to your list

In Java, everything is passed by references except primitives (int, bool, long, float, double).

how would i go about passing an object of an inner class as a paramitar to a method in the outer class?

You can invoke a method in the outer class from the inner class.

class OuterClass {
	public void someMethod(InnerClass ic) {

	class InnerClass {
		public void doStuff() {
			someMethod(this);  // OK

#5008488 iOS Game development on Windows- What are my options?

Posted by on 08 December 2012 - 07:38 AM

iOS development is always done on a mac, not Windows. Apple never made their SDK available for Windows. I haven't used Macincloud, but I wouldn't suggest doing that. When you sign up to be an Apple Developer, you are required to sign your build before you can put that on a device or release it to the market. This key needs to be stored on your machine, and you would need to connect your iPhone to the actual physical machine before you can test your app. You can't do that over the cloud.

#5007200 [C++] - Multithreaded Bubble Sort

Posted by on 04 December 2012 - 03:46 PM

Look up merge sort - it inherently merges two sorted lists together, you'll find how to do it there. The result is basically a simplified selection sort, taking advantage of the fact that the two lists are already sorted, which runs in O(n) time and uses a temporary array. You could extend this to an arbitrary number of lists, or you could do the merging in parallel too (which would be more useful, because doing the merge step on a single thread defeats your use of multithreading in the sorting step).

Is this for a school assignment, by the way? If not, you might be better served by trying to implement a multithreaded merge sort, which is more interesting and is actually useful.

I second this. Split array into two, spawn two threads and each handle its own segment. Recursively do this until you reach the smallest subset.

Merging the array shouldn't be too compliated either. Since each thread spawns two subthreads, you just wait until both threads finished executing, then merge, then flag its parent thread.

#5006081 Does anyone else struggle with problem solving?

Posted by on 01 December 2012 - 01:53 PM

For example, the Tic Tac Toe game, I keep trying to do it the exact way that the other guy does it, and I get stuck, and constantly refer back to his code to see what I am doing wrong. Not to mention whenever I try doing it by myself, I constantly think about that persons code. So I can never try it myself.

If you can't think of a solution for a tic-tac-toe game, then maybe it's too much of a challenge for you. Step back, and start something much simpler, like a number guessing game, text-based adventure, dice rolls. I have no idea how many useless/random programs I have written back in my GW/QBASIC days: draw random lines, circles, rectangles, compound interest calculators, address books, fake shell, etc.

It's a good thing that you are doing this because you want to learn. Keep this attitude, and never stop writing code.

#5005533 Does anyone else struggle with problem solving?

Posted by on 29 November 2012 - 07:53 PM

I find this a problem common among beginners. If I give you code, you can understand the process and what the code does. But if I tell you to write a brand new code from scratch, you are stuck right from the beginning. Did I run into this when I first started? I don't remember. But I see this all the time.

The era of the Internet today makes it easy to copy and download code snippets, which encourages lazy thinking. You see this all the time on blogs. People would comment "Code doesn't work! HELP! HOW DO I FIX!?!?". And this is coming from using a simple code how to convert a file to a string object, for example. I'm not pointing out that the code doesn't work, but I'm pointing out the sheer laziness in people that they expect things to fall on their lap and work. When things not operating the way they expected, they don't bother to find the solution themselves.

It only comes from experience, and it has to be the right experience. Always write code from scratch. It's okay to look at code from web, but only as a reference, not meant to be copied directly to your code. 90% of the time that code won't be compatible to your code anyway. Never, ever, copy-paste and use code you get from web, conferences, CDs, or anywhere else. It's okay to use prepackaged libraries (like STL, SDL, Ogre, 3rd party libraries), the ones that you don't have to look at their code to use it.

How can a writer be a writer, if all he does is copy someone else's work? Programming the same way.