Skip to content

Commit

Permalink
bullets die after leaving their range (plus buffer)
Browse files Browse the repository at this point in the history
some rebalancing
  • Loading branch information
Warsinger committed Aug 21, 2024
1 parent 1189a4e commit 1ec9345
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 5 deletions.
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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~~
Expand All @@ -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~~
Expand Down Expand Up @@ -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

Expand Down
6 changes: 6 additions & 0 deletions components/bullets.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion components/creeps.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{})
Expand Down
2 changes: 1 addition & 1 deletion game/game.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 1ec9345

Please sign in to comment.