用物理学滚动2D世界 [英] Scrolling the 2d world with physics

查看:101
本文介绍了用物理学滚动2D世界的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在写一个与物理有关的横向滚动游戏.在弄脏我的手之前,我开始专注于物理和渲染图形.最初,我想到使所有事物保持静态(非滚动). 对于物理学,在参考了许多教程之后,我最终在这里 http://www.tonypa.pri .ee/vectors/tut08.html .这套教程涵盖了简单游戏所需的大多数基本/高级物理知识.通过遵循本教程,我创建了一个2D世界,其中包含诸如三角形,盒子,...等对象.每个不同的对象的顶点均保存为向量,以计算碰撞,反弹,.......如果我只要每个可碰撞对象都是静态的,以x/y方向施加力就可以完美工作. 现在,我在努力如何根据方向(右/左)移动所有矢量,并同时为碰撞更新矢量的新变化方面感到困惑.我对这种翻译如何在基于图块的环境中工作有一些基本的了解.但是对于非基于图块的世界,最佳实践是什么.预先感谢.

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.

推荐答案

如果您使用的是OpenGL ...

If you're using OpenGL...

我正在从内存中检查这件事,因此您需要检查准确度,但是我认为有一种GL方法可以统计位置和所查看的内容.那就是你要做的. 您可以使用世界坐标来指定它,这样各个对象的x,y坐标就不会改变,就像您的视线一样.

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.

这篇关于用物理学滚动2D世界的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆