# Chapter 2 defining boundaries (pg71)

**URL:** <https://forums.kodeco.com/t/chapter-2-defining-boundaries-pg71/26924>\
**Category:** 2D iOS & tvOS Games by Tutorials\
**Created:** [March 6, 2017, 1:17pm UTC](https://forums.kodeco.com/t/chapter-2-defining-boundaries-pg71/26924 "2017-03-06T13:17:57Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![muzafar](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/muzafar/32/59239_2.png) [@muzafar](https://forums.kodeco.com/u/muzafar)\
**Post date:** [March 6, 2017, 1:17pm UTC](https://forums.kodeco.com/t/chapter-2-defining-boundaries-pg71/26924/1 "2017-03-06T13:17:57Z")

</div>

Hey people,

When i define boundaries to bounce my zombie off i get an error stating I ‘cannot assign value of type ‘CGfloat’ to type ‘CGPoint’’ .

as far as i can tell the zombie.position value is CGFloat and we defined topRight and bottomLeft as CGPoints.

What am i missing here ?

thanks. My code is below

* * *

```
func boundsCheckZombie() {
    let bottomLeft = CGPoint.zero
    let topRight = CGPoint (x: size.width, y:size.height)
    
    if zombie.position.x <= bottomLeft.x {
        zombie.position = bottomLeft.x
        velocity.x = -velocity.x
    }
    if zombie.position.x >= topRight.x {
        zombie.position = topRight.x
        velocity.x = -velocity.x
    }
    if zombie.position.y <= bottomLeft.x {
        zombie.position = bottomLeft.y
        velocity.y = -velocity.y
    }
    if zombie.position.x >= topRight.x {
        zombie.position = topRight.y
        velocity.y = -velocity.y
    }

```

}

* * *

---

<div class="post-metadata">

**Author:** ![narrativium](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/narrativium/32/110937_2.png) [@narrativium](https://forums.kodeco.com/u/narrativium)\
**Post date:** [March 6, 2017, 2:15pm UTC](https://forums.kodeco.com/t/chapter-2-defining-boundaries-pg71/26924/2 "2017-03-06T14:15:09Z")

</div>

`zombie.position` is a `CGPoint` - it’s a position on the screen, hence it has `x` and `y` properties, which a `CGFloat` wouldn’t have. `x` and `y` _are_ `CGFloat`s though.

You can do this:  
` zombie.position.x = bottomLeft.x // assigns CGFloat to CGFloat`  
or this:  
` zombie.position = bottomLeft // assigns CGPoint to CGPoint`  
but not this, as in your code:  
` zombie.position = bottomLeft.x // assigns CGFloat to CGPoint`

---

<div class="post-metadata">

**Author:** ![muzafar](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/muzafar/32/59239_2.png) [@muzafar](https://forums.kodeco.com/u/muzafar)\
**Post date:** [March 6, 2017, 2:16pm UTC](https://forums.kodeco.com/t/chapter-2-defining-boundaries-pg71/26924/3 "2017-03-06T14:16:19Z")

</div>

Thanks guys i figured it out. it was a typo:unamused:

The ‘‘zombie.position = bottomLeft.x’’ needed to be ‘‘zombie.position.x= bottomLeft.x’’

that “.x” after “zombie.position” makes it a CGPoint value. otherwise it it is a CGFloat value giving the error

---

<div class="post-metadata">

**Author:** ![muzafar](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/muzafar/32/59239_2.png) [@muzafar](https://forums.kodeco.com/u/muzafar)\
**Post date:** [March 6, 2017, 2:18pm UTC](https://forums.kodeco.com/t/chapter-2-defining-boundaries-pg71/26924/4 "2017-03-06T14:18:46Z")

</div>

thanks @narrativium. I think i figured it out just as you typed up your answer !! haha timing 🙂

Thanks for the extra explaination on CGFloat and CGPoint. very helpful.
