Timeline for How can I render player movement on a 2d plane efficiently?
Current License: CC BY-SA 3.0
8 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Apr 4, 2012 at 17:56 | vote | accept | user422318 | ||
Apr 4, 2012 at 17:09 | history | edited | Laurent Couvidou | CC BY-SA 3.0 |
added 89 characters in body
|
Apr 4, 2012 at 17:03 | comment | added | Laurent Couvidou |
You need to decouple your rendering from your Bresenham iterations. Just make it a separate bresenham function that you'd call as in my example above, and update/draw your game independently. Also, learn about what a game loop is: active.tutsplus.com/tutorials/games/….
|
|
Apr 4, 2012 at 16:57 | history | edited | Laurent Couvidou | CC BY-SA 3.0 |
Changed suggestion to slow down movement.
|
Apr 4, 2012 at 16:54 | comment | added | user422318 | I was just re-reading my response and I'm a little confused about the cached path. If I try to update with each iteration of the Bresenham, the rendering happens too fast. Why wouldn't this happen if I'm just looping through it? Should I call the update function (which increments pathIndex) based on the timer interval? Bresenham is already implemented and too way too long. >< I just have to figure out how to get pathfinding working in time, and I'm very worried about that. | |
Apr 4, 2012 at 16:50 | comment | added | Laurent Couvidou | Just google more about linear interpolation, I'm sure you'll find something that fits you. And if you're still confused, well, ask another question :) If there's something you'll use lots of times in gameplay programming, it's the lerp function. But for the moment, forget about lerp, you can just advance on your path once in a while, I'll edit my answer above to reflect that. Oh and by the way, maybe Bresenham is overkill for you, you should probably forget about discrete-grid motion and try out what Jimmy suggested: gamedev.stackexchange.com/a/26347/14808. | |
Apr 4, 2012 at 16:34 | comment | added | user422318 | Thanks, I like your idea of using a cached path and I'm trying to make that work with my code. I think that it will run too fast, but I haven't found any good resources on doing lerp. Are there any that you'd recommend? The best resources would be one that can explain the math to me like I'm 5 years old. :) | |
Apr 4, 2012 at 8:13 | history | answered | Laurent Couvidou | CC BY-SA 3.0 |