Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / Box collision using point

Author
Message
treeman
14
Years of Service
User Offline
Joined: 15th Sep 2010
Location: My Cave
Posted: 16th Sep 2010 08:17
I am making a platformer and using the box command and the pointer command to check for collisions.


The problem is, if the player (an 18x36 box) moves more than one pixel in a frame then it will stop partway through the box rather than on top of it.

Is there a way I could force the player to the desired spot after the collision or, alternatively a more effective way of performing collisions with 2d shapes.
LBFN
17
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 16th Sep 2010 17:46 Edited at: 16th Sep 2010 17:47
Normally, the POINT command is too slow to do checks like you are doing. If you really wanted to use it (not recommended), you would simply check the total # of pixels that the box would move to see if it hits anything. You would have to check on the corners, the top and bottom plus in the middle of each in order to be reasonably accurate. I would think your program would slow down to a very low FPS rate.

You didn't say how that you made the 'world' that you are checking collision against. If you make it with 2D tiles, it is easy to check collision based upon the player's location.

Here is an example of 2D tile scrolling:
http://forum.thegamecreators.com/?m=forum_view&t=45952&b=6

You can also search for '2D tile' and come up with many more results.

There are other ways to do this, but I would say that this is probably the easiest way to get good collision at a good frame rate.

So many games to code.......so little time.
treeman
14
Years of Service
User Offline
Joined: 15th Sep 2010
Location: My Cave
Posted: 17th Sep 2010 03:44
Hmm thats too bad, If I got pixel based collision working I could import levels as images and use different colors to refer to different ground types etc. It would probably run at a decent speed on my pc (i7 950 ) but I want it run run ok on everyones pc.

You mentioned there was other ways of doing it, are there faster ways of doing collision that would allow me to use imported images or shapes rather than sprites?
LBFN
17
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 17th Sep 2010 18:13
Quote: "You mentioned there was other ways of doing it, are there faster ways of doing collision that would allow me to use imported images or shapes rather than sprites?"


Yes, you could use MEMBLOCKs to determine pixel colors. It is very fast, but is a topic for advanced coders. BMacZero wrote a tutorial on memblocks that might be of help:

http://forum.thegamecreators.com/?m=forum_view&t=172867&b=1

You could also search to find other MEMBLOCK examples.

Computers do exactly what you tell them.........don't you hate that sometimes?

Login to post a reply

Server time is: 2024-09-28 22:29:14
Your offset time is: 2024-09-28 22:29:14