# Pacman-like collision

**URL:** https://forum.kirupa.com/t/pacman-like-collision/289462
**Category:** programming
**Created:** [May 30, 2009, 11:16pm UTC](https://forum.kirupa.com/t/pacman-like-collision/289462 "2009-05-30T23:16:26Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![substance](https://avatars.discourse-cdn.com/v4/letter/s/c6cbf5/32.png) [@substance](https://forum.kirupa.com/u/substance)
#### Post date: [May 30, 2009, 11:16pm UTC](https://forum.kirupa.com/t/pacman-like-collision/289462/1 "2009-05-30T23:16:26Z")

</div>

So I’m created a non-tile based pacman-like game and I’m trying to figure out how to manage keeping the character withing the pathing bounds. The way I’m going about things now is using hittest on four points around the character and stopping velocity accordingly. something like:

```auto
 	  		if(!road.hitTestPoint(x + halfwidth,y),true)){	
				velocity.x = velocity.x > 0 ? 0 : velocity.x;	
			}
if(!road.hitTestPoint(x - halfwidth,y),true)){	
				velocity.x = velocity.x < 0 ? 0 : velocity.x;;	
			}
etc..

```

Simple. If you’re touching a right wall and still moving toward the right, kill your velocity (so you cant move in that direction anymore. This works fine untill you factor in corners.

[http://mistermartinez.com/CreamWolf/CreamWolfDEBUG.swf](http://mistermartinez.com/CreamWolf/CreamWolfDEBUG.swf)

Because the points I’m testing dont including corners some overlapping occurs. The problem is when I test the corner points instead of what I’ve done above… things gets tricky and I cant wrap my head around a fix.

Am I even approaching this problem with the best method?

\*tiles aren’t an option.
