Skip to content

Commit

Permalink
More cleanups
Browse files Browse the repository at this point in the history
  • Loading branch information
bobtfish committed Aug 29, 2020
1 parent 9a7ba08 commit 2b01cdc
Show file tree
Hide file tree
Showing 9 changed files with 25 additions and 25 deletions.
20 changes: 10 additions & 10 deletions fx/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,24 +20,24 @@ type Fx struct {
}

// GameObject interface START
func (c *Fx) AnimationTick(odd bool) {
c.SpriteIdx++
if c.SpriteIdx == c.SpriteCount && c.RepeatIdx < c.RepeatCount {
c.RepeatIdx++
c.SpriteIdx = 0
func (f *Fx) AnimationTick(odd bool) {
f.SpriteIdx++
if f.SpriteIdx == f.SpriteCount && f.RepeatIdx < f.RepeatCount {
f.RepeatIdx++
f.SpriteIdx = 0
}
}

func (c *Fx) RemoveMe() bool {
return c.SpriteIdx == c.SpriteCount
func (f *Fx) RemoveMe() bool {
return f.SpriteIdx == f.SpriteCount
}

func (c *Fx) IsEmpty() bool {
func (f *Fx) IsEmpty() bool {
return false
}

func (c *Fx) GetSpriteSheetCoordinates() logical.Vec {
return logical.V(c.SpriteVec.X+c.SpriteIdx, c.SpriteVec.Y)
func (f *Fx) GetSpriteSheetCoordinates() logical.Vec {
return logical.V(f.SpriteVec.X+f.SpriteIdx, f.SpriteVec.Y)
}

func (f *Fx) GetColor() color.Color {
Expand Down
8 changes: 4 additions & 4 deletions grid/empty.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ import (

/* Empty game object (bottom level tile) */

const BLANK_SPRITE_X = 8
const BLANK_SPRITE_Y = 26
const BlankSpriteX = 8
const BlankSpriteY = 26

type EmptyObject struct {
SpriteCoordinates logical.Vec
}

var EMPTY_OBJECT = EmptyObject{
SpriteCoordinates: logical.V(BLANK_SPRITE_X, BLANK_SPRITE_Y),
var AnEmptyObject = EmptyObject{
SpriteCoordinates: logical.V(BlankSpriteX, BlankSpriteY),
}

func (e EmptyObject) AnimationTick(odd bool) {}
Expand Down
8 changes: 4 additions & 4 deletions grid/gameobject.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,19 @@ func (s *GameObjectStack) SetBoardPosition(v logical.Vec) {
(*s)[0].SetBoardPosition(v)
}

const DEBUG_GAMEOBJECT_REMOVAL = false
const DebugGameobjectRemoval = false

func (s *GameObjectStack) AnimationTick(odd bool) {
s.TopObject().AnimationTick(odd)
if s.TopObject().RemoveMe() {
if DEBUG_GAMEOBJECT_REMOVAL {
if DebugGameobjectRemoval {
fmt.Printf("About to remove top object from stack, len(%d)\n", len(*s))
for i, ob := range *s {
fmt.Printf(" ob at idx %d is %T(%v)\n", i, ob, ob)
}
}
s.RemoveTopObject()
if DEBUG_GAMEOBJECT_REMOVAL {
if DebugGameobjectRemoval {
fmt.Printf("Did remove top object from stack, len(%d)\n", len(*s))
for i, ob := range *s {
fmt.Printf(" ob at idx %d is %T(%v)\n", i, ob, ob)
Expand Down Expand Up @@ -85,6 +85,6 @@ func (s *GameObjectStack) RemoveTopObject() GameObjectStackable {

func NewGameObjectStack() *GameObjectStack {
os := make(GameObjectStack, 1)
os[0] = EMPTY_OBJECT
os[0] = AnEmptyObject
return &os
}
4 changes: 2 additions & 2 deletions logical/vec.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,8 @@ func (v Vec) Path() []Vec {
path := make([]Vec, 0)
for Xcurrent < float64(w.X) || Ycurrent < float64(w.Y) {
path = append(path, V(int(Xcurrent)*Xsign, int(Ycurrent)*Ysign))
Xcurrent = Xcurrent + Xstep
Ycurrent = Ycurrent + Ystep
Xcurrent += Xstep
Ycurrent += Ystep
}
return path
}
2 changes: 1 addition & 1 deletion player/player.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import (
"fmt"
"image/color"

"github.com/bobtfish/mayhem/rand"
"github.com/bobtfish/mayhem/fx"
"github.com/bobtfish/mayhem/logical"
"github.com/bobtfish/mayhem/rand"
"github.com/bobtfish/mayhem/spells"
)

Expand Down
2 changes: 1 addition & 1 deletion render/sprite.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"image"

"image/color"
_ "image/png"
_ "image/png" // For the side effects
"io"

"github.com/faiface/pixel"
Expand Down
2 changes: 1 addition & 1 deletion screen/attack.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ import (
"github.com/faiface/pixel"
"github.com/faiface/pixel/pixelgl"

"github.com/bobtfish/mayhem/rand"
"github.com/bobtfish/mayhem/character"
"github.com/bobtfish/mayhem/grid"
"github.com/bobtfish/mayhem/logical"
"github.com/bobtfish/mayhem/movable"
"github.com/bobtfish/mayhem/player"
"github.com/bobtfish/mayhem/rand"
)

type RangedCombat struct {
Expand Down
2 changes: 1 addition & 1 deletion screen/grow.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ import (
"github.com/faiface/pixel"
"github.com/faiface/pixel/pixelgl"

"github.com/bobtfish/mayhem/rand"
"github.com/bobtfish/mayhem/character"
"github.com/bobtfish/mayhem/fx"
"github.com/bobtfish/mayhem/logical"
"github.com/bobtfish/mayhem/player"
"github.com/bobtfish/mayhem/rand"
)

const GROW_CHANCE = 15
Expand Down
2 changes: 1 addition & 1 deletion spells/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import (
"fmt"
"image/color"

"github.com/bobtfish/mayhem/rand"
"github.com/bobtfish/mayhem/fx"
"github.com/bobtfish/mayhem/grid"
"github.com/bobtfish/mayhem/logical"
"github.com/bobtfish/mayhem/rand"
"github.com/bobtfish/mayhem/render"
)

Expand Down

0 comments on commit 2b01cdc

Please sign in to comment.