Quantcast
Channel: VBForums - CodeBank - Visual Basic 6 and earlier
Viewing all articles
Browse latest Browse all 1529

VB6 R-Tree Demo for large Game-Maps

$
0
0
In larger 2D (or 2.5D) Games, there's often the question of efficient Map-Handling...
Not only with regards to Map-creation or -definition, but also with regards to efficient re-rendering after the View-Rectangle was shifted.

This Demo addresses these questions, by placing *all* the resources in a little SQLite-DB in the App-Path.
(it contains Routines, which can import Tile- and Map-Placment-Infos into this DB efficiently).

It also contains Code, which demonstrates an efficient Selection (via SQL, in about 1msec) of:
- all Tile-Types which are fully contained in the current View-Window, as well as
- all Tile-Types which are only partially contained (overlap) with the current View-Window

The reason for the good query-performance (even if your world is made up, out of Millions of different Tiles),
is the SQLite RTree-Module (demonstrated in Class cTilePlacments).

Beginners should not be discouraged, the Code-Volume in each of the 4 Modules is (on average) only 50 Lines.
It is also well-commented, and to get a first impression how everything works together, perhaps start with stepping through with the <F8>-Key.

Here is, what it looks like:


At the Top-Left-Corner there's a little PicBox, which shows the "global World" in its entirety.
Within that PicBox is a little red-bordered Shape-Rectangle, which can be moved with the Mouse...
And when moved, the "View-Window" (in our case the entire Form) will "follow along", rendering the found Tiles in that View...

Ok, here's the Source-Code: RTreeMapDemo.zip

Have fun,

Olaf
Attached Files

Viewing all articles
Browse latest Browse all 1529

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>