Scrolling the 2d world with physics

坚强是说给别人听的谎言 提交于 2019-12-11 16:38:23

问题


I'm writing a side scrolling game with physics. Before get my hands dirty i started concentrating on physics and rendering graphics. Initially i thought of keeping every thing static (non scrolling). For physics after referring to many tutorial finally i ended up here http://www.tonypa.pri.ee/vectors/tut08.html. This set of tutorial covers most of the basic/advanced physics required for simple game. By following this tutorial i have created my 2d world with objects like triangle , box ,..... Each different objects vertices are saved as vectors for calculating the collision,bounce , ....... Response is pretty good if i apply force in x/y , is working perfect as long as each collidable objects are static. now im struggling in how to move all the vectors according to the direction (right/left) and at the same time updating the new change in vector for collision. i have some basic understanding how this translation works in tile based environment. But for the non tile based world what is the best practice. Thanks in advance.


回答1:


If you're going to move everything, the best way would be just to scroll the virtual camera.

I'm afraid I don't know anything about flash, but I would assume it has some functionality to manipulate the virtual camera, default transform matrix or something similar.

You shouldn't need to change anything else if you can manipulate the virtual camera or default transform matrix.




回答2:


If you're using OpenGL...

I'm sating this from memory so you need to check exacts, but I think there is an GL method that stats the location and what you are looking at. That is all you have to do. You can specify it in world co-ords so the x,y co-ords of the respective objects dont change, just your veiw does.



来源:https://stackoverflow.com/questions/4028298/scrolling-the-2d-world-with-physics

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!