From 1ec934514c95b6f013d056341a902fca14bbde2e Mon Sep 17 00:00:00 2001 From: Matt Lee Date: Tue, 20 Aug 2024 22:51:36 -0500 Subject: [PATCH] bullets die after leaving their range (plus buffer) some rebalancing --- README.md | 8 +++++--- components/bullets.go | 6 ++++++ components/creeps.go | 2 +- game/game.go | 2 +- 4 files changed, 13 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 0e51212..b142966 100644 --- a/README.md +++ b/README.md @@ -92,6 +92,8 @@ Graphics and sounds by Matt. Nathan created the Lego builds that were used for t * ~~Add UI for configuring game options (server, client, debug, gridlines)~~ * Choose options for game difficulty * Add input for tower level in game options + * Computer player options + * Sound options * ~~Implement game difficulty~~ * ~~Set other options~~ * ~~debug, range circles, etc~~ @@ -104,7 +106,7 @@ Graphics and sounds by Matt. Nathan created the Lego builds that were used for t * Bullets slow creeps * ~~Refresh tower health for % of initial cost~~ * Let mouse clicks heal and upgrade towers, right click or double click -* Bullets expire after traveling range + X +* ~~Bullets expire after traveling range + X~~ * Special bullets could create spots on the ground that will slow, damage, or annoy creeps * Levels * ~~More powerful creeps~~ @@ -132,13 +134,13 @@ Graphics and sounds by Matt. Nathan created the Lego builds that were used for t * ~~Scores~~ * ~~save high scores~~ * Stretch - * Computer players + * ~~Computer players~~ + * Additional strategies * ~~Networking players, possibly using [leap-fish/necs](https://github.com/leap-fish/necs)~~ * ~~Send extra creeps to other player~~ * Pick different types of creep to send * Simulation for testing * Play simulated network opponent - * Investigate donburi systems and events ## Remote viewer diff --git a/components/bullets.go b/components/bullets.go index 5df1161..18933ab 100644 --- a/components/bullets.go +++ b/components/bullets.go @@ -69,6 +69,12 @@ func (brd *BulletRenderData) GetColor() color.Color { func (bd *BulletData) Update(entry *donburi.Entry) error { pos := Position.Get(entry) dist := util.DistancePoints(bd.start, bd.end) + // if the bullet has traveled past its range (plus a little buffer), remove it + // TODO add special bullets that do something when they expire (like a slow-down effect) + if util.DistancePoints(bd.start, image.Pt(pos.X, pos.Y)) > dist*3/2 { + entry.Remove() + return nil + } ratio := dist / float64(bd.speed) // fmt.Printf("dist: %v, ratio: %v, start: %v, end: %v\n", dist, ratio, bd.start, bd.end) diff --git a/components/creeps.go b/components/creeps.go index 7f29073..9fa0505 100644 --- a/components/creeps.go +++ b/components/creeps.go @@ -38,7 +38,7 @@ func NewCreep(world donburi.World, x, y, creepLevel int) (*donburi.Entry, error) Velocity.Set(creep, &VelocityData{X: 0, Y: 5 - augment + creepLevel/2}) name := fmt.Sprintf("creep%v", choose) Creep.Set(creep, &CreepData{scoreValue: 10 * augment}) - Health.Set(creep, NewHealthData(1+2*augment+creepLevel/2)) + Health.Set(creep, NewHealthData(1+2*augment+creepLevel/3)) Attack.Set(creep, &AttackData{Power: 1 + (creepLevel-1)*augment/4, AttackType: RangedSingle, Range: 10 + 10*augment, cooldown: util.NewCooldownTimer(5 + 5*augment)}) SpriteRender.Set(creep, &SpriteRenderData{Name: name}) RangeRender.Set(creep, &RangeRenderData{}) diff --git a/game/game.go b/game/game.go index 3598105..ba13c6c 100644 --- a/game/game.go +++ b/game/game.go @@ -181,7 +181,7 @@ func ensureDir(dirName string) error { } func (g *GameData) Update() error { - // TODO move this into the title scene so we can determin if the config has focus + // TODO move this into the title scene so we can determine if the config has focus if !scenes.IsModalOpen() && inpututil.IsKeyJustPressed(ebiten.KeyQ) { if err := g.SaveScores(); err != nil { return err