cjmiles
cjmiles

Reputation: 11

In netlogo, how do you rotate the shape of turtle without changing heading?

In other words, how do I accomplish rotation (via a command, and not through shape editor) and translation of a turtle independently.

Upvotes: 1

Views: 2056

Answers (1)

Seth Tisue
Seth Tisue

Reputation: 30453

Here's sample code that makes turtles move forward while appearing to be facing in another direction entirely:

turtles-own [real-heading apparent-heading]

to setup
  clear-all
  create-turtles 10 [
    set real-heading random 360
    set apparent-heading random 360
    set heading apparent-heading
  ]
  reset-ticks
end

to go
  ask turtles [ set heading real-heading ]
  ask turtles [ fd 1 rt random 25 lt random 25 ]
  ask turtles [
    set real-heading heading
    set heading apparent-heading
  ]
  tick
end

assuming your model is set to tick-based updates (as opposed to continuous updates), your user will only ever see the turtle's apparent heading in the view, never the turtle's "real" heading.

Upvotes: 1

Related Questions