# Please help with checking quadrants and rotation

**URL:** https://forum.kirupa.com/t/please-help-with-checking-quadrants-and-rotation/332701
**Category:** flash
**Created:** [October 7, 2014, 2:59am UTC](https://forum.kirupa.com/t/please-help-with-checking-quadrants-and-rotation/332701 "2014-10-07T02:59:47Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![drawntodeath](https://avatars.discourse-cdn.com/v4/letter/d/eb9ed0/32.png) [@drawntodeath](https://forum.kirupa.com/u/drawntodeath)
#### Post date: [October 7, 2014, 2:59am UTC](https://forum.kirupa.com/t/please-help-with-checking-quadrants-and-rotation/332701/1 "2014-10-07T02:59:47Z")

</div>

[COLOR=#000000][FONT=verdana]here’s what I’ve got so far[/FONT][/COLOR]

[COLOR=#000000][FONT=verdana]package {[/FONT][/COLOR]

[COLOR=#000000][FONT=verdana]import flash.display.MovieClip;[/FONT][/COLOR]

[COLOR=#000000][FONT=verdana]public class Main extends MovieClip[/FONT][/COLOR]  
[COLOR=#000000][FONT=verdana]{[/FONT][/COLOR]

[COLOR=#000000][FONT=verdana]public function Main()[/FONT][/COLOR]  
[COLOR=#000000][FONT=verdana]{[/FONT][/COLOR]  
[COLOR=#000000][FONT=verdana]// constructor code[/FONT][/COLOR]

[COLOR=#000000][FONT=verdana]var hero = new Hero();[/FONT][/COLOR]  
[COLOR=#000000][FONT=verdana]addChild(hero);[/FONT][/COLOR]  
[COLOR=#000000][FONT=verdana]hero.x = stage.stageWidth / 2;[/FONT][/COLOR]  
[COLOR=#000000][FONT=verdana]hero.y = stage.stageHeight / 2;[/FONT][/COLOR]

[COLOR=#000000][FONT=verdana]var enemy = new Enemy();[/FONT][/COLOR]  
[COLOR=#000000][FONT=verdana]addChild(enemy);[/FONT][/COLOR]  
[COLOR=#000000][FONT=verdana]enemy.x = Math.random() \* (stage.stageWidth - [/FONT][/COLOR][COLOR=#000000][FONT=verdana]enemy.width[/FONT][/COLOR][COLOR=#000000][FONT=verdana]) + [/FONT][/COLOR][COLOR=#000000][FONT=verdana]enemy.width/2[/FONT][/COLOR][COLOR=#000000][FONT=verdana];[/FONT][/COLOR]  
[COLOR=#000000][FONT=verdana]enemy.y = Math.random() \* (stage.stageHeight - enemy.height) + enemy.height/2;[/FONT][/COLOR]  
[COLOR=#000000][FONT=verdana]}[/FONT][/COLOR]  
[COLOR=#000000][FONT=verdana]}[/FONT][/COLOR]  
[COLOR=#000000][FONT=verdana]}[/FONT][/COLOR]

[COLOR=#000000][FONT=verdana]And what I need to do next is:[/FONT][/COLOR]  
[COLOR=#000000][FONT=verdana]Use the if-condition to check what quadrant each of[/FONT][/COLOR]  
[COLOR=#000000][FONT=verdana]the enemies are in, if…[/FONT][/COLOR]  
[COLOR=#000000][FONT=verdana]• Top right: rotate the enemy instance to 45 degrees[/FONT][/COLOR]  
[COLOR=#000000][FONT=verdana]• Bottom right: rotate the enemy instance to 135 degrees[/FONT][/COLOR]  
[COLOR=#000000][FONT=verdana]• Bottom left: rotate the enemy instance to 225 degrees[/FONT][/COLOR]  
[COLOR=#000000][FONT=verdana]• Top left: rotate the enemy instance to 315 degrees[/FONT][/COLOR]

[COLOR=#000000][FONT=verdana]issue is I can’t find what code it is for checking the quadrant this is for an assignment that’s due tomorrow and I can’t find anything[/FONT][/COLOR]

---

<div class="post-metadata">

### Author: ![scottiescotsman](https://avatars.discourse-cdn.com/v4/letter/s/ac91a4/32.png) [@scottiescotsman](https://forum.kirupa.com/u/scottiescotsman)
#### Post date: [October 8, 2014, 9:20pm UTC](https://forum.kirupa.com/t/please-help-with-checking-quadrants-and-rotation/332701/2 "2014-10-08T21:20:13Z")

</div>

Cant you do like …

```php

var xPos = stage.stageWidth / 2;
var yPos = stage.stageHeight / 2;
if (enemy.x>xPos && enemy.y>yPos){
enemy.rotation = 45
}else if (enemy.x>xPos && enemy.y<yPos){
enemy.rotation = 135
}else if (enemy.x<xPos && enemy.y>yPos){
enemy.rotation = 225
};
enemy.rotation = 315;

```

hope this helps

---

<div class="post-metadata">

### Author: ![senocular](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/senocular/32/7217_2.png) [@senocular](https://forum.kirupa.com/u/senocular)
#### Post date: [October 8, 2014, 10:27pm UTC](https://forum.kirupa.com/t/please-help-with-checking-quadrants-and-rotation/332701/3 "2014-10-08T22:27:57Z")

</div>

You forgot your last else. 😉

---

<div class="post-metadata">

### Author: ![scottiescotsman](https://avatars.discourse-cdn.com/v4/letter/s/ac91a4/32.png) [@scottiescotsman](https://forum.kirupa.com/u/scottiescotsman)
#### Post date: [October 8, 2014, 10:37pm UTC](https://forum.kirupa.com/t/please-help-with-checking-quadrants-and-rotation/332701/4 "2014-10-08T22:37:00Z")

</div>

I was close u must admit lol
