@name Cenn's RTS
@inputs E:wirelink Pod:wirelink
@outputs 
@persist W S A D Cycle Building:string Ti
@trigger 

runOnTick(1)
if(first()){
    E:egpClear()
    E:egpBox(1,vec2(100,100),vec2(1000,1000))
    E:egpColor(1,vec(40,180,40))
    Ti = 1
    Cycle = 0
    E:egpBoxOutline(2,vec2(200,200),vec2(40,40))
    E:egpColor(2,vec(255,0,0))
}
W     = Pod["W",     number]  
S     = Pod["S",     number]  
A     = Pod["A",     number]  
D     = Pod["D",     number]  
M2    = Pod["Mouse2", number]
M1    = Pod["Mouse1", number]
if(W){E:egpPos(2,E:egpPos(2) + vec2(0,-5))
}
if(S){E:egpPos(2,E:egpPos(2) + vec2(0,5))
}
if(A){E:egpPos(2,E:egpPos(2) + vec2(-5,0))
}
if(D){E:egpPos(2,E:egpPos(2) + vec2(5,0))
}
    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(changed(M2) & M2){
   Cycle = Cycle + 2
if(Cycle>7){
Cycle=0}
    print(_HUD_PRINTCENTER,Cycle:toString())
}

if(Cycle==2){
    E:egpAlpha(3 + Ti,0)
Building = "Power"}
if(Cycle==4){
    E:egpAlpha(3 + Ti,0)
Building = "House"}
if(Cycle==6){
    E:egpAlpha(3 + Ti,0)
Building = "Military"}
if(Building =="Power"){
    if(Cycle==2){
        E:egpColor(4 + Ti,vec(255,0,0))
    E:egpBox(5 + Ti,E:egpPos(2),vec2(30,40))
    E:egpAlpha(100)
    if(changed(M1) & M1){
        E:egpBox(4 + Ti,E:egpPos(2),vec2(30,40))
    E:egpAlpha(255)
    Ti++}
}}
if(Building =="House"){
    if(Cycle==4){
        E:egpColor(4 + Ti,vec(0,255,0))
    E:egpBox(6 + Ti,E:egpPos(2),vec2(30,40))
    E:egpAlpha(100)
    if(changed(M1) & M1){
        E:egpBox(4 + Ti,E:egpPos(2),vec2(30,40))
    E:egpAlpha(255)
    Ti++}
}}
if(Building =="Military"){
    if(Cycle==6){
        E:egpColor(4 + Ti,vec(0,0,255))
    E:egpBox(7 + Ti,E:egpPos(2),vec2(30,40))
    E:egpAlpha(100)
    if(changed(M1) & M1){      E:egpBox(4 + Ti,E:egpPos(2),vec2(30,40))
    E:egpAlpha(255)
    Ti++}
}}
print(particlesList())
