Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 18 Oct 2005
Offline Last Active Oct 24 2016 05:25 PM

Posts I've Made

In Topic: peekmessage while vs if (main/game loop)

29 September 2016 - 03:07 PM

Imagine you render scene with vsync turned on.
If you go with 'if' implementation, you will process single input event per rendered frame.
But there will be lots of events, especially when mouse moves. If you will process only one event, render frame, wait for 16ms (vsync on), then with simple mouse movement you will create some work for many seconds upfront. Scene update will lag to the point where app will become totally unresponsive.
So you must go with 'while' loop, processing all inputs before you start rendering.

With 'while' it sounds like waiting till a message occurs.

You don't wait for events with PeekMessage(), you would wait with GetMessage().

The if version won't run any update or rendering logic unless peekmessage returns false so it should work properly.
All game and rendering code is inside the else block, it should even be a tiny bit faster since it only has to do the check for VM_QUIT (and not the extra assignment and checks for run like the while version does)
It also has the advantage of exiting almost immediately on a VM_QUIT, the while version will run through one update before exiting.

In Topic: How Much Lua Should I Learn To Use Unitale.

09 August 2016 - 11:06 AM

Roughly 542 litres but it is highly dependent on your project so it is impossible to give an exact figure.


If you know how to program (in any language) you can just dive in and learn whatever it is you need for your project as you go along, Lua is not that different from other mainstream programming languages.

In Topic: Only 12 Enemies, And My Fps Drops To 30, Why Is That?

02 August 2016 - 09:56 AM

Guys, very big thanks to all for all the helpful answers, this morning I couldn't load 12 enemies, now I'm loading 70, I'm very happy.


Lactose, I haven't thought about that, and you are right, basically the bigger the fps is, the smaller the difference in milliseconds is. 


I was just wondering why my fps would jump from 100 to 111 every time, now when I think about it, 1000ms/100 = 10ms and 1000ms/111 = 9.09ms, and only the rounding error miscalculates the fps with 11!


EDIT: Alberth, I just installed some free profiler called VerySleepy, and it told me that printf takes 99% from the thread, and I checked all my code, I didn't have any printf functions at all.


But what I did have is "snprintf" and I guess verySleepy counts snprintf() at least as heavy as printf(). Luckily, I need this function to be executed only in the beginning of my game, not every frame, so I moved it out of the loop and fps jumped from 100 to 166! This snprintf is a very heavy function....

void MMORPG::getBoneLocation(Shader& shader)
    for (unsigned int i = 0 ; i < 100 ; i++)
        char Name[128];
        memset(Name, 0, sizeof(Name));
        snprintf(Name, sizeof(Name), "gBones[%d]", i);
        boneLocation[i] = glGetUniformLocation( shader.programID, Name );

EDIT: Guys, VerySleepy continues to show that printf takes 90-100% of some thread. I checked all parts of my source code, I even tried commenting everything, fps went crazy and the profiler still says that printf works in background somehow, although I checked multiple times that I don't have anything that says 'print' in my whole project.


First I thought that the reason is that my project is set up as a console application in codeblocks, but I changed it to a GUI application and it still cries about printf, I profiled the printf, and the only thing it shows is where the function is declared in stdio.h. Any ideas?


it could be any function that outputs data to stdout (the console / terminal / IDE), a lot of such functions could be implemented as wrappers around printf), normally stdout will be line buffered when it is tied to a terminal (each newline will cause the buffer to be flushed which is a fairly slow operation), if you need to push large amount of text to the console you should flush manually when appropriate (once per frame, between levels, when the app closes, once the buffer is full, or whatever suits your application)

if you use c++ you can call std::ios_base::sync_with_stdio(false); and then avoid using std::endl (just throw in \n for linebreaks and flush manuall using std::flush once per frame or something) and for C you can use setvbuf to change the buffer mode on stdout, just make sure you have a big enough buffer for your needs.


If you are using debug builds quite a few third party libraries will push data through stdout or stderr to your IDE, make sure you are using release builds when you are profiling.

In Topic: Unity 3D pricing structure changes - Whats your opinion?

08 July 2016 - 10:19 PM

Generally speaking I'm against renting my tools instead of buying them.

From the Unity3d FAQ:

If you subscribe to the new Unity Pro for a minimum of 24 consecutive months, you get to keep the version you have if you notify us that you are stopping your subscription, and choosing pay to own. At that point, you will stop receiving access to Pro tier services, new features and upgrades. You will receive the next 3 patches. We reserve the right to grant access to additional patches in the event that we find severe bugs. If you later resume subscribing, you will still own the perpetual license you elected but again start receiving updates, fixes and services. Once you have subscribed for another 24 consecutive months, and should you then elect to cease this new subscription, you will then be granted a new perpetual license of the then current version of Unity.

In Topic: Building a game like "Game of War"

01 June 2016 - 03:32 PM

Ok. I have your attention. You guys are the experienced developers. You say it takes a lot of people and experience to make a game. I believe you. But when I look at the game it looks easy to me to make. If honestly it does take a lot of people and a lot of time I'll drop it. But I'll explain again.
I use a wallpaper for the kingdom. Designate spots for you to build buildings. I need visual art work for each building. 20 buildings. All the game mechanics are done. All it needs is coding. World map is a plain flat surface with resources to gather, kingdoms of other players and monsters to hunt. Can it really be that hard and time consuming? If I were to draw on paper and use things on papaer I can make the game on paper in 40 hours or less. Why does it make it so much harder to do on the programming side? You all make it sound like I'm building a hard game. Its not like star craft, wow, lol, charter. Those are hard games. No story. No videos. The game mechanics are finished. Can it really be that hard? :( combat system like chess with 7 units. That's all. U ether move or attack or skip turn. No spells. Turn based. It really can't be that difficult. I could careless for 3d high quality graphics right now. 2d pixel art is fine. 2d in general art is fine. It doesn't need to high quality graphics. Look at mine craft. Candy crush. Simple stupid graphics. Even angry birds. I don't need 3d amazing animation.

So I use unity and gimp. Any other programs I need?


You probably want something to record and mix sound and music as well. (Audacity is free and probably good enough to start with).


And yes, it can really be quite hard, the biggest challenge for you will most likely be to prevent rampant cheating while still keeping the server side scalable and fast. Doing one of those things is reasonably easy if you know what you are doing, doing both at the same time is extremely difficult, The client side programming of those games is fairly straight forward but you still want some high quality artwork (which is both time consuming and difficult to produce)