File tree Expand file tree Collapse file tree 3 files changed +377
-58
lines changed
Expand file tree Collapse file tree 3 files changed +377
-58
lines changed Original file line number Diff line number Diff line change @@ -281,6 +281,7 @@ func (level *Level) ResolveDamage() {
281281// Kill ...
282282func (level * Level ) Kill (c * Character ) {
283283 if c .Name == "You" {
284+ level .Player .Hitpoints = 0
284285 level .Player .Speed = 0
285286 groundItems := level .Items [c .Pos ]
286287 level .Items [c .Pos ] = groundItems
@@ -325,6 +326,11 @@ func (level *Level) lineOfSight() {
325326
326327// Draw a circle around the player and draw a line to each endpoint
327328func (level * Level ) bresenham (start Pos , end Pos ) {
329+ // Boundary checks
330+ if ! inRange (level , start ) || ! inRange (level , end ) {
331+ return
332+ }
333+
328334 steep := math .Abs (float64 (end .Y - start .Y )) > math .Abs (float64 (end .X - start .X )) // Is the line steep or not?
329335 // Swap the x and y for start and end
330336 if steep {
You can’t perform that action at this time.
0 commit comments