# Hittest diagonal

**URL:** <https://forum.kirupa.com/t/hittest-diagonal/255316>\
**Category:** flash\
**Created:** [March 21, 2008, 1:12am UTC](https://forum.kirupa.com/t/hittest-diagonal/255316 "2008-03-21T01:12:36Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![arrogance](https://avatars.discourse-cdn.com/v4/letter/a/3da27b/32.png) [@arrogance](https://forum.kirupa.com/u/arrogance)\
**Post date:** [March 21, 2008, 1:12am UTC](https://forum.kirupa.com/t/hittest-diagonal/255316/1 "2008-03-21T01:12:36Z")

</div>

Hello guys,

I’m busy now with a game now. I’m having problems with the hittest. I found a nice tutorial on flashfocus.nl. Maybe the dutch people know the site…But anyway, I had to move my charachter on a perspective way as you can see i the code or fla:  
var heroW = 10;  
var heroH = 20;  
//var velY = 0;  
//var stepS = 8;  
var stepX = 8;  
var stepY = 4;  
//var jumping = true;  
var grondY = 380;  
this.onEnterFrame = function() {  
if (Key.isDown(Key.UP)) {  
for (var i = 0; i\<stepX; i++) {  
hero.\_x–;  
}  
for (var j = 0; j\<stepY; j++) {  
hero.\_y–;  
}  
}  
if (Key.isDown(Key.DOWN)) {  
for (var i = 0; i\<stepX; i++) {  
hero.\_x++;  
}  
for (var j = 0; j\<stepY; j++) {  
hero.\_y++;  
}  
}  
if (Key.isDown(Key.LEFT)) {  
for (var i = 0; i\<stepX; i++) {  
hero.\_x–;  
}  
for (var j = 0; j\<stepY; j++) {  
hero.\_y++;  
}  
}  
if (Key.isDown(Key.RIGHT)) {  
for (var i = 0; i\<stepX; i++) {  
hero.\_x++;  
}  
for (var j = 0; j\<stepY; j++) {  
hero.\_y–;  
}  
}  
};

And then i saw the hittest code for regular movements see below for the left:  
if (Key.isDown(Key.LEFT)) {  
for (var i = 0; i\<stepX; i++) {  
hero.\_x–;  
for (var j = 0; j\<=heroH; j++) {  
if (ground.hitTest(hero.\_x-heroW, hero.\_y-j, true)) {  
i = stepX;  
j = heroH+1;  
hero.\_x++;  
}  
}  
}  
}

But for somehow i cant fix the hittest in my code. Can someone help me?
