game-engine

SDL_PollEvent() stuttering while idle?

一笑奈何 提交于 2019-11-27 14:25:00
I've cobbled together a very basic game loop in C++ using SDL2, and I've noticed that every few seconds, SDL_PollEvent seems to be unusually slow, even when nothing is happening. I sent my deltaTime to console every loop, and its about 100ms difference on the cycles that SDL_PollEvent is lagging. I've already confirmed that it's something with this function by moving my timers around, but I'm not sure where to diagnose the issue further. My loop: while (!quit) { uint32_t startTime = SDL_GetTicks(); while (SDL_PollEvent(&e) != 0) { std::cout << "Event: "<< e.type << std::endl; // Added later,

Detect/receive multiple key-presses at the same time in DOS?

巧了我就是萌 提交于 2019-11-27 08:39:30
问题 I'm in the middle of writing air hockey in tasm and I have encounter a problem which is how I get two keys/clicks at once because I need to get both click at once to move both players in one time and Im trying a lot but I don't think I have a way to doing it. I heard that I need to read from the buffer directory and see what keys are there and read each one individually but I don't really know how to do this. 回答1: Do you mind working with scancodes? I know this is not the simple, drop-in,

Game engine for iPhone/Android [closed]

时光总嘲笑我的痴心妄想 提交于 2019-11-27 00:18:39
问题 Is it possible to do cross platform game engine for iphone and android. if its how can i do this. what are all thinks i need to study to do this. 回答1: Check out Cocos2d-x. It's completely free and open-source. There is also http://www.appgamekit.com It's something I am interested in. It supports "Basic" as well as "C++". I think that Marmalade is really powerful. I've messed around with it. And highly recommend it. If you are only targeting Android and iOS for a 2D game, I would highly

Finder what point is to the left of a line/point after spinning it

坚强是说给别人听的谎言 提交于 2019-11-26 22:11:14
问题 I am currently trying to write a shader in unity that draws a triangular pattern around countries in a risk-styled game if both countries are not owned by the same player (visual aid to see your borders). Right now, I'm having an issue with making the shader set the countries properly. It always sets country 0 to the left, and country 1 to the right - country 0 and 1 are set programically. The line, a border, can be between 0 and 359 degrees. How I find the countries 0 and 1 is I draw 3

Why transforming normals with the transpose of the inverse of the modelview matrix?

我与影子孤独终老i 提交于 2019-11-26 17:15:02
I am working on some shaders, and I need to transform normals. I read in few tutorials the way you transform normals is you multiply them with the transpose of the inverse of the modelview matrix . But I can't find explanation of why is that so, and what is the logic behind that? Invalid Take a look at this tutorial: https://paroj.github.io/gltut/Illumination/Tut09%20Normal%20Transformation.html You can imagine that when the surface of a sphere stretches (so the sphere is scaled along one axis or something similar) the normals of that surface will all 'bend' towards each other. It turns out

SDL_PollEvent() stuttering while idle?

不羁岁月 提交于 2019-11-26 16:37:31
问题 I've cobbled together a very basic game loop in C++ using SDL2, and I've noticed that every few seconds, SDL_PollEvent seems to be unusually slow, even when nothing is happening. I sent my deltaTime to console every loop, and its about 100ms difference on the cycles that SDL_PollEvent is lagging. I've already confirmed that it's something with this function by moving my timers around, but I'm not sure where to diagnose the issue further. My loop: while (!quit) { uint32_t startTime = SDL

Java Main Game Loop

安稳与你 提交于 2019-11-26 10:59:20
问题 I am writing a game loop, I found the code in the example below here. I have also looked at other ways to do a game loop, such as from this article. I couldn\'t get any of those ones working though. So I kept with the one from the first link. What I would like to know: Is the way I wrote my game loop a good way to do this? Any suggestions? Should I be using Thread.sleep(); in my game loop? Here is my current code: public void run(){ long lastLoopTime = System.nanoTime(); final int TARGET_FPS

Why transforming normals with the transpose of the inverse of the modelview matrix?

痞子三分冷 提交于 2019-11-26 05:18:47
问题 I am working on some shaders, and I need to transform normals. I read in few tutorials the way you transform normals is you multiply them with the transpose of the inverse of the modelview matrix . But I can\'t find explanation of why is that so, and what is the logic behind that? 回答1: Take a look at this tutorial: https://paroj.github.io/gltut/Illumination/Tut09%20Normal%20Transformation.html You can imagine that when the surface of a sphere stretches (so the sphere is scaled along one axis