Jump to content

Search the Community

Showing results for tags 'game loop'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


  • HTML5 Game Coding
    • News
    • Game Showcase
    • Facebook Instant Games
    • Web Gaming Standards
    • Coding and Game Design
    • Paid Promotion (Buy Banner)
  • Frameworks
    • Pixi.js
    • Phaser 3
    • Phaser 2
    • Babylon.js
    • Panda 2
    • melonJS
    • Haxe JS
    • Kiwi.js
  • General
    • General Talk
    • GameMonetize
  • Business
    • Collaborations (un-paid)
    • Jobs (Hiring and Freelance)
    • Services Offered
    • Marketplace (Sell Apps, Websites, Games)

Find results in...

Find results that contain...

Date Created

  • Start


Last Updated

  • Start


Filter by number of...


  • Start



Website URL





Found 4 results

  1. Hey all, I'm currently in the process of re-writing my authoritative server from one that was completely event driven to one that relies heavily on a game loop and I had some questions I'm sure some people can answer. To give some insight for my question, the way the old event-based system worked was basically the client would do something, then send tell the server what it was trying to do. The server would then check if this was legal if it was, do nothing but tell other players what that client did, if not legal, would set the client back to its previous state. For example, movement was handled by the client telling the server where it was a few times a second. The server would make sure it's getting consistent updates from the client and calculate if its velocity and other parts of its movement was legal, if so the server would accept that update and store it and push it to other clients. Similarly, shooting was handled in the same way. (Bullets do not travel btw, shooting would essentially just spawn a point of damage wherever you clicked) Client would tell the server where it wants to shoot, server would give it the okay or not then push that info to everyone else and calculate damage if it hit someone etc. Now, I'm switching to a game loop so that my entities can have a more robust "ai" behind them. While in the process of this I've moved a lot of the server logic (like movement) to the loop and it seems to be much more functional (and authoritative) to do it this way. I always knew the loop made more sense, I just didn't want to hassle myself with it yet. Now the main question I have is should I be handling things like shooting in the game loop too, or is it okay to keep them event driven. Do I lose anything by having half the game event driven and the other half of the game ran in the loop? Since bullets aren't a traveling entity and is just damage at a point and all the server needs to do is calculate if you can shoot there, and if there is a player there, then damage them. Should I move this logic into the loop for cleanness/speed/efficiency? Same thing with other things like opening an inventory screen. When you open your inventory on the client, the client requests the server for its items, the server just immediately sends the client the info it needs (while doing some other logic obv). Should I move this to the loop and set like a flag that says on the next loop serve this client their inventory? Or does it really not matter at all and whatever makes sense to me? Let me know if I need to elaborate some more, I'm sometimes not too clear hahaha. Thanks!
  2. As PixiJS introduced Application class, I find there is a function start(): In PixiJS examples, the game loop always starts like: // Animate the rotation app.ticker.add(function() { anim.rotation += 0.01; }); But some examples use app.start(). So what is the best way for game loop? requestAnimateFrame? app.ticker.add? app.start?
  3. I've been trying to wrap my head around understanding the update and render functions. Here's my game loop: Update function runs at 25 fpsRender function runs as fast as it can (usually 50-60 FPS)For the sake of argument, lets pretend that I'm going to animate a box moving from left to right on the screen. Here's what's bugging me. If I put the code to change the xy into the update function, then in one second the box will have 25 position changes. Essentially, even though my render loop runs faster, the animation would appear to run at 25 FPS. I want to take advantage of my faster running rendering function for smoother animations. It would seem to me that I should initiate the move in the update function. Something like .moveTo(position), but then actually set the xy coordinates of the object in the render function. This is my first time writing a game loop so I'm not sure how other people do it, but it just seems weird to me to change the xy coordinates in the render function. I'd like to know how other people have approached this problem and what your solutions are. UPDATE: Or should the update function change the xy coordinates, and the render function just interpolate the change/difference in values?
  4. I'll start with an issue I'm having and after that I will pass to a more generic thought. I'm using this game loop structure, using requestAnimationFrame: requestAnimFrame = (function() { return window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.oRequestAnimationFrame || window.msRequestAnimationFrame || function(/* function FrameRequestCallback */ callback, /* DOMElement Element */ element) { window.setTimeout(callback, 1000/60); };})();gameloop=function(){ //Here I do my calculations and drawings //I do this in order to calculate FPS thisLoop=new Date; var fps=1000/(thisLoop-lastLoop); lastLoop=thisLoop; requestAnimFrame(gameloop); }It works fine both on Chrome and IE, at a steady 60 fps pace. But when running on Firefox, FPS counting goes over 60 (it sets around 65) and the gaming experience is a lot worse, not smooth at all because I suppose the screen might be dropping some frames. I read of setting a time-interval alongside the requestAnimFrame call but I don't know if it's the solution. Any thoughts? Having said that, a more broad question. MAKING GAME LOGIC FPS INDEPENDENT. This has been taking some of my time lately. I've tried a couple of methods to do that. In the first one, I use that fps data I'm getting to do the pertinent speed corrections every cycle with fresh data. Then I tried to do the same but using a mean value calculated over some cycles. I'm getting buggy results either way (what else!). Is this the correct approach? Which is the lowest FPS you handle in your games?
  • Create New...