game-loop

Android: Understanding OnDrawFrame, FPS and VSync (OpenGL ES 2.0)

二次信任 提交于 2020-01-01 02:28:10
问题 For a while now I've experienced an intermittent 'stuttering' of the sprites that are in motion within my Android Game. It's a fiarly simple 2D OpenGL ES 2.0 game. (This is an ongoing problem which I have re-visited many times). In my game loop, I have 2 'timers' - one which will log the number of frames in the previous second, and another which counts the time (in Milliseconds) from the end of the current onDrawFrame iteration to the start of the next. This is what I've found: When not

Android: Understanding OnDrawFrame, FPS and VSync (OpenGL ES 2.0)

点点圈 提交于 2020-01-01 02:28:07
问题 For a while now I've experienced an intermittent 'stuttering' of the sprites that are in motion within my Android Game. It's a fiarly simple 2D OpenGL ES 2.0 game. (This is an ongoing problem which I have re-visited many times). In my game loop, I have 2 'timers' - one which will log the number of frames in the previous second, and another which counts the time (in Milliseconds) from the end of the current onDrawFrame iteration to the start of the next. This is what I've found: When not

How to make timer for a game loop?

拜拜、爱过 提交于 2019-12-20 15:29:44
问题 I want to time fps count, and set it's limit to 60 and however i've been looking throught some code via google, I completly don't get it. 回答1: You shouldn't try to limit the fps. The only reason to do so is if you are not using delta time and you expect each frame to be the same length. Even the simplest game cannot guarantee that. You can however take your delta time and slice it into fixed sizes and then hold onto the remainder. Here's some code I wrote recently. It's not thoroughly tested.

Simple Game in C# with only native libraries

我是研究僧i 提交于 2019-12-20 09:47:44
问题 I could find a set of java 2D game tutorials and android game tutorials which uses only native graphics libraries . I'm looking for something similar in C# ( without DirectX or XNA) I found this game loop skeleton , but it doesn't tell how to Render the Graphics. Target is to simulate a simple Electronic device. I need to show some graphical output as user "presses" some keys on the keyboard quickly.Hence it looks like an arcade game. For example As the user presses one of the arrow keys a

android game loop vs updating in the rendering thread

放肆的年华 提交于 2019-12-18 10:37:11
问题 I'm making an android game and am currently not getting the performance I'd like. I have a game loop in its own thread which updates an object's position. The rendering thread will traverse these objects and draw them. The current behavior is what seems like choppy/uneven movement. What I cannot explain is that before I put the update logic in its own thread, I had it in the onDrawFrame method, right before the gl calls. In that case, the animation was perfectly smooth, it only becomes choppy

Why is a “main” game loop necessary for developing a game?

[亡魂溺海] 提交于 2019-12-18 10:26:43
问题 I find that most game development requires a main game loop, but I don't know why it's necessary. Couldn't we implement an event listener and respond to every user action? Animations (etc.) could then be played when a event occurs. What is the purpose of a main game loop? 回答1: The argument that you "need a loop because otherwise what calls the event listener" does not hold water. Admittedly on any mainstream OS, you do indeed have such a loop, and event listeners do work that way, but it is

Java TimerTick event for game loop

六月ゝ 毕业季﹏ 提交于 2019-12-18 08:54:06
问题 I tried making a game loop in Java using the Timer from java.util.Timer. I am unable to get my game loop to execute during the timer tick. Here is an example of this issue. I am trying to move the button during the game loop, but it is not moving on the timer tick event. import java.util.Timer; import java.util.TimerTask; import javax.swing.JFrame; import javax.swing.JButton; public class Window extends JFrame { private static final long serialVersionUID = -2545695383117923190L; private

Player moves faster with higher deltaTime

别来无恙 提交于 2019-12-13 05:24:36
问题 Here's the first version, where I have a delta of 1/60: http://jsfiddle.net/ocdrd0uy/ Here's the second version, where the only thing I changed was the delta to 1/20: http://jsfiddle.net/ocdrd0uy/1/ var delta = 1 / 60; --> var delta = 1 / 20; I simply timestep like this: x = x + v * dt * 0.5 v = v + (F * 1/m) * dt x = x + v * dt * 0.5 Why does the player move faster with higher delta? 回答1: It's quite logical that when your delta decrease, the speed will increase. After you do your 2 half-step

How do I make a “loop” for a game, that runs every (number) of milliseconds?

一曲冷凌霜 提交于 2019-12-13 05:08:46
问题 I've tried to search for this on google and stackoverflow, but I'm not sure what to call it, so I can't find it. How would I make a "loop" for the C# program, that runs every, say, 100 milliseconds? Similar to what Minecraft calls "ticks", or GameMaker calls "steps". I can't figure out how to do this. I'm using visual studio, and I have a main window. There are things that I want to execute constantly, so I'm trying to figure out how to make a "step" or "update" function. 回答1: If you want it

How would an abstract render method work? (Java)

瘦欲@ 提交于 2019-12-13 02:57:51
问题 So say you want to have an abstract class called play, which has a render method. public abstract class RenderPanel{ public abstract void render(); } And then you have another class which calls the render method using some sort of game loop. public class Window implements Runnable{ public void run(){ while(running){ RenderPanel.render(); Thread.sleep(5000); } } } This code would not work because you cannot call an abstract class statically, and you can't instantiate the class. So how would