Skip to content

Commit

Permalink
Loads more lint cleanups, think I'm done now
Browse files Browse the repository at this point in the history
  • Loading branch information
bobtfish committed Aug 29, 2020
1 parent 8de98ea commit 5a24565
Show file tree
Hide file tree
Showing 13 changed files with 37 additions and 33 deletions.
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@
"go.lintTool": "golangci-lint",
"go.lintFlags": [
"--fast"
]
],
"go.fmtFlags": [ "-s" ]
}
2 changes: 1 addition & 1 deletion character/character.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ import (
"github.com/bobtfish/mayhem/logical"
"github.com/bobtfish/mayhem/movable"
"github.com/bobtfish/mayhem/player"
"github.com/bobtfish/mayhem/rand"
"github.com/bobtfish/mayhem/render"
"github.com/bobtfish/mayhem/spells"
"github.com/bobtfish/mayhem/rand"
)

// Abstract character that can be created
Expand Down
2 changes: 1 addition & 1 deletion character/spells.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package character

import (
"github.com/bobtfish/mayhem/rand"
"github.com/bobtfish/mayhem/fx"
"github.com/bobtfish/mayhem/grid"
"github.com/bobtfish/mayhem/logical"
"github.com/bobtfish/mayhem/player"
"github.com/bobtfish/mayhem/rand"
"github.com/bobtfish/mayhem/spells"
)

Expand Down
10 changes: 5 additions & 5 deletions render/const.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ package render

import "github.com/bobtfish/mayhem/logical"

const CHAR_PIXELS = 64
const SPRITE_SIZE = 16
const INVERSE_VIDEO_OFFSET = 10
const CharPixels = 64
const SpriteSize = 16
const InverseVideoOffset = 10

func MainScreenV() logical.Vec {
return logical.V(0, CHAR_PIXELS)
return logical.V(0, CharPixels)
}

func GameBoardV() logical.Vec {
return MainScreenV().Add(logical.V(CHAR_PIXELS/2, CHAR_PIXELS/2))
return MainScreenV().Add(logical.V(CharPixels/2, CharPixels/2))
}
12 changes: 6 additions & 6 deletions render/sprite.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,16 @@ func GetSpriteSheet(io io.Reader) pixel.Picture {
func NewSpriteDrawer(ss pixel.Picture) SpriteDrawer {
return SpriteDrawer{
SpriteSheet: ss,
SpriteSheetSizeV: logical.V(SPRITE_SIZE, SPRITE_SIZE),
WinSizeV: logical.V(CHAR_PIXELS, CHAR_PIXELS),
SpriteSheetSizeV: logical.V(SpriteSize, SpriteSize),
WinSizeV: logical.V(CharPixels, CharPixels),
}
}

func NewTextDrawer(ss pixel.Picture) SpriteDrawer {
return SpriteDrawer{
SpriteSheet: ss,
SpriteSheetSizeV: logical.V(SPRITE_SIZE/2, SPRITE_SIZE),
WinSizeV: logical.V(CHAR_PIXELS/2, CHAR_PIXELS),
SpriteSheetSizeV: logical.V(SpriteSize/2, SpriteSize),
WinSizeV: logical.V(CharPixels/2, CharPixels),
}
}

Expand All @@ -72,8 +72,8 @@ func (sd SpriteDrawer) GetSpriteMatrix(winPos logical.Vec) pixel.Matrix {
mat := pixel.IM
v := winPos.Multiply(sd.WinSizeV).Add(sd.WinOffsetV).ToPixelVec()
mat = mat.Moved(v)
mat = mat.ScaledXY(v, pixel.V(CHAR_PIXELS/SPRITE_SIZE, CHAR_PIXELS/SPRITE_SIZE))
return mat.Moved(pixel.V(CHAR_PIXELS/2-1, CHAR_PIXELS/2-1))
mat = mat.ScaledXY(v, pixel.V(CharPixels/SpriteSize, CharPixels/SpriteSize))
return mat.Moved(pixel.V(CharPixels/2-1, CharPixels/2-1))
}

func (sd SpriteDrawer) DrawSpriteColor(ssPos, winPos logical.Vec, mask color.Color, target pixel.Target) {
Expand Down
2 changes: 1 addition & 1 deletion screen/attack.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ type RangedCombat struct {
func (screen *RangedCombat) Enter(ss pixel.Picture, win *pixelgl.Window) {
fmt.Printf("In ranged combat state\n")
screen.DisplayRange = true
screen.WithBoard.CursorSprite = CURSOR_RANGEDATTACK
screen.WithBoard.CursorSprite = CursorRangedAttack
}

func (screen *RangedCombat) Step(ss pixel.Picture, win *pixelgl.Window) GameScreen {
Expand Down
18 changes: 9 additions & 9 deletions screen/const.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@ import (
"github.com/bobtfish/mayhem/render"
)

const WIN_X = 1024
const WIN_Y = 768
const GRID_WIDTH = 15
const GRID_HEIGHT = 10
const WinX = 1024
const WinY = 768
const GridWidth = 15
const GridHeight = 10

const CURSOR_SPELL = 0
const CURSOR_BOX = 1
const CURSOR_FLY = 2
const CURSOR_RANGEDATTACK = 3
const CursorSpell = 0
const CursorBox = 1
const CursorFly = 2
const CursorRangedAttack = 3

func cursorSprite(index int) logical.Vec {
// All the cursors in the original sprite sheet are
// are drawn with black on transparent so we need to
// use the inverse version.
return logical.V(4+index+render.INVERSE_VIDEO_OFFSET, 24)
return logical.V(4+index+render.InverseVideoOffset, 24)
}
3 changes: 3 additions & 0 deletions screen/help.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ func (screen *HelpScreenMenu) Step(ss pixel.Picture, win *pixelgl.Window) GameSc

type HelpScreenKeys struct{}

// nolint
func (screen *HelpScreenKeys) Enter(ss pixel.Picture, win *pixelgl.Window) {
ClearScreen(ss, win)
td := TextDrawer(ss)
Expand Down Expand Up @@ -122,6 +123,7 @@ func (screen *HelpScreenCombat) Step(ss pixel.Picture, win *pixelgl.Window) Game

type HelpScreenCombatRanged struct{}

// nolint
func (screen *HelpScreenCombatRanged) Enter(ss pixel.Picture, win *pixelgl.Window) {
ClearScreen(ss, win)
td := TextDrawer(ss)
Expand Down Expand Up @@ -171,6 +173,7 @@ func (screen *HelpScreenUndead) Step(ss pixel.Picture, win *pixelgl.Window) Game

type HelpScreenMounts struct{}

// nolint
func (screen *HelpScreenMounts) Enter(ss pixel.Picture, win *pixelgl.Window) {
ClearScreen(ss, win)
td := TextDrawer(ss)
Expand Down
2 changes: 1 addition & 1 deletion screen/maingame.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ type StartMainGame struct {

// Initialize stuff for the main game
func (screen *StartMainGame) Enter(ss pixel.Picture, win *pixelgl.Window) {
screen.Grid = grid.MakeGameGrid(GRID_WIDTH, GRID_HEIGHT)
screen.Grid = grid.MakeGameGrid(GridWidth, GridHeight)
for i, pos := range player.GetStartPositions(len(screen.Players)) {
screen.Grid.PlaceGameObject(pos, screen.Players[i])
}
Expand Down
4 changes: 2 additions & 2 deletions screen/move.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ type MoveFindCharacterScreen struct {

func (screen *MoveFindCharacterScreen) Enter(ss pixel.Picture, win *pixelgl.Window) {
ClearScreen(ss, win)
screen.WithBoard.CursorSprite = CURSOR_BOX
screen.WithBoard.CursorSprite = CursorBox
if screen.MovedCharacters == nil {
screen.MovedCharacters = make(map[movable.Movable]bool)
}
Expand Down Expand Up @@ -461,7 +461,7 @@ type MoveFlyingCharacterScreen struct {

func (screen *MoveFlyingCharacterScreen) Enter(ss pixel.Picture, win *pixelgl.Window) {
ClearScreen(ss, win)
screen.WithBoard.CursorSprite = CURSOR_FLY
screen.WithBoard.CursorSprite = CursorFly
fmt.Printf("Enter move flying character screen for player %d\n", screen.PlayerIdx+1)
screen.DisplayRange = true // Set this to start to suppress cursor till we move it
}
Expand Down
8 changes: 4 additions & 4 deletions screen/players.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ func (screen *PlayerIconScreen) Enter(ss pixel.Picture, win *pixelgl.Window) {
td.DrawText("Which character?", logical.V(0, 4), win)
td.DrawText("1 2 3 4 5 6 7 8", logical.V(0, 3), win)
for x := 0; x < 8; x++ {
offset := logical.V(render.CHAR_PIXELS/4+render.CHAR_PIXELS/2*x*3, render.CHAR_PIXELS*2-render.CHAR_PIXELS/2)
offset := logical.V(render.CharPixels/4+render.CharPixels/2*x*3, render.CharPixels*2-render.CharPixels/2)
sd.WithOffset(offset).DrawSprite(logical.V(x, 23), logical.V(1, 3), win)
}
}
Expand All @@ -98,7 +98,7 @@ func (screen *PlayerIconScreen) Step(ss pixel.Picture, win *pixelgl.Window) Game
screen.CurrentPlayer.CharacterIcon = logical.V(c-1, 23)
TextDrawer(ss).DrawText(fmt.Sprintf("%d", c), logical.V(17, 4), win)
sd := SpriteDrawer(ss)
offset := sd.WinOffsetV.Add(logical.V(render.CHAR_PIXELS/4, 0))
offset := sd.WinOffsetV.Add(logical.V(render.CharPixels/4, 0))
sd.WithOffset(offset).DrawSprite(screen.CurrentPlayer.CharacterIcon, logical.V(9, 4), win)
return &PlayerColorScreen{PlayersScreen: screen.PlayersScreen}
}
Expand Down Expand Up @@ -129,7 +129,7 @@ func (screen *PlayerColorScreen) Enter(ss pixel.Picture, win *pixelgl.Window) {
td.DrawText("1 2 3 4 5 6 7 8", logical.V(0, 1), win)
colors := characterColorChoices()
for x := 0; x < 8; x++ {
offset := logical.V(render.CHAR_PIXELS/4+render.CHAR_PIXELS/2*x*3, render.CHAR_PIXELS*2-render.CHAR_PIXELS/2)
offset := logical.V(render.CharPixels/4+render.CharPixels/2*x*3, render.CharPixels*2-render.CharPixels/2)
sd.WithOffset(offset).DrawSpriteColor(screen.CurrentPlayer.CharacterIcon, logical.V(1, 1), colors[x], win)
}
}
Expand All @@ -141,7 +141,7 @@ func (screen *PlayerColorScreen) Step(ss pixel.Picture, win *pixelgl.Window) Gam
if c >= 1 && c <= 8 {
colors := characterColorChoices()
td.DrawText(fmt.Sprintf("%d", c), logical.V(13, 2), win)
offset := sd.WinOffsetV.Add(logical.V(render.CHAR_PIXELS/4, 0))
offset := sd.WinOffsetV.Add(logical.V(render.CharPixels/4, 0))
sd.WithOffset(offset).DrawSpriteColor(screen.CurrentPlayer.CharacterIcon, logical.V(7, 2), colors[c-1], win)
screen.CurrentPlayer.Color = colors[c-1]
newPlayer := screen.CurrentPlayer
Expand Down
2 changes: 1 addition & 1 deletion screen/window.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func NewGameWindow(ss pixel.Picture) *GameWindow {

cfg := pixelgl.WindowConfig{
Title: title,
Bounds: pixel.R(0, 0, WIN_X, WIN_Y),
Bounds: pixel.R(0, 0, WinX, WinY),
VSync: true,
}
win, err := pixelgl.NewWindow(cfg)
Expand Down
2 changes: 1 addition & 1 deletion screen/with_board.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ type WithBoard struct {
CursorFlashTime time.Time
Grid *grid.GameGrid
Players []*player.Player
CursorSprite int // Defaults to CURSOR_SPELL
CursorSprite int // Defaults to CursorSpell
}

func (screen *WithBoard) ShouldIDrawCursor() bool {
Expand Down

0 comments on commit 5a24565

Please sign in to comment.