Skip to content

Commit

Permalink
return blue bug name
Browse files Browse the repository at this point in the history
  • Loading branch information
pankona committed Jun 26, 2024
1 parent 0c7167f commit c092e5a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
11 changes: 10 additions & 1 deletion bugs.go
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,16 @@ func greenBugUpdate(b *bug) {
}

func (b *bug) Name() string {
return b.name
switch b.selfColor {
case bugsRed:
return "Red bug"
case bugsBlue:
return "Blue bug"
case bugsGreen:
return "Green bug"
}
log.Fatal("invalid bug color")
return ""
}

func (b *bug) Position() (int, int) {
Expand Down
11 changes: 6 additions & 5 deletions wavectl.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,12 @@ func generateSpawnInfos(num int) []spawnInfo {
y = rand.Intn(screenHeight)
}

infos = append(infos, spawnInfo{
color: bugsBlue,
x: x,
y: y,
})
// 赤虫:青虫 = 4:6 で生成する
if rand.Intn(10) < 4 {
infos = append(infos, spawnInfo{bugsRed, x, y})
} else {
infos = append(infos, spawnInfo{bugsBlue, x, y})
}
}

return infos
Expand Down

0 comments on commit c092e5a

Please sign in to comment.