import random import turtle import time class creature: speed = 1 angle = 5 sight = 5 x=0 y=0 t = turtle.Turtle() t.ht() def move(self): self.t.pu() self.t.goto(self.x,self.y) self.x+=random.randint(-self.speed,self.speed) self.y+=random.randint(-self.speed,self.speed) self.t.pd() self.t.goto(self.x,self.y) def koor(self): print(self.x) def found(self,p): if(self.x == p.x and self.y == p.y): print("True") class points: x = 0 y = 0 t = turtle.Turtle() t.ht() def __init__(self, x,y): self.x=x self.y=y def draw(self): self.t.ht() self.t.pu() self.t.goto(self.x-1,self.y-1) self.t.pd() self.t.goto(self.x,self.y-1) self.t.goto(self.x,self.y) self.t.goto(self.x-1,self.y) self.t.goto(self.x-1,self.y-1) def inrange(self,c): if(self.x-1<=c.x<=self.x and self.y-1<=c.y<=self.y): return True return False sc = turtle.Screen() c = creature() creat = [] food = [] s = 25 sc.tracer(0,0) sc.setworldcoordinates(-s,-s,s,s) for i in range(5000): food.append(points(random.randint(-5000,5000),random.randint(-5000,5000))) food[i].draw() for i in range(500): creat.append(creature()) sc.update() while True: for e in range(len(creat)): creat[e].move() if(abs(creat[e].t.xcor())>=s): s+=1 sc.setworldcoordinates(-s,-s,s,s) if(abs(creat[e].t.ycor())>=s): s+=1 sc.setworldcoordinates(-s,-s,s,s) w = True for q in range(len(creat)): for e in range(len(food)): if(food[e].inrange(creat[q]) == True): print("gotcha") print("Creature",q+1) w = False break if w == False: break sc.update() sc.exitonclick()