# \[RESOLVED\] Rotating a quad() towards player(that moves around)

**URL:** <https://discourse.processing.org/t/resolved-rotating-a-quad-towards-player-that-moves-around/6997>\
**Category:** Processing.py\
**Created:** [December 29, 2018, 7:28pm UTC](https://discourse.processing.org/t/resolved-rotating-a-quad-towards-player-that-moves-around/6997 "2018-12-29T19:28:22Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sky](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/sky/32/3013_2.png) [@Sky](https://discourse.processing.org/u/Sky)\
**Post date:** [December 29, 2018, 7:28pm UTC](https://discourse.processing.org/t/resolved-rotating-a-quad-towards-player-that-moves-around/6997/1 "2018-12-29T19:28:23Z")

</div>

```auto
    def AI(self,plx,ply): #traslates 
        angle1 = atan2(ply - self.y1,plx - self.x1)
        self.x1 = cos(angle1) * self.speed + self.x1
        self.y1 = sin(angle1) * self.speed + self.y1    
        self.x2 = cos(angle1) * self.speed + self.x2
        self.y2 = sin(angle1) * self.speed + self.y2   
        self.x3 = cos(angle1) * self.speed + self.x3
        self.y3 = sin(angle1) * self.speed + self.y3  
        self.x4 = cos(angle1) * self.speed + self.x4
        self.y4 = sin(angle1) * self.speed + self.y4    
        
    def show(self):
        stroke(0)
        strokeWeight(1)
        fill(255,0,0)
        beginShape()
        vertex(self.x1,self.y1)
        vertex(self.x2,self.y2)
        vertex (self.x3,self.y3)
        vertex(self.x4,self.y4)
        endShape()
        #ellipse(self.x,self.y,self.r,self.r)   

```

I need to rotate the first vertex of this quad (the same above) towards the player:

```auto
    beginShape()
    vertex(40,40)
    vertex(50,60)
    vertex (20,30)
    vertex(70,40)
    endShape()

```

I tried with rotate(), but actually it rotates all of the things in my scene (it was funny at least)  
(Im sure that I am missing some moving objects on a plain foundamentals too, bc actaully I am at 11th grade and I have never done this kind of things at school)

---

<div class="post-metadata">

**Author:** ![GoToLoop](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/gotoloop/32/86_2.png) [@GoToLoop](https://discourse.processing.org/u/GoToLoop)\
**Post date:** [December 29, 2018, 8:56pm UTC](https://discourse.processing.org/t/resolved-rotating-a-quad-towards-player-that-moves-around/6997/2 "2018-12-29T20:56:34Z")

</div>

[Py.Processing.org/reference/pushMatrix.html](http://Py.Processing.org/reference/pushMatrix.html)

---

<div class="post-metadata">

**Author:** ![Sky](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/sky/32/3013_2.png) [@Sky](https://discourse.processing.org/u/Sky)\
**Post date:** [December 29, 2018, 9:18pm UTC](https://discourse.processing.org/t/resolved-rotating-a-quad-towards-player-that-moves-around/6997/3 "2018-12-29T21:18:34Z")

</div>

@GoToLoop  
My fear became true, I have to use Matrix funcs, wich I didnt copletely understodd. ☹  
I already tried with pushMatrix() -\> rotate() -\> i show quad -\> popMatrix()  
Is there any vid/guide where to these things are explained?

---

<div class="post-metadata">

**Author:** ![GoToLoop](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/gotoloop/32/86_2.png) [@GoToLoop](https://discourse.processing.org/u/GoToLoop)\
**Post date:** [December 29, 2018, 9:36pm UTC](https://discourse.processing.org/t/resolved-rotating-a-quad-towards-player-that-moves-around/6997/4 "2018-12-29T21:36:57Z")

</div>

[Py.Processing.org/tutorials/transform2d/](http://Py.Processing.org/tutorials/transform2d/)

---

<div class="post-metadata">

**Author:** ![Sky](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/sky/32/3013_2.png) [@Sky](https://discourse.processing.org/u/Sky)\
**Post date:** [December 29, 2018, 9:50pm UTC](https://discourse.processing.org/t/resolved-rotating-a-quad-towards-player-that-moves-around/6997/5 "2018-12-29T21:50:39Z")

</div>

@GoToLoop  
I love you man!  
(Love in a friendly way 🙂 )
