@name Agar.io Chip by Cenn
@inputs E:wirelink Pod:wirelink Pod2:wirelink 
@outputs 
@persist W S A D W2 S2 A2 D2 Sizez Sizezz Size TT Ar:array GG HH Active Active2 Space  LastPressed:string   Dir:vector2  Size2
@trigger
while(perf(10)){ 
runOnTick(1)
#Debugging Hit boxes
#[E:egpBox(4,vec2(Size*2.5,Size*2.5),vec2(10,10))
E:egpBox(5,vec2(Size*-2.5,Size*-2.5),vec2(10,10))
E:egpColor(4,vec(0,0,0))
E:egpColor(5,vec(0,0,0))]#
if(first()){
E:egpClear()
E:egpRoundedBox(1,vec2(100,100),vec2(1000,1000))
E:egpColor(1,vec(150,150,255))
Size = 3
Size2 = 3
TT = 10
##Define Player##
E:egpCircle(2,vec2(100,100),vec2(Size + 30,Size+ 30))
E:egpCircleOutline(3,vec2(0,0),vec2(50,50))
E:egpCircleOutline(9,vec2(0,0),vec2(50,50))
E:egpColor(3,vec(0,0,0))
E:egpParent(3,2)
E:egpColor(9,vec(0,0,0))
timer("spawn",2000)
}
#print(E:egpSize(2))
E:egpColor(8,vec(255,0,0))
E:egpParent(4,2)
E:egpParent(5,2)
E:egpCircle(8,E:egpPos(8),vec2(Size2 + 30,Size2+ 30))
E:egpCircleOutline(9,vec2(0,0),vec2(Size2+30,Size2+30))
E:egpParent(9,8)
E:egpCircle(2,E:egpPos(2),vec2(Size + 30,Size+ 30))
E:egpCircleOutline(3,vec2(0,0),vec2(Size+30,Size+30))
W     = Pod["W",     number]  
S     = Pod["S",     number]  
A     = Pod["A",     number]  
D     = Pod["D",     number]  
W2     = Pod2["W",     number]  
S2     = Pod2["S",     number]  
A2     = Pod2["A",     number]  
D2     = Pod2["D",     number]  
Active2 = Pod2["Active", number]
Active = Pod["Active", number]
Space = Pod["Space", number]
    if(Active==0 & Active2==0){
        stoptimer("spawn")}
   if(changed(Active | Active2)){
    if(Active==1 | Active2==1){
        timer("spawn",5000)}}
HH++
if(HH==TT){
HH=0}
if(clk("spawn")){
    TT++
    GG++
  #  print(TT)
E:egpCircle(TT,vec2(randint(1,550),randint(1,550)),vec2(10,10))
E:egpColor(TT,vec(randint(40,255),randint(40,255),randint(40,255)))
Ar:setNumber(GG,TT)
timer("spawn",randint(4000,8000))   }

#Eating#


for(I = 1,Ar:number(HH)){
if(inrange(E:egpPos(Ar:number(HH)),E:egpPos(2),E:egpPos(2) + E:egpSize(2))){
E:egpRemove(Ar:number(HH))
Size = Size + 3}}
for(I = 1,Ar:number(HH)){
if(inrange(E:egpPos(Ar:number(HH)),E:egpPos(8),E:egpPos(8) + E:egpSize(8))){
E:egpRemove(Ar:number(HH))
Size2 = Size2 + 3}}
if(inrange(E:egpPos(8),E:egpPos(2),E:egpPos(2) + E:egpSize(2))){
    Sizez = Size+ 15
    if(Sizez<Size2){
       # print(Sizez)
       # print(Size2)
        E:egpRemove(8)
        Size = 3
}}

if(inrange(E:egpPos(2),E:egpPos(8),E:egpPos(8) + E:egpSize(8))){
    Sizezz = Size2+15
    if(Sizezz<Size){
        E:egpRemove(2)
        Size2 = 3
}}

#Failed Debugging Module 
#[
if(Size>500){reset()}
if(Size2>500){reset()}
if(changed(Size)){
    gSetStr(1,Size:toString())}
if(Size > gGetStr(1):toNumber() + 2){
    Size = gGetStr(1):toNumber() + 2
    print("Caught Bug!")}
]#

## Keys For the Movings
if(W){E:egpPos(2,E:egpPos(2) + vec2(0,-5 * 4 / Size))
    LastPressed  =  "W"}
if(S){E:egpPos(2,E:egpPos(2) + vec2(0,5 * 4 / Size))
    LastPressed  =  "S"}
if(A){E:egpPos(2,E:egpPos(2) + vec2(-5 * 4 /Size,0))
    LastPressed  =  "A"}
if(D){E:egpPos(2,E:egpPos(2) + vec2(5 * 4 / Size,0))
    LastPressed  = "D"}
    
if(W2){E:egpPos(8,E:egpPos(8) + vec2(0,-5 * 4 / Size2))
    LastPressed  =  "W"}
if(S2){E:egpPos(8,E:egpPos(8) + vec2(0,5 * 4 / Size2))
    LastPressed  =  "S"}
if(A2){E:egpPos(8,E:egpPos(8) + vec2(-5 * 4 /Size2,0))
    LastPressed  =  "A"}
if(D2){E:egpPos(8,E:egpPos(8) + vec2(5 * 4 / Size2,0))
    LastPressed  = "D"}

## World Hitbox
if(E:egpPos(2):x() <= -350){
    E:egpPos(2,vec2(-350,E:egpPos(2):y()))
}
if(E:egpPos(2):x() >= 550){
    E:egpPos(2,vec2(550,E:egpPos(2):y()))
}
if(E:egpPos(2):y() <= -350){
    E:egpPos(2,vec2(E:egpPos(2):x(),-350))
}
if(E:egpPos(2):y() >= 550){
    E:egpPos(2,vec2(E:egpPos(2):x(),550))
}

if(E:egpPos(8):x() <= -350){
    E:egpPos(8,vec2(-350,E:egpPos(8):y()))
}
if(E:egpPos(8):x() >= 550){
    E:egpPos(8,vec2(550,E:egpPos(8):y()))
}
if(E:egpPos(8):y() <= -350){
    E:egpPos(8,vec2(E:egpPos(8):x(),-350))
}
if(E:egpPos(8):y() >= 550){
    E:egpPos(8,vec2(E:egpPos(8):x(),550))
}
#print(_HUD_PRINTCENTER,E:egpPos(2):toString())
#print(_HUD_PRINTCENTER,Size:toString())

## Testing splitting mechanics
#[if(changed(Space)){
    if(Size  > 20){
    Size = Size /2
    if(LastPressed=="W"){Dir =  vec2(0,-40)}
    if(LastPressed=="S"){Dir =  vec2(0,40)}
    if(LastPressed=="A"){Dir =  vec2(-40,0)}
    if(LastPressed=="D"){Dir =  vec2(40,0)}
    Size2  =   Size
    E:egpCircle(6,E:egpPos(2) +  Dir,vec2(Size2))
    E:egpCircleOutline(7,E:egpPos(6),vec2(Size2))
    E:egpParent(6,2)
    E:egpParent(7,6)
    }
}]#
}
