用物理学滚动2D世界

编程入门 行业动态 更新时间:2024-10-25 01:26:42
本文介绍了用物理学滚动2D世界的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在写一个与物理有关的横向滚动游戏.在弄脏我的手之前,我开始专注于物理和渲染图形.最初,我想到使所有事物保持静态(非滚动). 对于物理学,在参考了许多教程之后,我最终在这里 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 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世界

本文发布于:2023-06-04 19:08:06,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/503336.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:物理学   世界

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!