Welcome to the CSC Q&A, on our server named in honor of Ada Lovelace. Write great code! Get help and give help!
It is our choices... that show what we truly are, far more than our abilities.

Categories

+12 votes

Here is my code that allows you to use both drums and other instruments!

extensions [sound]

;;turtles own an "instrument" and a "kind"
turtles-own [instrument kind]

to setup

clear-all

cro 4
;;drum turtles
ask turtle 0 [set instrument "Bass Drum 1" set kind "drum"]
ask turtle 1 [set instrument "Low Tom" set kind "drum"]

;;instrument turtles
ask turtle 2 [set instrument "Marimba" set kind "pitched"]
ask turtle 3 [set instrument "Marimba" set kind "pitched"]

end

to go

ask turtles [

fd 1
right random 90
left random 90

;;check if the turtle is a drum or not
ifelse kind = "drum" [
  ;;plays a drum note
  sound:play-drum instrument (180 + pxcor)
]
[
  ;;plays a non-drum note
  sound:play-note instrument (60 + pxcor) 128 .2
]
wait random 2 * (.25)

]
end

asked in CSC 150 January201920 by (1 point)
+4

This is super helpful, thank you!

7 Answers

+7 votes

Thank you for sharing your work!

answered by (1 point)
+7 votes

Thank you, this helped a lot!

answered by (1 point)
+6 votes

Very helpful!

answered by (1 point)
+6 votes

Ahh I kept trying to play the drums using the note command and it wasn't working for me. Thank you so much !!

answered by (1 point)
+6 votes

Thanks for this, I had no idea how to use drums this was extremely helpful!!

answered by (1 point)
+5 votes

was very helpful. Thankyou

answered by (1 point)
+3 votes

Thank you so much <3

answered by (1 point)
...