Skip to content

Commit

Permalink
Do I really need to pass everything by pointer? It works now, but it'…
Browse files Browse the repository at this point in the history
…s a bit inconsistent
  • Loading branch information
VedVid committed Nov 16, 2018
1 parent cf1fe76 commit 89e9059
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
8 changes: 6 additions & 2 deletions controls.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@ package main

import (
blt "bearlibterminal"
"fmt"
)

func Controls(k int, p *Creature, b Board, c Creatures, o Objects) bool {
func Controls(k int, p *Creature, b Board, c Creatures, o *Objects) bool {
/* Function Controls is input handler.
It takes integer k (key codes are basically numbers,
but creating new "type key int" is not convenient)
Expand All @@ -43,7 +44,10 @@ func Controls(k int, p *Creature, b Board, c Creatures, o Objects) bool {
turnSpent = p.MoveOrAttack(-1, 0, b, c)

case blt.TK_G:
turnSpent = p.PickUp(&o)
fmt.Println()
fmt.Println("PickingUp")
turnSpent = p.PickUp(o)
fmt.Println(len(*o))
}
return turnSpent
}
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func main() {
if key == blt.TK_ESCAPE || actors[0].HPCurrent <= 0 {
break
} else {
turnSpent := Controls(key, player, cells, actors, objs)
turnSpent := Controls(key, player, cells, actors, &objs)
if turnSpent == true {
CreaturesTakeTurn(cells, actors)
}
Expand Down
4 changes: 4 additions & 0 deletions render.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ package main

import (
blt "bearlibterminal"
"fmt"
)

const (
Expand Down Expand Up @@ -86,6 +87,9 @@ func PrintObjects(b Board, o Objects, c Creatures) {
always pass "]]" instead of "]".
Prints every object on its coords if certain conditions are met:
AlwaysVisible bool is set to true, or is in player fov. */
fmt.Println()
fmt.Println("PrintObjects")
fmt.Println(len(o))
for _, v := range o {
if (IsInFOV(b, c[0].X, c[0].Y, v.X, v.Y) == true) ||
(v.AlwaysVisible == true) {
Expand Down

0 comments on commit 89e9059

Please sign in to comment.