Netlogo turtles die if they reach upper boundary

Viewed 50

Good morning everyone: I'm currently doing a version of space invaders in a world without limits. I have already done everything, but I have a problem with the laser beam. When it doesn't hit the alien it doesn't destroy when it reaches the upper limit of the world, it comes from the bottom since the world doesn't have limits. I want the laser beam (turtle) to die when it reaches the max-pycor but I don't know how to do it. If you can help me I will appreciate it.

Here is an example of what I want to do

    ask laser [ 
    if reach max-pycor [ die ]
    ]
1 Answers

The turtles can always acces the patch variables of the patch, it is standing on. That way, you can easily check if the turtle (in this case the laser) is on the last patch:

ask laser 
[ 
   if pycor = max-pycor [ die ]
]
Related