Logo Bolo: a re-envisioning of the classic tank game by Stuart Cheshire in NetLogo
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
- ;; lobo: Logo Bolo
- ;; (c) Ben Kurtovic, 2011-2012
-
- breed [bullets bullet]
-
- bullets-own [
- is-shooter-player?
- is-shooter-tank?
- max-travel-distance
- shooter
- speed
- team-of-shooter
- travel-distance
- ]
-
- ;; ==========
- ;; Procedures
- ;; ==========
-
- to fire-bullet [dist]
- hatch-bullets 1 [
- set max-travel-distance dist
- set is-shooter-player? false
- set is-shooter-tank? false
- if [breed] of myself = tanks [
- if [is-player?] of myself [
- set is-shooter-player? true
- ]
- set is-shooter-tank? true
- ]
- set shooter [who] of myself
- set speed 1
- set team-of-shooter [team] of myself
- set travel-distance 0
-
- set color white
- set label ""
- set shape "bullet"
- set size 0.5
-
- ; Bullets shouldn't travel perfectly straight:
- lt random 5
- rt random 5
- ]
- end
-
- to do-bullet-logic
- fd speed
- set travel-distance travel-distance + speed
- if travel-distance >= max-travel-distance [
- explode "small"
- die
- ]
-
- let mxcor xcor
- let mycor ycor
- let shootable-pills-here pillboxes-here with [alive? = true]
- let targets (turtle-set tanks-here shootable-pills-here)
- if is-shooter-tank? [ ; Only tanks can shoot at bases
- let shootable-bases-here bases-here with [armor > 0 and team != -1 and team != team-of-shooter]
- set targets (turtle-set targets shootable-bases-here)
- ]
- let target min-one-of targets [distancexy mxcor mycor]
- if target != nobody [
- ask target [
- if distancexy mxcor mycor < 0.65 [
- if breed = tanks [ tank-shot-at ]
- if breed = pillboxes [ pill-shot-at ]
- if breed = bases [ base-shot-at ]
- ask myself [
- die
- ]
- ]
- ]
- ]
- end
|