Logo Bolo: a re-envisioning of the classic tank game by Stuart Cheshire in NetLogo
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

explosion.nls 2.0 KiB

il y a 13 ans
il y a 13 ans
il y a 13 ans
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. ;; lobo: Logo Bolo
  2. ;; (c) Ben Kurtovic, 2011-2012
  3. globals [
  4. explosions-table
  5. ]
  6. breed [explosions explosion]
  7. explosions-own [
  8. midlife
  9. size-increment
  10. time-to-live
  11. ]
  12. ;; ==========
  13. ;; Procedures
  14. ;; ==========
  15. to make-explosions-table
  16. ; Fun with particle effects!
  17. set explosions-table table:make
  18. table:put explosions-table "small" [["explosion-small" 0.65 10 0.5]]
  19. table:put explosions-table "medium" [["explosion-med" 1.25 10 0.5]]
  20. table:put explosions-table "large" [["explosion-large" 2.5 15 0.5] ["explosion-med" 1.25 10 1]
  21. ["explosion-med" 1.1 8 1 ] ["explosion-small" 0.65 7 2]
  22. ["explosion-small" 0.65 5 3 ]]
  23. table:put explosions-table "huge" [["explosion-large" 3 20 0.5] ["explosion-med" 1.25 15 1]
  24. ["explosion-med" 1.25 15 1 ] ["explosion-med" 1.25 10 1]
  25. ["explosion-med" 1.25 10 1 ] ["explosion-small" 0.65 10 2]
  26. ["explosion-small" 0.65 10 2 ] ["explosion-small" 0.65 8 2]
  27. ["explosion-small" 0.65 7 2 ] ["explosion-small" 0.65 5 3]
  28. ["explosion-small" 0.65 5 3 ]]
  29. end
  30. to explode [name]
  31. let data table:get explosions-table name
  32. foreach data [
  33. create-explosion ?
  34. ]
  35. end
  36. to create-explosion [info]
  37. let sprite (item 0 info)
  38. let maxsize (item 1 info)
  39. let lifespan (item 2 info)
  40. let deviation (item 3 info)
  41. hatch-explosions 1 [
  42. set label ""
  43. set shape sprite
  44. set size maxsize / 2
  45. set midlife lifespan / 2
  46. set size-increment (maxsize / lifespan) * 2
  47. set time-to-live lifespan
  48. set heading random 360
  49. fd (random 100) / (100 / deviation)
  50. ]
  51. end
  52. to keep-exploding
  53. if time-to-live = 0 [
  54. die
  55. ]
  56. set time-to-live time-to-live - 1
  57. set midlife midlife - 1
  58. ifelse midlife > 0 [
  59. set size size + size-increment
  60. ] [
  61. set size size - size-increment
  62. ]
  63. end