Skip to content

Commit 1cc4b10

Browse files
committed
Updates README.md. Updates icon.
1 parent d22bd72 commit 1cc4b10

File tree

4 files changed

+19
-18
lines changed

4 files changed

+19
-18
lines changed

CollisionGrid/CollisionGrid.nuspec

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
<authors>Unterrainer Informatik OG Team</authors>
88
<owners>Public Domain</owners>
99
<licenseUrl>http://unlicense.org</licenseUrl>
10+
<iconUrl>https://github.com/UnterrainerInformatik/collisiongrid/raw/master/icon.png</iconUrl>
1011
<projectUrl>https://github.com/UnterrainerInformatik/collisiongrid</projectUrl>
1112
<requireLicenseAcceptance>false</requireLicenseAcceptance>
1213
<description>Narrow down collision candidates in a 2D environment by using a fixed-size grid.</description>

CollisionGrid/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,5 @@
3232
// You can specify all the values or you can default the Build and Revision Numbers
3333
// by using the '*' as shown below:
3434
// [assembly: AssemblyVersion("1.0.*")]
35-
[assembly: AssemblyVersion("1.0.0.1")]
36-
[assembly: AssemblyFileVersion("1.0.0.1")]
35+
[assembly: AssemblyVersion("1.0.0.2")]
36+
[assembly: AssemblyFileVersion("1.0.0.2")]

CollisionGrid/icon.png

-9.59 KB
Loading

README.md

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,25 +11,25 @@ In order to get help with basic GIT commands you may try [the GIT cheat-sheet][c
1111
This repository located on our [homepage][homepage] is private since this is the master- and release-branch. You may clone it, but it will be read-only.
1212
If you want to contribute to our repository (push, open pull requests), please use the copy on github located here: [the public github repository][github]
1313

14-
# CollisionGrid
14+
# ![Icon](https://github.com/UnterrainerInformatik/collisiongrid/raw/master/icon.png)CollisionGrid
1515

1616
This class implements a collision-grid.
1717
When doing game development you've probably come across a point when you'd liked to do some collision-checks and that's usually the time when you've realize that just checking all sprites against each other doesn't cut it.
1818
The problem with that brute-force-approach is, that the number of checks grow very fast (N² for N sprites) when the number of your sprites increase.
19-
19+
2020
So you somehow have to narrow down your collision-candidates.
2121
This piece of software does that for you. It does not do the collision checks themself. It just tells you if a sprite may be near enough to a second one to maybe collide with it, which allows you to do a collision test for those two, or three, or five sprites instead of the whole bunch.
2222
## What It Really Does...
2323
...is a simple trade-off.
2424
You may query it about the sprites around your coordinate or rectangle, but your sprites have to register with it and update their position/AABB on every update.
2525
But all in all this is a lot faster than a simple brute-force check.
26-
26+
2727
## Getting Started
2828
The first thing is: You have to set-up a grid. Usually you'd take your game-coordinate-system's bounds.
2929
Then you have to tell the grid how many cells it has by setting the number of cells on the X and Y axis.
30-
30+
3131
Then you may add your sprites or other objects to the grid by calling `Add(object, Point/Vector2/Rectangle/Rect)` or `Move(object, Point/Vector2/Rectangle/Rect)`. Move removes the item first if it was present on the grid.
32-
32+
3333
### Parameters
3434
The first parameter is your item. The grid is generic and there are no constraints for that.
3535
The second parameter is always one of the following:
@@ -47,21 +47,21 @@ Then you may add your sprites or other objects to the grid by calling `Add(objec
4747
#### Rect
4848
This is a special parameter in our utility-package. It's essentially a Rectangle, but with all float parameters.
4949
By specifying this you give the grid a rectangle in the game-coordinate-system.
50-
50+
5151
All rectangles this grid works with are axis-aligned.
5252

5353
You're free to remove them at any time by using one of the remove-methods `Remove(Point/Vector2/Rectangle/Rect)`.
54-
54+
5555
The method `Get(Point/Vector2/Rectangle/Rect)` returns an array of your items with all of them that the grid has encountered in the area you've specified when calling `Get`. If it doesn't find any it returns an empty array.
56-
56+
5757
If you add your sprites by their position, then this is what the grid will basically do:
5858
![Position Test][testposition]
59-
59+
6060
If you add your sprites by their AABBs, then this is what the grid will basically do:
6161
![Rectangle Test][testrectangle]
6262

6363
#### Example
64-
64+
6565
Set up the collision-grid:
6666
```csharp
6767
public CollisionGrid<Sprite> Grid;
@@ -92,7 +92,7 @@ To achieve the output in the second one, just change the Move-line to the follow
9292
Grid.Move(s, s.getAABB());
9393
```
9494
Whereas of course your sprite has to return the axis-aligned-bounding-box as a Rect.
95-
95+
9696
Please don't forget to clean up afterwards. There are a few data-structures the grid has to dispose of:
9797
```csharp
9898
protected override void UnloadContent()
@@ -101,23 +101,23 @@ protected override void UnloadContent()
101101
Grid.Dispose();
102102
}
103103
```
104-
104+
105105
## So What's A QuadTree Then?
106106
Maybe you've heard of such a data-structure that does essentially exactly the same things as this grid with one major difference:
107-
107+
108108
The QuadTree divides the space all by itself, dynamically whenever you add new items.
109109
It doesn't need a fixed uniform grid, but divides space unevenly and only when another partition is needed.
110110
And that's good and bad at the same time.
111111
The good thing is that it can cope with unevenly distributed items very well.
112112
The bad thing is that it costs a lot more time (the updating of this data-structure); At least when compared to this grid here.
113113
[Here's a very good implementation of a QuadTree on GitHub with an excellent explanation what it exactly does.][quadtree]
114-
114+
115115
The good news about the QuadTree is that it's exactly what you're looking for if you are thinking...
116116
> Oh! Nice thing this grid. But the space I have to check is REALLY BIG and my sprites are very unevenly distributed. Most of the time they are clustered with much space in between those clusters. So my cells become way too big to segment those clusters in a helpful way.
117117
118118
...when reading the explanation of the CollisionGrid.
119-
120-
119+
120+
121121
[homepage]: http://www.unterrainer.info
122122
[coding]: http://www.unterrainer.info/Home/Coding
123123
[github]: https://github.com/UnterrainerInformatik/collisiongrid

0 commit comments

Comments
 (0)