• Content Count

  • Joined

  • Last visited

About mtycholaz

  • Rank

Profile Information

  • Gender
  • Location
  • Interests
  1. I've came across this article before during my research and based my game loop off it. It's a very well done article. Where I'm having trouble is how to synchronize my objects in memory with what is on the screen. From what I've read, people have two objects to solve this. The first is in memory and represents the current game state. The second is the display object, which is the actual object on-screen. The memory object is only updated during the update function, and the display object is updated during the render function. Basically I would need to use interpolation during the render, and update the position. I will have to experiment though to see what happens during lag, and high/low FPS.
  2. This was going to be my fallback, but I wanted to see if there was a different solution.
  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. So this is a long shot, but I wanted to ask anyway. When a user moves the mouse cursor in the browser, the "mousemove" event. What I would like to do is pick a random x,y coordinate and determine what objects are "on/within" the given coordinate. Not sure if webgl has some tricks up it's sleeve to do this, or maybe I could create a mousemove event in javascript for a given coordinate, fire the event and see what bubbles. Looking for ideas. What I'm trying to shortcut is looping through world entities to find any close to the given coordinates. Thoughts?