Thanks for sharing,
Pixel perfect collision is ... pixel perfect but also can be quite slow.
Your approach looks good.
Numbers in tile map mean textures?
Thanks,
Petr
This is a follow on from here
http://community.thinbasic.com/index.php?topic=947.0
I use a simple technique for collision at the moment, tile based.
think of it like this say I have a tile map of a screen 10x10 tiles
[code=ini]
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 1 3 0 0 0 0
0 0 0 1 2 2 3 0 0 0
0 1 2 2 2 2 2 2 3 0
[/code]
I then make a collision map
[code=ini]
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 1 1 0 0 0 0
0 0 0 1 1 1 1 0 0 0
0 1 1 1 1 1 1 1 1 0
[/code]
I use a collision map because I might want to have invisable platforms or graphics that are not platforms (sneaky).
So I know my player x and y positions using that I find my position on the collision map and test up, down, left, right and do whats required.
I am thinking about doubling up on my collision map that will improve detection.
This method is quicker than pixel perfect collision and most time you will get away with it.
Good luck
Mike
Home Desktop : Windows 7 - Intel Pentium (D) - 3.0 Ghz - 2GB - Geforce 6800GS
Home Laptop : WinXP Pro SP3 - Intel Centrino Duo - 1.73 Ghz - 2 GB - Intel GMA 950
Home Laptop : Windows 10 - Intel(R) Core(TM) i5-4210U CPU @ 1.70GHz, 2401 Mhz, 2 Core(s), 4 Logical Processor(s) - 4 GB - Intel HD 4400
Work Desktop : Windows 10 - Intel I7 - 4 Ghz - 8GB - Quadro Fx 370
Thanks for sharing,
Pixel perfect collision is ... pixel perfect but also can be quite slow.
Your approach looks good.
Numbers in tile map mean textures?
Thanks,
Petr
Learn 3D graphics with ThinBASIC, learn TBGL!
Windows 10 64bit - Intel Core i5-3350P @ 3.1GHz - 16 GB RAM - NVIDIA GeForce GTX 1050 Ti 4GB
If there is some new functionality you need let me know.
For example, some matrix compare or array scan or whatever, even strange one but can be enough general to be a keyword.
This can speed up such data compare a lot.
Ciao
Eros
www.thinbasic.com | www.thinbasic.com/community/ | help.thinbasic.com
Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000
That's a cool technique. Clever idea for sure!
Acer Notebook: Win 10 Home 64 Bit, Core i7-4702MQ @ 2.2Ghz, 12 GB RAM, nVidia GTX 760M and Intel HD 4600
Raspberry Pi 3: Raspbian OS use for Home Samba Server and Test HTTP Server
Such a collision maps could be useful in generall way,
for labyrinths and similar.
And it would be a bit too much to use ODE for it, as it would be like using tank to kill a mosquito.
TBGL collision arsenal is kind of poor now , so I am open to any general purpose additions there.
Bye,
Petr
Learn 3D graphics with ThinBASIC, learn TBGL!
Windows 10 64bit - Intel Core i5-3350P @ 3.1GHz - 16 GB RAM - NVIDIA GeForce GTX 1050 Ti 4GB
@Petr. I keep it simple and use the texture number and tile numbering the same.
Tile based collision is an old idea that has been around since early games so I can't take credit for it.
I dont know if opengl can perform anything like collision.
I remember on the amiga you could do collision using the blitter chip.
First you make a mask of your character which is 1 bitplane(2 colour) and do the same for the level graphics then do the blit operation with a logical "AND" with the 2 channels and checking the ZERO FLAG for collision.
I dont know if the blitter function of modern video cards have this feature??
something to read
http://www.geocities.com/SiliconVall...520/tutor.html
http://people.ifm.liu.se/ulfek/bitmask/
Home Desktop : Windows 7 - Intel Pentium (D) - 3.0 Ghz - 2GB - Geforce 6800GS
Home Laptop : WinXP Pro SP3 - Intel Centrino Duo - 1.73 Ghz - 2 GB - Intel GMA 950
Home Laptop : Windows 10 - Intel(R) Core(TM) i5-4210U CPU @ 1.70GHz, 2401 Mhz, 2 Core(s), 4 Logical Processor(s) - 4 GB - Intel HD 4400
Work Desktop : Windows 10 - Intel I7 - 4 Ghz - 8GB - Quadro Fx 370
There was a tutorial on the 'bitmask' method of collision detection in an early edition of the Amiga Magazine 'Amiga Format'.
You can download the full tutorial here. (5.72 MB)
The collision detection section is in part 6.
Operating System: Windows 10 Home 64-bit
CPU: Intel Celeron N4000 CPU @ 1.10GHz
Memory: 4.00GB RAM
Graphics: Intel UHD Graphics 600
Ive been reviewing the opengl commands available and was wondering if something like this might work.
start with a clear frame
using a bitmask of the player and level gfx.
set glLogicOP to GL_AND
now only draw the quad directly below the player
now draw the player
this is where I dont see a way to check
If its worked when the player has overlapped the level gfx it should only set the those bits so you have a collision.
thats a rough idea what does everyone think?
I was wondering glFeedbackBuffer could be used but I dont really understand its use.
Home Desktop : Windows 7 - Intel Pentium (D) - 3.0 Ghz - 2GB - Geforce 6800GS
Home Laptop : WinXP Pro SP3 - Intel Centrino Duo - 1.73 Ghz - 2 GB - Intel GMA 950
Home Laptop : Windows 10 - Intel(R) Core(TM) i5-4210U CPU @ 1.70GHz, 2401 Mhz, 2 Core(s), 4 Logical Processor(s) - 4 GB - Intel HD 4400
Work Desktop : Windows 10 - Intel I7 - 4 Ghz - 8GB - Quadro Fx 370
Hi Abraxas,
OpenGL is just graphic library, so I doubt so. But I will check.
Thanks to both you and Abraxas for provided sources, I will study them very soon and report back.
There is a way to check how many pixels are on screen after the logical op, for example using glReadPixels, but this is sadly performance killer, and higher the resolution, bigger problem...
That one for VisualBASIC seems to be GDI oriented, so not usable for TBGL/OpenGL, but as I said, will check.
You gave me really interesting ideas
Thanks a lot,
Petr
Learn 3D graphics with ThinBASIC, learn TBGL!
Windows 10 64bit - Intel Core i5-3350P @ 3.1GHz - 16 GB RAM - NVIDIA GeForce GTX 1050 Ti 4GB
Petr I found this http://graphics.stanford.edu/~tolis/...are/asteroids/
read the section on collision detection I didnt think about using the depth buffer. I will look at that when I get time.
Home Desktop : Windows 7 - Intel Pentium (D) - 3.0 Ghz - 2GB - Geforce 6800GS
Home Laptop : WinXP Pro SP3 - Intel Centrino Duo - 1.73 Ghz - 2 GB - Intel GMA 950
Home Laptop : Windows 10 - Intel(R) Core(TM) i5-4210U CPU @ 1.70GHz, 2401 Mhz, 2 Core(s), 4 Logical Processor(s) - 4 GB - Intel HD 4400
Work Desktop : Windows 10 - Intel I7 - 4 Ghz - 8GB - Quadro Fx 370
Bookmarks