Browse Source

A bit of cleanup, nothing substantial just yet.

master
Ben Kurtovic 12 years ago
parent
commit
19a1694264
3 changed files with 37 additions and 32 deletions
  1. +17
    -1
      bullet.nls
  2. +3
    -11
      lobo.nlogo
  3. +17
    -20
      tank.nls

+ 17
- 1
bullet.nls View File

@@ -10,6 +10,22 @@ bullets-own [
travel-distance
]

to fire-bullet
hatch-bullets 1 [
set max-travel-distance 8
set shooter [who] of myself
set speed 1
set travel-distance 0

set color white
set shape "bullet"
set size 0.5

lt random 10 ; Bullets shouldn't travel perfectly straight
rt random 10
]
end

to do-bullet-logic
fd speed
set travel-distance travel-distance + speed
@@ -25,7 +41,7 @@ to do-bullet-logic
ask target [
if distancexy mxcor mycor < 0.65 [
set is-close-enough true
shot-at myself
shot-at
]
]
]


+ 3
- 11
lobo.nlogo View File

@@ -4,10 +4,6 @@
;; Logo Bolo is a re-envisioning of the classic tank game by Stuart Cheshire in NetLogo.
;;

;; ============
;; Declarations
;; ============

__includes [
"bullet.nls"
"player.nls"
@@ -86,9 +82,7 @@ end

to make-sounds-table
set sounds table:make
table:put sounds "fire player" "Hand Clap"
table:put sounds "fire ally" "Hand Clap"
table:put sounds "fire enemy" "Hand Clap"
table:put sounds "fire" "Hand Clap"
table:put sounds "shot player" "Acoustic Snare"
table:put sounds "shot ally" "Acoustic Snare"
table:put sounds "shot enemy" "Acoustic Snare"
@@ -139,11 +133,10 @@ end

to play-sound [name]
if enable-sound? [
let sname (word name " " get-tank-affiliation)
let dist distancexy ([xcor] of player) ([ycor] of player)
let volume 127 - (dist * 4)
if volume > 0 [
sound:play-drum (table:get sounds sname) volume
sound:play-drum (table:get sounds name) volume
]
]
end
@@ -363,7 +356,6 @@ Rectangle -16777216 true false 135 30 165 90
Rectangle -1 true false 135 90 165 150
Rectangle -1 true false 135 150 165 210
Polygon -16777216 true false 135 30 150 0 165 30 135 30
Rectangle -16777216 true false 120 270 120 270
Rectangle -2674135 true false 135 210 165 270
Rectangle -16777216 true false 120 270 180 300
Polygon -7500403 true false 195 210 165 150 165 210 195 210
@@ -376,7 +368,7 @@ true
1
Rectangle -7500403 true false 78 85 116 103
Polygon -7500403 true false 105 270 210 271 210 105 180 105 180 135 120 135 120 105 90 105 89 270
Polygon -2674135 true true 120 105 120 105 90 105 90 180 120 180 120 195 180 195 180 180 210 180 210 105 180 105 180 105 165 105 165 135 135 135 135 105 120 105
Polygon -2674135 true true 120 105 90 105 90 180 120 180 120 195 180 195 180 180 210 180 210 105 180 105 165 105 165 135 135 135 135 105 120 105
Polygon -1 true false 135 15 135 150 165 150 165 15
Polygon -1 true false 67 105 67 255 97 255 97 105
Polygon -1 true false 202 105 202 255 232 255 232 105


+ 17
- 20
tank.nls View File

@@ -26,7 +26,7 @@ end

to set-tank-vars [tank-team player-tank?]
set acceleration 0.03
set ammunition 20
set ammunition 24
set armor 8
set fire-cool-down 0
set friction 0.0075
@@ -74,34 +74,31 @@ to fire
debug "FIRE" (word who " (" ammunition " left)")
set ammunition ammunition - 1
set fire-cool-down max-fire-rate

hatch-bullets 1 [
set max-travel-distance 8
set shooter [who] of myself
set speed 1
set travel-distance 0

set color white
set shape "bullet"
set size 0.5

lt random 10 ; Bullets shouldn't travel perfectly straight
rt random 10
]
fire-bullet
play-sound "fire"
]
end

to shot-at [bullet]
to shot-at
debug "SHOT" (word who " by " ([shooter] of myself))
set armor armor - 1
ifelse armor = 0 [
debug "KILL" (word who " by " ([shooter] of myself))
play-sound "kill"
die
kill-tank
] [
play-sound "shot"
play-sound (word "shot " get-tank-affiliation)
]
end

to kill-tank
debug "KILL" (word who " by " ([shooter] of myself))
play-sound (word "kill " get-tank-affiliation)
if is-player? [
set player-deaths player-deaths + 1
]
if [is-player?] of (turtle [shooter] of myself) [
set player-kills player-kills + 1
]
die
end

to-report get-tank-affiliation


Loading…
Cancel
Save