Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 03 Sep 2008
Offline Last Active Today, 02:14 AM

#5097552 space wars

Posted by on 28 September 2013 - 11:26 PM

Switch the order of your rotate and translate.

When you want to rotate an object on it's axis, rotation should come first.

However, since openGL transforms are a stack, what happens first is what is closest to the code.

So the order of transforms of opengl is actually resversed.


This is kind of confusing at first, but is really logical when you need heirerchial animations (like a skeleton). It's also required because of the linear-algebra behind openGL.


So what you should be doing is:

void DrawShip(GLfloat position_X,GLfloat position_Y, GLfloat position_Z, GLfloat rotation,GLfloat color)
glTranslatef(position_X,position_Y,position_Z); //move only after the ship is rotated.
glRotatef(rotation,0.0f,0.0f,1.0f); //Now rotation will happen before movement
glBegin(GL_LINE_LOOP);glVertex3f(0.0f,-0.25f+position_Y,0.0f); glVertex3f(-0.25f,-0.5f+position_Y,0.0f); glVertex3f(-0.5f,-0.5f+position_Y,0.0f); glVertex3f(-0.0f,0.5f+position_Y,0.0f);

#5097494 3 Questions on my mind about (winsock)

Posted by on 28 September 2013 - 03:18 PM

1. Yes identify your clients. Usually a server has more than one game at a time. So besides "not mirroring client 1 back to itself", it's also about "not sending client 3 which is in another game" back to clients 1 and 2.


2. You can use asynchronous io. Look up TCP IO selector on google. It can handle many connections on a single thread. The problem is that It is more difficult then using threads, so if you only have less then 10 connections at a time, don't think about it and keep using threads.


3. Some people like to use UDP instead of TCP for multiplayer. It is much faster than TCP, and you can also broadcast to more than one player at a time. The problem is UDP packets can arrive out of order, so you need to re-order them. If you are using TCP, don't worry about it. TCP is basically a high level protocol over UDP that includes ordering and error handling. If you are making a realtime game, I would turn on TCP_NODELAY to prevent TCP from delaying transmission of your data. These delays can reach several 100s of milliseconds.

#5095280 Trouble getting a stable framerate (C++/Allegro 4)

Posted by on 19 September 2013 - 04:22 PM

limit your speed to a sliding window:

1. Keep a sliding window (queue) of your last 50 frames' times (or any other number)

2. If your current frame is too far ahead of it's time: You want 50 FPS, but a second has not passed since the last 50 frames, then sleep a little bit.

3. You will also want to check the last 2 frames, to set an upper bound for speed: It is ok for the game to accelerate to compensate for missed frames, but there should be a limit on the maximum rate. If you do not do this, and you have some long frames, then your game will jitter.


Regardless of these points, you should separate your logic code from your render code. Your logic should never fall behind as a result of frame drawing speed. If you use a single thread it should look something like this.

   bool wasUpdated=false;
   int targetLogicTime=CalculateTimeFromSlidingWindowAsMentionedAbove();
       //calculate logic:
       calculateStuff();//put all your logic code here
       //limit and stabalize your FPS:
     drawStuff();//Draw everything here
       sleep(1ms);//give the CPU time to rest to avoid busy waiting.

Basically, this loop makes sure:

1. Your frame rate doesn't explode

2. If your drawing rate goes down, your game rate stays the same (car still takes 60 seconds to drive from A to B regardless of frame rate)

3. You don't draw redundant frames (frames where nothing has changed)

4. If available, you give the CPU some time to rest. (Very important for desktop CPU temperature, and laptop/phone battery life).


You can get better performance if you do this on two threads, but that's a whole other story.

#5092561 c++11 Multithreading not working! Please help!

Posted by on 08 September 2013 - 05:20 PM

You have a race condition.

Thread 1 can notify thread 2  before thread 2 ever starts waiting.

So thread 2 will continue waiting forever because thread1 notified it when it wasn't waiting.


It is customary in these situations to wait and lock on the same mutex. That way you never miss a notification.

#5092523 Seeking Advice on Windows IDEs, Cygwin, Windows versions, et. al.

Posted by on 08 September 2013 - 01:09 PM

Visual Studio is an Amazing C++ IDE.

By far the best C++ IDE I have encountered anywhere.

That said, getting the full experience is very expensive. (Even after you but V.S. you still need to shell out for some good plugins).

If you are a hobbyist, and are not ok with the express edition, don't use it.


If you are looking for alternatives, you can use Eclipse CDT or Netbeans.

Disadvantage is, they are very slow and poor in features.

Also, they were originally designed for JAVA, so some of the design seems clunky.

The advantage is they are free, and come preloaded with alot features such as refactoring.

Also, they work with several compilers: Cygwin, Ming32, etc...


Always use an IDE, preferably with an integrated debugger. Even when working with Linux.

#5090663 Should I learn how to draw?

Posted by on 31 August 2013 - 02:44 PM

'images' like in real life pictures or just other peoples' drawings?

Doesn't matter. It's sort of like tracing over another picture. So it can be a photo, a sketch or anything else. The obvious advantage of drawing by yourself, is that you can get any picture you like. The obvious disatvantage is that it takes way more time then searching on google.



well if it takes just takes couple months to learn how to draw comic-book/cartoon art(assuming that I draw 2-3 hours a day and reach these results), I see no harm in learning how.

Make sure you take a course, or read a book. What a lot of people who do not draw fail to realise is that drawing is methodical. Just like you learn Loops, Methods, Data-Structures and Algorithms before you can program, you need to study drawing techniques. Just sketching on a piece of paper for a couple of months will not yield good results. It would be the same as opening an editor and writing random code smile.png .


I took a short course and practiced at home and it did wonders for me.




Then again, some don't draw pleasure from drawing I wish you luck however, it is a skill that will elude me forver, due to a lack of passion and patience for it.


Agreed, no amateur game-dev should draw unless it fascinates him or brings him some enjoyment. You can make excellent games without knowing how to draw. 

#5090605 Should I learn how to draw?

Posted by on 31 August 2013 - 10:34 AM

also, Is drawing neccesarry for 3d games?

No. At the higher levels, you nead to model over a sketch. But you can download an image from the internet, and model over that.




should I learn how to draw too? like what if I want to test out some games, do I need artwork for it?
I mean im not trying to be michelangelo or anything, I just want to be competent enough to draw figures for game testing.

No, For testing purposes, you can use ugly art (stick figures/ 8 bit).


Regardless, learning how to draw is fun.

Alot of people don't try to learn it, and assume you are only born with it.

Learning how to draw decent comic-book level takes  around 1-2 months, art if you have no prior knowledge .

And you need a scanner to use your drawings in a game.

Do you have 1-2 months & a scanner?

#5087254 10 distinct ways to start a game programming (for beginners)

Posted by on 19 August 2013 - 04:31 AM

I like to start my game protoypes as text. Since I am not an artist, I find generating sprites and models very boring and time consuming. As such the whole gfx-engine stuff doesn't saave me any grief.


So what I do is prototype my games as text:



Once I figure out the game is fun, I spend time adding graphics:



But basically I have a very playable game to prototype before I ever get started with the graphics portion.

The biggest plusses:

  • If I want a new sprite, I just add a new letter.
  • I develop on mobiles, but I can easily debug on my PC.

This can also somewhat work for an FPS style game, if you start out top view, and add camera angles later.

#5082046 Non-random evasion in turn-based games?

Posted by on 31 July 2013 - 04:05 PM

A game I played had a defend mechansim where a character could defend instead of attacking. This would skip your chance to attack, but would reduce the damage done to said character. This was especially interesting when battling ranged units.


Technically this isn't evasion, but it's a similar concept.

#5081506 Are RPGs (role playing games) and ARGs (alternate reality games) considered m...

Posted by on 29 July 2013 - 11:49 AM

I voted you down, but in retrospect, your post was a good one (helpful, polite, and informative), it was just that I think the information is inaccurate - at least, within the meager limitations of my own knowledge!
Unfortunately I can't undo the downvote, so I upvoted one of your posts in another thread - feel free to correspondingly downvote mine if you think my post is inaccurate or unhelpful.


Sir , I have never been so politely down-voted. Kudos to you, I shall regard this noblest of down-votes as an ode to your chivalrous nature. 

#5081289 Are RPGs (role playing games) and ARGs (alternate reality games) considered m...

Posted by on 28 July 2013 - 04:06 PM

RPGs are like Dungeons and Dragons. Mostly medieval fantasy (some are futuristic cyber-punk games). You mostly play wizards and warriors battling monsters and save the kingdom.


Alternate Reality games (never heard them called ARGs before) are like Second-Life. They usually don't have an objective, but are like building an alternate version of your life. You buy a house, decorate it, open a buisness, etc... There is no real objective to the game, except interacting with other people. Alot of the time it is also more realistic. You live in a regular city (or a cruise ship as I recently saw in one game).


Some RPGs imitate some Alternate reality games and allow you to buy a house. But that is usually not the object of the game. You still have to go battle dragons (or robots) in order to have fun.


ARGs tend to be targeted at a more grown up crowd. An ARG is like a 3D fake Facebook where everyone has an alter-ego.


RPGs, while also played by grown-ups, also cater to younger audiences. (I'm no child, and I'd play an RPG over an ARG any day)

#5079000 How does the programmer merge systems together in the industry

Posted by on 19 July 2013 - 01:58 PM

You usually try to keep the merging to a minimum.

You define an API that borders the code you are working on now with others.

This API-border is very well defined.


The API is a set of functions like: Enemy.move(x,y).


One programer will create the function "move" which moves the enemy. The other programer will create the AI function which tells the enemy when to move.


The only thing they have to decide in advance is that enemy has a move function that takes x & y. This is the API.


The AI programer does not care about how the enemy moves (collison detection etc...).

The "move" programer does not care about why the enemy moves ( the AI ).

And the only thing they decided in advance, is that move takes two parameters: x & y


You can define such API borders in advance any time you want to split the job.


So basically there is a well defined border, and usually a lot of discussion goes in to that. The better you are at the design stage, the less you work you will have merging it later. 

#5078257 Jumping - What did I do wrong?

Posted by on 16 July 2013 - 03:00 PM

1. This code can't loop by itself. 

2. If your computer freezes, it's more likely that you have corrupted your memory than an endless loop. (Unless you mean that your game freezes).


Since there is not enough code to analyze this, my suggestions are:

1. Use a debugger, and break excution (see where your computer is stuck).

2. If a debugger is unavailable, add some printf's and print the character ID + the character state. You should be able to figure out what's wrong. (Dump it into a log file)

3. Post more code, so someone can figure out your problem.


You should really try suggestions 1 & 2 first, unless you want to wait for someone to figure out the problem.

#5077241 Texture alpha blending?

Posted by on 12 July 2013 - 07:08 PM

What are you using to render?

IF it's OpenGL did you gl_enable blending?

#5077180 Free / Open source multiplayer servers

Posted by on 12 July 2013 - 01:20 PM

I get the impression you are looking for something higher-level than the solutions being offered to you. Something like Smartfox Server or Photon would serve, but unfortunately they aren't free.


I could use any message queue for messaging, but I was hoping to get some added value besides packeting over TCP/IP. Message queus also tend to lack a security layer, which is a big deal over WAN.


Thanks for the links, I'm a complete newbee in multiplayer, so I was unaware of these.


Regarding Smartfox, 100 concurrent users should be enough at first. I see that smart-fox community edition supports it, but I can't find the license on their site. Do you know if I can use the community edition in a commercial game? Also Photon's 100 users for 10$ might also be fine, since if I use my own I'll probably pay ~10$ for hosting.


Also, what do you guys think of the Google offer I mentioned above? I cringe at the thought of forcing people to use Google+, but it looks very easy, and very robust. Also, I couldn't figure out the pricing.