Chapter 11. Collisions

What’s the first thing you think of when someone says the word “collision”? I think of two cars hurtling down the road at one another and then smashing headon in an impressive display of fireworks, flying metal, and screeching tires. Thankfully, in my vision nobody gets hurt! In Blitz3D, collisions control how two or more objects react with one another. Collisions are an important part of any game since they allow you to control whether your players can bump into walls or go through them. They also prevent players from falling off the edge of the screen, and they tell the computer what type of reaction should happen when two objects meet. By default, when you move one object into another using Blitz3D, the objects will pass right through each other. You have the ability to control both the method in which two objects collide and the response of the collision.

A very important concept that you must understand when defining collisions is that of types. Types are basically a way of grouping different objects that share similar qualities. Think of a type as a “team”—you can assign different objects to that team and then define the type of collisions for the team. For example, let’s say in your 3D game you have created hundreds of different enemy invaders. Rather than having to program the collisions for each enemy invader, you can assign each invader to a team and then define the collisions for that team. The collision parameters you apply to the “team” (the type) will apply to all members of the team—in this case all the enemy invaders. When you create a type, you assign a number for your team. The number you choose isn’t important; it’s just important that you assign it a number.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.21.244.217