Update dependencies

main
Trevor Slocum 2022-06-10 17:14:10 -07:00
parent 7cad0b3628
commit 2289376545
27 changed files with 362 additions and 598 deletions

141
LICENSE
View File

@ -1,5 +1,5 @@
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
GNU AFFERO GENERAL PUBLIC LICENSE
Version 3, 19 November 2007
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
@ -7,17 +7,15 @@
Preamble
The GNU General Public License is a free, copyleft license for
software and other kinds of works.
The GNU Affero General Public License is a free, copyleft license for
software and other kinds of works, specifically designed to ensure
cooperation with the community in the case of network server software.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
the GNU General Public License is intended to guarantee your freedom to
our General Public Licenses are intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users. We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors. You can apply it to
your programs, too.
software for all its users.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
@ -26,44 +24,34 @@ them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
To protect your rights, we need to prevent others from denying you
these rights or asking you to surrender the rights. Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.
Developers that use our General Public Licenses protect your rights
with two steps: (1) assert copyright on the software, and (2) offer
you this License which gives you legal permission to copy, distribute
and/or modify the software.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received. You must make sure that they, too, receive
or can get the source code. And you must show them these terms so they
know their rights.
A secondary benefit of defending all users' freedom is that
improvements made in alternate versions of the program, if they
receive widespread use, become available for other developers to
incorporate. Many developers of free software are heartened and
encouraged by the resulting cooperation. However, in the case of
software used on network servers, this result may fail to come about.
The GNU General Public License permits making a modified version and
letting the public access it on a server without ever releasing its
source code to the public.
Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.
The GNU Affero General Public License is designed specifically to
ensure that, in such cases, the modified source code becomes available
to the community. It requires the operator of a network server to
provide the source code of the modified version running there to the
users of that server. Therefore, public use of a modified version, on
a publicly accessible server, gives the public access to the source
code of the modified version.
For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software. For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.
Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so. This is fundamentally incompatible with the aim of
protecting users' freedom to change the software. The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable. Therefore, we
have designed this version of the GPL to prohibit the practice for those
products. If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.
Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary. To prevent this, the GPL assures that
patents cannot be used to render the program non-free.
An older license, called the Affero General Public License and
published by Affero, was designed to accomplish similar goals. This is
a different license, not a version of the Affero GPL, but Affero has
released a new version of the Affero GPL which permits relicensing under
this license.
The precise terms and conditions for copying, distribution and
modification follow.
@ -72,7 +60,7 @@ modification follow.
0. Definitions.
"This License" refers to version 3 of the GNU General Public License.
"This License" refers to version 3 of the GNU Affero General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
@ -549,35 +537,45 @@ to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Use with the GNU Affero General Public License.
13. Remote Network Interaction; Use with the GNU General Public License.
Notwithstanding any other provision of this License, if you modify the
Program, your modified version must prominently offer all users
interacting with it remotely through a computer network (if your version
supports such interaction) an opportunity to receive the Corresponding
Source of your version by providing access to the Corresponding Source
from a network server at no charge, through some standard or customary
means of facilitating copying of software. This Corresponding Source
shall include the Corresponding Source for any work covered by version 3
of the GNU General Public License that is incorporated pursuant to the
following paragraph.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
under version 3 of the GNU General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.
but the work with which it is combined will remain governed by version
3 of the GNU General Public License.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
the GNU Affero General Public License from time to time. Such new versions
will be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU General
Program specifies that a certain numbered version of the GNU Affero General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU General Public License, you may choose any version ever published
GNU Affero General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU General Public License can be used, that proxy's
versions of the GNU Affero General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
@ -635,40 +633,29 @@ the "copyright" line and a pointer to where the full notice is found.
Copyright (C) <year> <name of author>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
GNU Affero General Public License for more details.
You should have received a copy of the GNU General Public License
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
<program> Copyright (C) <year> <name of author>
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, your program's commands
might be different; for a GUI interface, you would use an "about box".
If your software can interact with users remotely through a computer
network, you should also make sure that it provides a way for users to
get its source. For example, if your program is a web application, its
interface could display a "Source" link that leads users to an archive
of the code. There are many ways you could offer source, and different
solutions will be better for different programs; see section 13 for the
specific requirements.
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
For more information on this, and how to apply and follow the GNU AGPL, see
<https://www.gnu.org/licenses/>.
The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
<https://www.gnu.org/licenses/why-not-lgpl.html>.

View File

@ -2,12 +2,9 @@ package component
import (
"math/rand"
. "code.rocketnine.space/tslocum/brownboxbatman/ecs"
"code.rocketnine.space/tslocum/gohan"
)
type CreepComponent struct {
type Creep struct {
Type int
Active bool
@ -31,17 +28,3 @@ const (
CreepMediumRock
CreepLargeRock
)
var CreepComponentID = ECS.NewComponentID()
func (p *CreepComponent) ComponentID() gohan.ComponentID {
return CreepComponentID
}
func Creep(ctx *gohan.Context) *CreepComponent {
c, ok := ctx.Component(CreepComponentID).(*CreepComponent)
if !ok {
return nil
}
return c
}

View File

@ -1,24 +1,5 @@
package component
import (
. "code.rocketnine.space/tslocum/brownboxbatman/ecs"
"code.rocketnine.space/tslocum/gohan"
)
type CreepBulletComponent struct {
type CreepBullet struct {
Invulnerable bool // Invulnerable to hazards
}
var CreepBulletComponentID = ECS.NewComponentID()
func (p *CreepBulletComponent) ComponentID() gohan.ComponentID {
return CreepBulletComponentID
}
func CreepBullet(ctx *gohan.Context) *CreepBulletComponent {
c, ok := ctx.Component(CreepBulletComponentID).(*CreepBulletComponent)
if !ok {
return nil
}
return c
}

View File

@ -1,23 +1,4 @@
package component
import (
. "code.rocketnine.space/tslocum/brownboxbatman/ecs"
"code.rocketnine.space/tslocum/gohan"
)
type PlayerBulletComponent struct {
}
var PlayerBulletComponentID = ECS.NewComponentID()
func (p *PlayerBulletComponent) ComponentID() gohan.ComponentID {
return PlayerBulletComponentID
}
func PlayerBullet(ctx *gohan.Context) *PlayerBulletComponent {
c, ok := ctx.Component(PlayerBulletComponentID).(*PlayerBulletComponent)
if !ok {
return nil
}
return c
type PlayerBullet struct {
}

View File

@ -1,24 +1,5 @@
package component
import (
. "code.rocketnine.space/tslocum/brownboxbatman/ecs"
"code.rocketnine.space/tslocum/gohan"
)
type PositionComponent struct {
type Position struct {
X, Y float64
}
var PositionComponentID = ECS.NewComponentID()
func (p *PositionComponent) ComponentID() gohan.ComponentID {
return PositionComponentID
}
func Position(ctx *gohan.Context) *PositionComponent {
c, ok := ctx.Component(PositionComponentID).(*PositionComponent)
if !ok {
return nil
}
return c
}

View File

@ -1,23 +1,4 @@
package component
import (
. "code.rocketnine.space/tslocum/brownboxbatman/ecs"
"code.rocketnine.space/tslocum/gohan"
)
type RailComponent struct {
}
var RailComponentID = ECS.NewComponentID()
func (p *RailComponent) ComponentID() gohan.ComponentID {
return RailComponentID
}
func Rail(ctx *gohan.Context) *RailComponent {
c, ok := ctx.Component(RailComponentID).(*RailComponent)
if !ok {
return nil
}
return c
type Rail struct {
}

View File

@ -3,13 +3,10 @@ package component
import (
"time"
. "code.rocketnine.space/tslocum/brownboxbatman/ecs"
"code.rocketnine.space/tslocum/gohan"
"github.com/hajimehoshi/ebiten/v2"
)
type SpriteComponent struct {
type Sprite struct {
Image *ebiten.Image
HorizontalFlip bool
VerticalFlip bool
@ -31,17 +28,3 @@ type SpriteComponent struct {
OverrideColorScale bool
ColorScale float64
}
var SpriteComponentID = ECS.NewComponentID()
func (p *SpriteComponent) ComponentID() gohan.ComponentID {
return SpriteComponentID
}
func Sprite(ctx *gohan.Context) *SpriteComponent {
c, ok := ctx.Component(SpriteComponentID).(*SpriteComponent)
if !ok {
return nil
}
return c
}

View File

@ -1,24 +1,5 @@
package component
import (
. "code.rocketnine.space/tslocum/brownboxbatman/ecs"
"code.rocketnine.space/tslocum/gohan"
)
type VelocityComponent struct {
type Velocity struct {
X, Y float64
}
var VelocityComponentID = ECS.NewComponentID()
func (c *VelocityComponent) ComponentID() gohan.ComponentID {
return VelocityComponentID
}
func Velocity(ctx *gohan.Context) *VelocityComponent {
c, ok := ctx.Component(VelocityComponentID).(*VelocityComponent)
if !ok {
return nil
}
return c
}

View File

@ -1,11 +1,6 @@
package component
import (
. "code.rocketnine.space/tslocum/brownboxbatman/ecs"
"code.rocketnine.space/tslocum/gohan"
)
type WeaponComponent struct {
type Weapon struct {
Equipped bool
Damage int
@ -16,17 +11,3 @@ type WeaponComponent struct {
BulletSpeed float64
}
var WeaponComponentID = ECS.NewComponentID()
func (p *WeaponComponent) ComponentID() gohan.ComponentID {
return WeaponComponentID
}
func Weapon(ctx *gohan.Context) *WeaponComponent {
c, ok := ctx.Component(WeaponComponentID).(*WeaponComponent)
if !ok {
return nil
}
return c
}

View File

@ -3,28 +3,27 @@ package entity
import (
"code.rocketnine.space/tslocum/brownboxbatman/asset"
"code.rocketnine.space/tslocum/brownboxbatman/component"
. "code.rocketnine.space/tslocum/brownboxbatman/ecs"
"code.rocketnine.space/tslocum/gohan"
)
func NewCreepBullet(x, y, xSpeed, ySpeed float64) gohan.Entity {
bullet := ECS.NewEntity()
bullet := gohan.NewEntity()
ECS.AddComponent(bullet, &component.PositionComponent{
bullet.AddComponent(&component.Position{
X: x,
Y: y,
})
ECS.AddComponent(bullet, &component.VelocityComponent{
bullet.AddComponent(&component.Velocity{
X: xSpeed,
Y: ySpeed,
})
ECS.AddComponent(bullet, &component.SpriteComponent{
bullet.AddComponent(&component.Sprite{
Image: asset.ImgWhiteSquare,
})
ECS.AddComponent(bullet, &component.CreepBulletComponent{})
bullet.AddComponent(&component.CreepBullet{})
return bullet
}

View File

@ -3,29 +3,28 @@ package entity
import (
"code.rocketnine.space/tslocum/brownboxbatman/asset"
"code.rocketnine.space/tslocum/brownboxbatman/component"
. "code.rocketnine.space/tslocum/brownboxbatman/ecs"
"code.rocketnine.space/tslocum/gohan"
)
func NewPlayer() gohan.Entity {
player := ECS.NewEntity()
player := gohan.NewEntity()
ECS.AddComponent(player, &component.PositionComponent{})
player.AddComponent(&component.Position{})
ECS.AddComponent(player, &component.VelocityComponent{})
player.AddComponent(&component.Velocity{})
weapon := &component.WeaponComponent{
weapon := &component.Weapon{
Damage: 1,
FireRate: 144 / 16,
BulletSpeed: 8,
}
ECS.AddComponent(player, weapon)
player.AddComponent(weapon)
ECS.AddComponent(player, &component.SpriteComponent{
player.AddComponent(&component.Sprite{
Image: asset.ImgBat,
})
ECS.AddComponent(player, &component.RailComponent{})
player.AddComponent(&component.Rail{})
return player
}

View File

@ -3,28 +3,27 @@ package entity
import (
"code.rocketnine.space/tslocum/brownboxbatman/asset"
"code.rocketnine.space/tslocum/brownboxbatman/component"
. "code.rocketnine.space/tslocum/brownboxbatman/ecs"
"code.rocketnine.space/tslocum/gohan"
)
func NewPlayerBullet(x, y, xSpeed, ySpeed float64) gohan.Entity {
bullet := ECS.NewEntity()
bullet := gohan.NewEntity()
ECS.AddComponent(bullet, &component.PositionComponent{
bullet.AddComponent(&component.Position{
X: x,
Y: y,
})
ECS.AddComponent(bullet, &component.VelocityComponent{
bullet.AddComponent(&component.Velocity{
X: xSpeed,
Y: ySpeed,
})
ECS.AddComponent(bullet, &component.SpriteComponent{
bullet.AddComponent(&component.Sprite{
Image: asset.ImgBlackSquare,
})
ECS.AddComponent(bullet, &component.PlayerBulletComponent{})
bullet.AddComponent(&component.PlayerBullet{})
return bullet
}

View File

@ -7,9 +7,10 @@ import (
"sync"
"time"
"code.rocketnine.space/tslocum/gohan"
"code.rocketnine.space/tslocum/brownboxbatman/asset"
"code.rocketnine.space/tslocum/brownboxbatman/component"
. "code.rocketnine.space/tslocum/brownboxbatman/ecs"
"code.rocketnine.space/tslocum/brownboxbatman/entity"
"code.rocketnine.space/tslocum/brownboxbatman/system"
"code.rocketnine.space/tslocum/brownboxbatman/world"
@ -53,7 +54,7 @@ func NewGame() (*game, error) {
}
const numEntities = 30000
ECS.Preallocate(numEntities)
gohan.Preallocate(numEntities)
return g, nil
}
@ -75,8 +76,9 @@ func (g *game) changeMap(filePath string) {
w := float64(world.World.Map.Width * world.World.Map.TileWidth)
h := float64(world.World.Map.Height * world.World.Map.TileHeight)
position := ECS.Component(world.World.Player, component.PositionComponentID).(*component.PositionComponent)
position.X, position.Y = w/2, h-playerStartOffset
world.World.Player.With(func(position *component.Position) {
position.X, position.Y = w/2, h-playerStartOffset
})
world.World.CamX, world.World.CamY = 0, h-camStartOffset
}
@ -120,7 +122,7 @@ func (g *game) Update() error {
world.World.GameOver = false
}
err := ECS.Update()
err := gohan.Update()
if err != nil {
return err
}
@ -128,27 +130,26 @@ func (g *game) Update() error {
}
func (g *game) Draw(screen *ebiten.Image) {
err := ECS.Draw(screen)
err := gohan.Draw(screen)
if err != nil {
panic(err)
}
}
func (g *game) addSystems() {
ecs := ECS
g.movementSystem = system.NewMovementSystem()
ecs.AddSystem(system.NewPlayerMoveSystem(world.World.Player, g.movementSystem))
ecs.AddSystem(system.NewplayerFireSystem())
ecs.AddSystem(g.movementSystem)
ecs.AddSystem(system.NewCreepSystem())
ecs.AddSystem(system.NewCameraSystem())
ecs.AddSystem(system.NewRailSystem())
g.renderSystem = system.NewRenderSystem()
ecs.AddSystem(g.renderSystem)
ecs.AddSystem(system.NewRenderMessageSystem())
ecs.AddSystem(system.NewRenderDebugTextSystem(world.World.Player))
ecs.AddSystem(system.NewProfileSystem(world.World.Player))
gohan.AddSystem(system.NewPlayerMoveSystem(world.World.Player, g.movementSystem))
gohan.AddSystem(system.NewplayerFireSystem())
gohan.AddSystem(g.movementSystem)
gohan.AddSystem(system.NewCreepSystem())
gohan.AddSystem(system.NewCameraSystem())
gohan.AddSystem(system.NewRailSystem())
gohan.AddSystem(g.renderSystem)
gohan.AddSystem(system.NewRenderMessageSystem())
gohan.AddSystem(system.NewRenderDebugTextSystem(world.World.Player))
gohan.AddSystem(system.NewProfileSystem(world.World.Player))
}
func (g *game) loadAssets() error {

23
go.mod
View File

@ -3,20 +3,21 @@ module code.rocketnine.space/tslocum/brownboxbatman
go 1.17
require (
code.rocketnine.space/tslocum/gohan v0.0.0-20211229205912-263cd48bca66
github.com/hajimehoshi/ebiten/v2 v2.2.3
github.com/lafriks/go-tiled v0.6.0
code.rocketnine.space/tslocum/gohan v0.0.0-20220611080547-c66dd322f959
github.com/hajimehoshi/ebiten/v2 v2.3.3
github.com/lafriks/go-tiled v0.7.0
)
require (
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20211213063430-748e38ca8aec // indirect
github.com/hajimehoshi/oto/v2 v2.1.0-alpha.5 // indirect
github.com/jezek/xgb v0.0.0-20210312150743-0e0f116e1240 // indirect
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20220516021902-eb3e265c7661 // indirect
github.com/gofrs/flock v0.8.1 // indirect
github.com/hajimehoshi/oto/v2 v2.1.0 // indirect
github.com/jezek/xgb v1.0.1 // indirect
github.com/jfreymuth/oggvorbis v1.0.3 // indirect
github.com/jfreymuth/vorbis v1.0.2 // indirect
golang.org/x/exp v0.0.0-20211221223016-e29036178569 // indirect
golang.org/x/image v0.0.0-20211028202545-6944b10bf410 // indirect
golang.org/x/mobile v0.0.0-20211207041440-4e6c2922fdee // indirect
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c // indirect
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e // indirect
golang.org/x/exp/shiny v0.0.0-20220609121020-a51bd0440498 // indirect
golang.org/x/image v0.0.0-20220601225756-64ec528b34cd // indirect
golang.org/x/mobile v0.0.0-20220518205345-8578da9835fd // indirect
golang.org/x/sync v0.0.0-20220601150217-0de741cfad7f // indirect
golang.org/x/sys v0.0.0-20220610221304-9f5ed59c137d // indirect
)

83
go.sum
View File

@ -1,92 +1,105 @@
code.rocketnine.space/tslocum/gohan v0.0.0-20211229205912-263cd48bca66 h1:H8rapZ2HCQZH+DpcXRZh52kUcXDzgHlJwsZgEGqezpo=
code.rocketnine.space/tslocum/gohan v0.0.0-20211229205912-263cd48bca66/go.mod h1:nOvFBFvFPl5sDtkMy2Fn/7QZcWq5RE98/mK+INLqIWg=
code.rocketnine.space/tslocum/gohan v0.0.0-20220611080547-c66dd322f959 h1:gxih+XUGSZbhDAedXqrtJPBBHODDQMl9mBKbHmhFr4Y=
code.rocketnine.space/tslocum/gohan v0.0.0-20220611080547-c66dd322f959/go.mod h1:Z8otqLKIINu0nowsu2IidBFe6M0GkVmGBhP2T4FNKQY=
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/disintegration/imaging v1.6.2/go.mod h1:44/5580QXChDfwIclfc/PCwrr44amcmDAg8hxG0Ewe4=
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20210727001814-0db043d8d5be/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20211213063430-748e38ca8aec h1:3FLiRYO6PlQFDpUU7OEFlWgjGD1jnBIVSJ5SYRWk+9c=
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20211213063430-748e38ca8aec/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
github.com/hajimehoshi/bitmapfont/v2 v2.1.3/go.mod h1:2BnYrkTQGThpr/CY6LorYtt/zEPNzvE/ND69CRTaHMs=
github.com/hajimehoshi/ebiten/v2 v2.2.3 h1:jZUP3XWP6mXaw9SCrjWT5Pl6EPuz6FY737dZQgN1KJ4=
github.com/hajimehoshi/ebiten/v2 v2.2.3/go.mod h1:olKl/qqhMBBAm2oI7Zy292nCtE+nitlmYKNF3UpbFn0=
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20220320163800-277f93cfa958/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20220516021902-eb3e265c7661 h1:1bpooddSK2996NWM/1TW59cchQOm9MkoV9DkhSJH1BI=
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20220516021902-eb3e265c7661/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
github.com/gofrs/flock v0.8.1 h1:+gYjHKf32LDeiEEFhQaotPbLuUXjY5ZqxKgXy7n59aw=
github.com/gofrs/flock v0.8.1/go.mod h1:F1TvTiK9OcQqauNUHlbJvyl9Qa1QvF/gOUDKA14jxHU=
github.com/hajimehoshi/bitmapfont/v2 v2.2.0/go.mod h1:Llj2wTYXMuCTJEw2ATNIO6HbFPOoBYPs08qLdFAxOsQ=
github.com/hajimehoshi/ebiten/v2 v2.3.3 h1:v72UzprVvWGE+HGcypkLI9Ikd237fqzpio5idPk9KNI=
github.com/hajimehoshi/ebiten/v2 v2.3.3/go.mod h1:vxwpo0q0oSi1cIll0Q3Ui33TVZgeHuFVYzIRk7FwuVk=
github.com/hajimehoshi/file2byteslice v0.0.0-20210813153925-5340248a8f41/go.mod h1:CqqAHp7Dk/AqQiwuhV1yT2334qbA/tFWQW0MD2dGqUE=
github.com/hajimehoshi/go-mp3 v0.3.2/go.mod h1:qMJj/CSDxx6CGHiZeCgbiq2DSUkbK0UbtXShQcnfyMM=
github.com/hajimehoshi/go-mp3 v0.3.3/go.mod h1:qMJj/CSDxx6CGHiZeCgbiq2DSUkbK0UbtXShQcnfyMM=
github.com/hajimehoshi/oto v0.6.1/go.mod h1:0QXGEkbuJRohbJaxr7ZQSxnju7hEhseiPx2hrh6raOI=
github.com/hajimehoshi/oto/v2 v2.1.0-alpha.2/go.mod h1:rUKQmwMkqmRxe+IAof9+tuYA2ofm8cAWXFmSfzDN8vQ=
github.com/hajimehoshi/oto/v2 v2.1.0-alpha.5 h1:AwLKf51fpOTVIBxgQUvNokmj/IaYMYsqJQBh6wif1c8=
github.com/hajimehoshi/oto/v2 v2.1.0-alpha.5/go.mod h1:rUKQmwMkqmRxe+IAof9+tuYA2ofm8cAWXFmSfzDN8vQ=
github.com/hajimehoshi/oto/v2 v2.1.0 h1:/h+UkbKzhD7xBHOQlWgKUplBPZ+J4DK3P2Y7g2UF1X4=
github.com/hajimehoshi/oto/v2 v2.1.0/go.mod h1:9i0oYbpJ8BhVGkXDKdXKfFthX1JUNfXjeTp944W8TGM=
github.com/jakecoffman/cp v1.1.0/go.mod h1:JjY/Fp6d8E1CHnu74gWNnU0+b9VzEdUVPoJxg2PsTQg=
github.com/jezek/xgb v0.0.0-20210312150743-0e0f116e1240 h1:dy+DS31tGEGCsZzB45HmJJNHjur8GDgtRNX9U7HnSX4=
github.com/jezek/xgb v0.0.0-20210312150743-0e0f116e1240/go.mod h1:3P4UH/k22rXyHIJD2w4h2XMqPX4Of/eySEZq9L6wqc4=
github.com/jezek/xgb v1.0.0/go.mod h1:nrhwO0FX/enq75I7Y7G8iN1ubpSGZEiA3v9e9GyRFlk=
github.com/jezek/xgb v1.0.1 h1:YUGhxps0aR7J2Xplbs23OHnV1mWaxFVcOl9b+1RQkt8=
github.com/jezek/xgb v1.0.1/go.mod h1:nrhwO0FX/enq75I7Y7G8iN1ubpSGZEiA3v9e9GyRFlk=
github.com/jfreymuth/oggvorbis v1.0.3 h1:MLNGGyhOMiVcvea9Dp5+gbs2SAwqwQbtrWnonYa0M0Y=
github.com/jfreymuth/oggvorbis v1.0.3/go.mod h1:1U4pqWmghcoVsCJJ4fRBKv9peUJMBHixthRlBeD6uII=
github.com/jfreymuth/vorbis v1.0.2 h1:m1xH6+ZI4thH927pgKD8JOH4eaGRm18rEE9/0WKjvNE=
github.com/jfreymuth/vorbis v1.0.2/go.mod h1:DoftRo4AznKnShRl1GxiTFCseHr4zR9BN3TWXyuzrqQ=
github.com/lafriks/go-tiled v0.6.0 h1:kDJSvRPep6/5dtfdu0hqiAhXL40HmciMEXRb1TN/AU0=
github.com/lafriks/go-tiled v0.6.0/go.mod h1:xy+4iO8AKWpFNBWeqBqnq+Cb3Oirm5oin/irP/jPx6A=
github.com/pkg/browser v0.0.0-20180916011732-0a3d74bf9ce4/go.mod h1:4OwLy04Bl9Ef3GJJCoec+30X3LQs/0/m4HFRt/2LUSA=
github.com/kr/pretty v0.2.1 h1:Fmg33tUaq4/8ym9TJN1x7sLJnHVwhP33CNkpYV/7rwI=
github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/lafriks/go-tiled v0.7.0 h1:xb1iVYtPpjpHx9i/LjqHwoS2xdfrihCsFRKOFn7fOBU=
github.com/lafriks/go-tiled v0.7.0/go.mod h1:xy+4iO8AKWpFNBWeqBqnq+Cb3Oirm5oin/irP/jPx6A=
github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8/go.mod h1:HKlIX3XHQyzLZPlr7++PzdhaXEj94dEiJgZDTsxEqUI=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
github.com/yuin/goldmark v1.4.0/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
github.com/yuin/goldmark v1.4.1/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20190731235908-ec7cb31e5a56/go.mod h1:JhuoJpWY28nO4Vef9tZUw9qufEGTyX1+7lmHxV5q5G4=
golang.org/x/exp v0.0.0-20211221223016-e29036178569 h1:a59ODISX5tE9svMyl7ITFQtdrV6Jnidn76Zt9dZnKXE=
golang.org/x/exp v0.0.0-20211221223016-e29036178569/go.mod h1:b9TAUYHmRtqA6klRHApnXMnj+OyLce4yF5cZCUbk2ps=
golang.org/x/exp/shiny v0.0.0-20220609121020-a51bd0440498 h1:mJjyic/dxHcz1W6IUE8zf6+RltuO8+9mS45tTtb4F6k=
golang.org/x/exp/shiny v0.0.0-20220609121020-a51bd0440498/go.mod h1:VjAR7z0ngyATZTELrBSkxOOHhhlnVUxDye4mcjx5h/8=
golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js=
golang.org/x/image v0.0.0-20190703141733-d6a02ce849c9/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
golang.org/x/image v0.0.0-20191009234506-e7c1f5e7dbb8/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
golang.org/x/image v0.0.0-20210628002857-a66eb6448b8d/go.mod h1:023OzeP/+EPmXeapQh35lcL3II3LrY8Ic+EFFKVhULM=
golang.org/x/image v0.0.0-20211028202545-6944b10bf410 h1:hTftEOvwiOq2+O8k2D5/Q7COC7k5Qcrgc2TFURJYnvQ=
golang.org/x/image v0.0.0-20211028202545-6944b10bf410/go.mod h1:023OzeP/+EPmXeapQh35lcL3II3LrY8Ic+EFFKVhULM=
golang.org/x/image v0.0.0-20220321031419-a8550c1d254a/go.mod h1:023OzeP/+EPmXeapQh35lcL3II3LrY8Ic+EFFKVhULM=
golang.org/x/image v0.0.0-20220601225756-64ec528b34cd h1:9NbNcTg//wfC5JskFW4Z3sqwVnjmJKHxLAol1bW2qgw=
golang.org/x/image v0.0.0-20220601225756-64ec528b34cd/go.mod h1:doUCurBvlfPMKfmIpRIywoHmhN3VyhnoFDbvIEWF4hY=
golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE=
golang.org/x/mobile v0.0.0-20190415191353-3e0bab5405d6/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o=
golang.org/x/mobile v0.0.0-20210902104108-5d9a33257ab5/go.mod h1:c4YKU3ZylDmvbw+H/PSvm42vhdWbuxCzbonauEAP9B8=
golang.org/x/mobile v0.0.0-20211207041440-4e6c2922fdee h1:/tShaw8UTf0XzI8DOZwQHzC7d6Vi3EtrBnftiZ4vAvU=
golang.org/x/mobile v0.0.0-20211207041440-4e6c2922fdee/go.mod h1:pe2sM7Uk+2Su1y7u/6Z8KJ24D7lepUjFZbhFOrmDfuQ=
golang.org/x/mobile v0.0.0-20220518205345-8578da9835fd h1:x1GptNaTtxPAlTVIAJk61fuXg0y17h09DTxyb+VNC/k=
golang.org/x/mobile v0.0.0-20220518205345-8578da9835fd/go.mod h1:pe2sM7Uk+2Su1y7u/6Z8KJ24D7lepUjFZbhFOrmDfuQ=
golang.org/x/mod v0.1.0/go.mod h1:0QHyrYULN0/3qlju5TqG8bIK38QM8yzMo5ekMj3DlcY=
golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.6.0-dev.0.20220106191415-9b9b3d81d5e3/go.mod h1:3p9vT2HGsQu2K1YbXdKPJLVgG5VJdoTa1poYQBtP1AY=
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM=
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/net v0.0.0-20210805182204-aaa1db679c0d/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c h1:5KslGYwFpkhGh+Q16bwMP3cOontH8FOep7tGV86Y7SQ=
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20220601150217-0de741cfad7f h1:Ax0t5p6N38Ga0dThY21weqDEyz2oklo4IvDkpigvkD8=
golang.org/x/sync v0.0.0-20220601150217-0de741cfad7f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190429190828-d89cdac9e872/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210616045830-e2b7044e8c71/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210917161153-d61c044b1678/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e h1:fLOSk5Q00efkSvAm+4xcoXD+RRmLmmulPn5I3Y9F2EM=
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20211019181941-9d821ace8654/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220408201424-a24fb2fb8a0f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220610221304-9f5ed59c137d h1:Zu/JngovGLVi6t2J3nmAf3AoTDwuzw85YZ3b9o4yU7s=
golang.org/x/sys v0.0.0-20220610221304-9f5ed59c137d/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20190312151545-0bb0c0a6e846/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.1.2/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
golang.org/x/tools v0.1.6/go.mod h1:LGqMHiF4EqQNHR1JncWGqT5BVaXmza+X+BDGol+dOxo=
golang.org/x/tools v0.1.8-0.20211022200916-316ba0b74098/go.mod h1:LGqMHiF4EqQNHR1JncWGqT5BVaXmza+X+BDGol+dOxo=
golang.org/x/tools v0.1.10/go.mod h1:Uh6Zz+xoGYZom868N8YTex3t7RhtHDBrE8Gzo9bV56E=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

View File

@ -6,6 +6,7 @@ builds:
# ldflags:
# - -s -w -X code.rocketnine.space/tslocum/brownboxbatman/main.Version={{.Version}}
goos:
- darwin
- js
- linux
- windows

View File

@ -12,6 +12,8 @@ import (
const CameraMoveSpeed = 0.132
type CameraSystem struct {
Weapon *component.Weapon
Position *component.Position
}
func NewCameraSystem() *CameraSystem {
@ -19,18 +21,8 @@ func NewCameraSystem() *CameraSystem {
return s
}
func (_ *CameraSystem) Needs() []gohan.ComponentID {
return []gohan.ComponentID{
component.WeaponComponentID,
component.PositionComponentID,
}
}
func (_ *CameraSystem) Uses() []gohan.ComponentID {
return nil
}
func (s *CameraSystem) Update(ctx *gohan.Context) error {
func (s *CameraSystem) Update(e gohan.Entity) error {
if !world.World.GameStarted || world.World.GameOver {
return nil
}
@ -45,6 +37,6 @@ func (s *CameraSystem) Update(ctx *gohan.Context) error {
return nil
}
func (_ *CameraSystem) Draw(_ *gohan.Context, screen *ebiten.Image) error {
return gohan.ErrSystemWithoutDraw
func (_ *CameraSystem) Draw(_ gohan.Entity, _ *ebiten.Image) error {
return gohan.ErrUnregister
}

View File

@ -3,7 +3,6 @@ package system
import (
"code.rocketnine.space/tslocum/brownboxbatman/asset"
"code.rocketnine.space/tslocum/brownboxbatman/component"
. "code.rocketnine.space/tslocum/brownboxbatman/ecs"
"code.rocketnine.space/tslocum/brownboxbatman/entity"
"code.rocketnine.space/tslocum/brownboxbatman/world"
"code.rocketnine.space/tslocum/gohan"
@ -12,6 +11,11 @@ import (
// pause time, screen X, screen Y
type CreepSystem struct {
Creep *component.Creep
Position *component.Position
Sprite *component.Sprite `gohan:"?"`
Weapon *component.Weapon `gohan:"?"`
}
func NewCreepSystem() *CreepSystem {
@ -19,36 +23,24 @@ func NewCreepSystem() *CreepSystem {
return s
}
func (_ *CreepSystem) Needs() []gohan.ComponentID {
return []gohan.ComponentID{
component.CreepComponentID,
component.PositionComponentID,
}
}
func (_ *CreepSystem) Uses() []gohan.ComponentID {
return []gohan.ComponentID{
component.WeaponComponentID,
}
}
func (s *CreepSystem) Update(ctx *gohan.Context) error {
func (s *CreepSystem) Update(e gohan.Entity) error {
if !world.World.GameStarted {
return nil
}
creep := component.Creep(ctx)
position := component.Position(ctx)
creep := s.Creep
position := s.Position
if creep.Health <= 0 {
for i, e := range world.World.CreepEntities {
if e == ctx.Entity {
for i, ent := range world.World.CreepEntities {
if ent == e {
asset.SoundCreepDie.Rewind()
asset.SoundCreepDie.Play()
world.World.CreepRects = append(world.World.CreepRects[:i], world.World.CreepRects[i+1:]...)
world.World.CreepEntities = append(world.World.CreepEntities[:i], world.World.CreepEntities[i+1:]...)
ctx.RemoveEntity()
e.Remove()
return nil
}
}
@ -105,18 +97,17 @@ func (s *CreepSystem) Update(ctx *gohan.Context) error {
if creep.DamageTicks > 0 {
creep.DamageTicks--
sprite := ECS.Component(ctx.Entity, component.SpriteComponentID)
sprite := s.Sprite
if sprite != nil {
sp := sprite.(*component.SpriteComponent)
if creep.DamageTicks > 0 {
if creep.DamageTicks%2 == 0 {
sp.ColorScale = 100
sprite.ColorScale = 100
} else {
sp.ColorScale = .01
sprite.ColorScale = .01
}
sp.OverrideColorScale = true
sprite.OverrideColorScale = true
} else {
sp.OverrideColorScale = false
sprite.OverrideColorScale = false
}
}
}
@ -124,6 +115,6 @@ func (s *CreepSystem) Update(ctx *gohan.Context) error {
return nil
}
func (_ *CreepSystem) Draw(_ *gohan.Context, screen *ebiten.Image) error {
return gohan.ErrSystemWithoutDraw
func (_ *CreepSystem) Draw(_ gohan.Entity, _ *ebiten.Image) error {
return gohan.ErrUnregister
}

View File

@ -13,32 +13,24 @@ const (
)
type playerFireSystem struct {
Position *component.Position
Velocity *component.Velocity
Weapon *component.Weapon
Sprite *component.Sprite
}
func NewplayerFireSystem() *playerFireSystem {
return &playerFireSystem{}
}
func (_ *playerFireSystem) Needs() []gohan.ComponentID {
return []gohan.ComponentID{
component.PositionComponentID,
component.VelocityComponentID,
component.WeaponComponentID,
component.SpriteComponentID,
}
}
func (_ *playerFireSystem) Uses() []gohan.ComponentID {
return nil
}
func (s *playerFireSystem) Update(ctx *gohan.Context) error {
func (s *playerFireSystem) Update(e gohan.Entity) error {
if !world.World.GameStarted || world.World.GameOver {
return nil
}
position := component.Position(ctx)
weapon := component.Weapon(ctx)
position := s.Position
weapon := s.Weapon
if ebiten.IsKeyPressed(ebiten.KeyZ) || ebiten.IsMouseButtonPressed(ebiten.MouseButtonLeft) {
if weapon.NextFire == 0 {
entity.NewPlayerBullet(position.X-8, position.Y-8, 0, -weapon.BulletSpeed)
@ -52,6 +44,6 @@ func (s *playerFireSystem) Update(ctx *gohan.Context) error {
return nil
}
func (s *playerFireSystem) Draw(_ *gohan.Context, _ *ebiten.Image) error {
return gohan.ErrSystemWithoutDraw
func (s *playerFireSystem) Draw(_ gohan.Entity, _ *ebiten.Image) error {
return gohan.ErrUnregister
}

View File

@ -4,7 +4,6 @@ import (
"os"
"code.rocketnine.space/tslocum/brownboxbatman/asset"
"code.rocketnine.space/tslocum/brownboxbatman/component"
"code.rocketnine.space/tslocum/brownboxbatman/world"
"code.rocketnine.space/tslocum/gohan"
@ -17,6 +16,11 @@ const (
)
type playerMoveSystem struct {
Position *component.Position
Velocity *component.Velocity
Weapon *component.Weapon
Sprite *component.Sprite
player gohan.Entity
movement *MovementSystem
lastWalkDirL bool
@ -32,22 +36,7 @@ func NewPlayerMoveSystem(player gohan.Entity, m *MovementSystem) *playerMoveSyst
}
}
func (_ *playerMoveSystem) Needs() []gohan.ComponentID {
return []gohan.ComponentID{
component.PositionComponentID,
component.VelocityComponentID,
component.WeaponComponentID,
component.SpriteComponentID,
}
}
func (_ *playerMoveSystem) Uses() []gohan.ComponentID {
return nil
}
func (s *playerMoveSystem) Update(ctx *gohan.Context) error {
velocity := component.Velocity(ctx)
func (s *playerMoveSystem) Update(e gohan.Entity) error {
if ebiten.IsKeyPressed(ebiten.KeyEscape) && !world.World.DisableEsc {
os.Exit(0)
return nil
@ -92,37 +81,37 @@ func (s *playerMoveSystem) Update(ctx *gohan.Context) error {
return nil
}
pressLeft := ebiten.IsKeyPressed(ebiten.KeyLeft)
pressRight := ebiten.IsKeyPressed(ebiten.KeyRight)
pressUp := ebiten.IsKeyPressed(ebiten.KeyUp)
pressDown := ebiten.IsKeyPressed(ebiten.KeyDown)
pressLeft := ebiten.IsKeyPressed(ebiten.KeyLeft) || ebiten.IsKeyPressed(ebiten.KeyA)
pressRight := ebiten.IsKeyPressed(ebiten.KeyRight) || ebiten.IsKeyPressed(ebiten.KeyD)
pressUp := ebiten.IsKeyPressed(ebiten.KeyUp) || ebiten.IsKeyPressed(ebiten.KeyW)
pressDown := ebiten.IsKeyPressed(ebiten.KeyDown) || ebiten.IsKeyPressed(ebiten.KeyS)
if (pressLeft && !pressRight) ||
(pressRight && !pressLeft) {
if pressLeft {
velocity.X = -moveSpeed
s.Velocity.X = -moveSpeed
} else {
velocity.X = moveSpeed
s.Velocity.X = moveSpeed
}
} else {
velocity.X = 0
s.Velocity.X = 0
}
if (pressUp && !pressDown) ||
(pressDown && !pressUp) {
if pressUp {
velocity.Y = -moveSpeed
s.Velocity.Y = -moveSpeed
} else {
velocity.Y = moveSpeed
s.Velocity.Y = moveSpeed
}
} else {
velocity.Y = 0
s.Velocity.Y = 0
}
return nil
}
func (s *playerMoveSystem) Draw(_ *gohan.Context, _ *ebiten.Image) error {
return gohan.ErrSystemWithoutDraw
func (s *playerMoveSystem) Draw(_ gohan.Entity, _ *ebiten.Image) error {
return gohan.ErrUnregister
}
func deltaXY(x1, y1, x2, y2 float64) (dx float64, dy float64) {

View File

@ -13,6 +13,8 @@ import (
)
type profileSystem struct {
Weapon *component.Weapon
player gohan.Entity
cpuProfile *os.File
}
@ -23,17 +25,7 @@ func NewProfileSystem(player gohan.Entity) *profileSystem {
}
}
func (s *profileSystem) Needs() []gohan.ComponentID {
return []gohan.ComponentID{
component.WeaponComponentID,
}
}
func (s *profileSystem) Uses() []gohan.ComponentID {
return nil
}
func (s *profileSystem) Update(_ *gohan.Context) error {
func (s *profileSystem) Update(_ gohan.Entity) error {
if ebiten.IsKeyPressed(ebiten.KeyControl) && inpututil.IsKeyJustPressed(ebiten.KeyP) {
if s.cpuProfile == nil {
runtime.SetCPUProfileRate(1000)
@ -63,6 +55,6 @@ func (s *profileSystem) Update(_ *gohan.Context) error {
return nil
}
func (s *profileSystem) Draw(_ *gohan.Context, _ *ebiten.Image) error {
return gohan.ErrSystemWithoutDraw
func (s *profileSystem) Draw(_ gohan.Entity, _ *ebiten.Image) error {
return gohan.ErrUnregister
}

View File

@ -5,7 +5,6 @@ import (
"image/color"
"code.rocketnine.space/tslocum/brownboxbatman/component"
. "code.rocketnine.space/tslocum/brownboxbatman/ecs"
"code.rocketnine.space/tslocum/brownboxbatman/world"
"code.rocketnine.space/tslocum/gohan"
"github.com/hajimehoshi/ebiten/v2"
@ -14,7 +13,15 @@ import (
const rewindThreshold = 1
type MovementSystem struct {
ScreenW, ScreenH float64
Position *component.Position
Velocity *component.Velocity
Creep *component.Creep `gohan:"?"`
CreepBullet *component.CreepBullet `gohan:"?"`
PlayerBullet *component.PlayerBullet `gohan:"?"`
Sprite *component.Sprite `gohan:"?"`
ScreenW, ScreenH float64 `gohan:"-"`
}
func NewMovementSystem() *MovementSystem {
@ -27,17 +34,17 @@ func NewMovementSystem() *MovementSystem {
}
func drawDebugRect(r image.Rectangle, c color.Color, overrideColorScale bool) gohan.Entity {
rectEntity := ECS.NewEntity()
rectEntity := gohan.NewEntity()
rectImg := ebiten.NewImage(r.Dx(), r.Dy())
rectImg.Fill(c)
ECS.AddComponent(rectEntity, &component.PositionComponent{
rectEntity.AddComponent(&component.Position{
X: float64(r.Min.X),
Y: float64(r.Min.Y),
})
ECS.AddComponent(rectEntity, &component.SpriteComponent{
rectEntity.AddComponent(&component.Sprite{
Image: rectImg,
OverrideColorScale: overrideColorScale,
})
@ -45,33 +52,20 @@ func drawDebugRect(r image.Rectangle, c color.Color, overrideColorScale bool) go
return rectEntity
}
func (_ *MovementSystem) Needs() []gohan.ComponentID {
return []gohan.ComponentID{
component.PositionComponentID,
component.VelocityComponentID,
}
}
func (_ *MovementSystem) Uses() []gohan.ComponentID {
return []gohan.ComponentID{
component.WeaponComponentID,
}
}
func (s *MovementSystem) Update(ctx *gohan.Context) error {
func (s *MovementSystem) Update(e gohan.Entity) error {
if !world.World.GameStarted {
return nil
}
if world.World.GameOver && ctx.Entity == world.World.Player {
if world.World.GameOver && e == world.World.Player {
return nil
}
position := component.Position(ctx)
velocity := component.Velocity(ctx)
position := s.Position
velocity := s.Velocity
vx, vy := velocity.X, velocity.Y
if ctx.Entity == world.World.Player && (world.World.NoClip || world.World.Debug != 0) && ebiten.IsKeyPressed(ebiten.KeyShift) {
if e == world.World.Player && (world.World.NoClip || world.World.Debug != 0) && ebiten.IsKeyPressed(ebiten.KeyShift) {
vx, vy = vx*2, vy*2
}
@ -79,7 +73,7 @@ func (s *MovementSystem) Update(ctx *gohan.Context) error {
// Force player to remain within the screen bounds.
// TODO same for bullets
if ctx.Entity == world.World.Player {
if e == world.World.Player {
screenX, screenY := s.levelCoordinatesToScreen(position.X, position.Y)
if screenX < 0 {
diff := screenX / world.World.CamScale
@ -109,9 +103,9 @@ func (s *MovementSystem) Update(ctx *gohan.Context) error {
return nil
}
}
} else if ctx.Entity == world.World.BrokenPieceA || ctx.Entity == world.World.BrokenPieceB {
sprite := ECS.Component(ctx.Entity, component.SpriteComponentID).(*component.SpriteComponent)
if ctx.Entity == world.World.BrokenPieceA {
} else if e == world.World.BrokenPieceA || e == world.World.BrokenPieceB {
sprite := s.Sprite
if e == world.World.BrokenPieceA {
sprite.Angle -= 0.05
} else {
sprite.Angle += 0.05
@ -125,20 +119,19 @@ func (s *MovementSystem) Update(ctx *gohan.Context) error {
bulletSize := 8.0
bulletRect := image.Rect(int(position.X), int(position.Y), int(position.X+bulletSize), int(position.Y+bulletSize))
creepBullet := ECS.Component(ctx.Entity, component.CreepBulletComponentID)
playerBullet := ECS.Component(ctx.Entity, component.PlayerBulletComponentID)
creepBullet := s.CreepBullet
playerBullet := s.PlayerBullet
// Check hazard collisions.
if creepBullet != nil || playerBullet != nil {
var invulnerable bool
if creepBullet != nil {
b := creepBullet.(*component.CreepBulletComponent)
invulnerable = b.Invulnerable
invulnerable = creepBullet.Invulnerable
}
if !invulnerable {
for _, hazardRect := range world.World.HazardRects {
if bulletRect.Overlaps(hazardRect) {
ctx.RemoveEntity()
e.Remove()
return nil
}
}
@ -156,13 +149,20 @@ func (s *MovementSystem) Update(ctx *gohan.Context) error {
}
if playerBullet != nil {
var hitCreep bool
for i, creepRect := range world.World.CreepRects {
if bulletRect.Overlaps(creepRect) {
creep := ECS.Component(world.World.CreepEntities[i], component.CreepComponentID).(*component.CreepComponent)
if creep.Active {
creep.Health--
creep.DamageTicks = 6
ctx.RemoveEntity()
creepEntity := world.World.CreepEntities[i]
creepEntity.With(func(creep *component.Creep) {
if creep.Active {
creep.Health--
creep.DamageTicks = 6
hitCreep = true
}
})
if hitCreep {
e.Remove()
return nil
}
}
@ -176,6 +176,6 @@ func (s *MovementSystem) levelCoordinatesToScreen(x, y float64) (float64, float6
return (x - world.World.CamX) * world.World.CamScale, (y - world.World.CamY) * world.World.CamScale
}
func (_ *MovementSystem) Draw(_ *gohan.Context, screen *ebiten.Image) error {
return gohan.ErrSystemWithoutDraw
func (_ *MovementSystem) Draw(_ gohan.Entity, _ *ebiten.Image) error {
return gohan.ErrUnregister
}

View File

@ -8,6 +8,8 @@ import (
)
type RailSystem struct {
Rail *component.Rail
Position *component.Position
}
func NewRailSystem() *RailSystem {
@ -15,27 +17,16 @@ func NewRailSystem() *RailSystem {
return s
}
func (_ *RailSystem) Needs() []gohan.ComponentID {
return []gohan.ComponentID{
component.RailComponentID,
component.PositionComponentID,
}
}
func (_ *RailSystem) Uses() []gohan.ComponentID {
return nil
}
func (s *RailSystem) Update(ctx *gohan.Context) error {
func (s *RailSystem) Update(e gohan.Entity) error {
if !world.World.GameStarted || world.World.GameOver || !world.World.CamMoving {
return nil
}
position := component.Position(ctx)
position.Y -= CameraMoveSpeed
s.Position.Y -= CameraMoveSpeed
return nil
}
func (_ *RailSystem) Draw(_ *gohan.Context, screen *ebiten.Image) error {
return gohan.ErrSystemWithoutDraw
func (_ *RailSystem) Draw(_ gohan.Entity, _ *ebiten.Image) error {
return gohan.ErrUnregister
}

View File

@ -9,7 +9,6 @@ import (
"code.rocketnine.space/tslocum/brownboxbatman/asset"
"code.rocketnine.space/tslocum/brownboxbatman/component"
. "code.rocketnine.space/tslocum/brownboxbatman/ecs"