01-07-2014

posted Jan 7, 2014, 5:57 AM by Samuel Konstantinovich   [ updated Jan 7, 2014, 5:57 AM ]
Sliders: 
acceleration
rotationacceleration
bulletdelay


breed [ bullets bullet]
breed [ players player]

players-own [speed rotatespeed bullettimer]
to setup
  ca
  reset-ticks
  ;ask patches [set pcolor red]
  create-players 1
end


to go
  ask players [moveplayers]
  ask bullets [movebullets]
  ;ask patches [set pcolor pcolor + 10]
  wait 1 / 30
  tick
end

to movebullets 
  fd 1
  if abs pxcor > max-pxcor - 1 or abs pycor > max-pycor - 1
  [ die ]
end

to moveplayers
  fd speed
  rt rotatespeed
  if bullettimer > 0 [ set bullettimer bullettimer - 1]
end

to shoot
  ask players [ 
    if bullettimer = 0 [
      set bullettimer bulletdelay
      hatch-bullets 1 [set shape "circle"]]]
end

to up
  ask players [accelerate acceleration ]
end

to down
  ask players [decelerate acceleration ]
end

to leftkey
  ask players [leftbias rotationalacceleration]
end


to rightkey
  ask players [rightbias rotationalacceleration]
end




to accelerate[n]
  set speed speed + n
end

to decelerate[n]
  set speed speed - n
end



to leftbias[n]
  set rotatespeed rotatespeed - n
end

to rightbias[n]
  set rotatespeed rotatespeed + n
end
Comments