- Hands-On Game Development with WebAssembly
- Rick Battagline
- 397字
- 2021-06-24 13:41:13
Summary
Circle colliders are what we need right now. They are fast and efficient, and, for a simple game such as this, you might be able to get away with not doing anything more sophisticated. We added in a compound collider to demonstrate how this simple modification could significantly increase the accuracy of your collider. We will need to add more collision detection methods later in this book. In the future, we will be adding asteroids and a star to our game, and we will be creating an AI (Artificial Intelligence) agent to navigate our game and attack our player. This agent will eventually need to know whether it has a line of sight with the player so that line collision detection will become more important. Our agent will also want to quickly scan the area close to it to see whether there are any asteroids it must avoid. For this feature, we will be using rectangle collision.
There are many types of collision detection techniques for 2D games, and we have only scratched the surface in this chapter. We learned how to implement some basic circle colliders and compound colliders, and we added code that detects collisions between the projectiles in our game and the player and enemy spaceships. These kinds of colliders are fast and relatively easy to implement, but they are not without their drawbacks.
One drawback you may notice with simple colliders such as the ones we have implemented is that, if two objects pass each other with a high enough relative velocity, it is possible they could pass through each other without colliding. That is because our objects have a new position calculated every frame, and they do not continuously move from point A to point B. If it takes one frame to move from point A to point B, the object effectively teleports between the two points. If there was a second object in between those two points, but we are not colliding with that object when at either point A or point B, the object collision is missed. That should not be a problem in our game because we will be keeping our maximum object velocities relatively low. It is, however, something to keep in mind when writing your games.
In the next chapter, we will be building a tool to help us to configure particle systems.
- 零點(diǎn)起飛學(xué)Xilinx FPG
- 嵌入式系統(tǒng)設(shè)計(jì)教程
- micro:bit魔法修煉之Mpython初體驗(yàn)
- 電腦軟硬件維修從入門(mén)到精通
- STM32嵌入式技術(shù)應(yīng)用開(kāi)發(fā)全案例實(shí)踐
- 單片機(jī)技術(shù)及應(yīng)用
- 電腦組裝與維護(hù)即時(shí)通
- 筆記本電腦芯片級(jí)維修從入門(mén)到精通(圖解版)
- 單片微機(jī)原理及應(yīng)用
- Intel FPGA權(quán)威設(shè)計(jì)指南:基于Quartus Prime Pro 19集成開(kāi)發(fā)環(huán)境
- Drupal Rules How-to
- 筆記本電腦維修技能實(shí)訓(xùn)
- 計(jì)算機(jī)組裝與維護(hù)(慕課版)
- Zabbix 4 Network Monitoring
- 筆記本電腦的結(jié)構(gòu)、原理與維修