-
Notifications
You must be signed in to change notification settings - Fork 0
/
game_mode_draw.go
100 lines (84 loc) · 2.57 KB
/
game_mode_draw.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
package main
import (
"fmt"
"image"
"image/color"
"github.com/hajimehoshi/ebiten/v2"
"github.com/hajimehoshi/ebiten/v2/ebitenutil"
"github.com/hajimehoshi/ebiten/v2/text"
)
func (g *Game) GameModeDraw(screen *ebiten.Image) {
if showDebug {
ebitenutil.DebugPrint(screen, fmt.Sprintf("\n\n\n\n\nFPS: %v\nBullets: %v\nEnemies: %v\n%v", ebiten.ActualFPS(), len(g.EHBullets), len(g.Enemies), g.Diff))
}
for _, bullet := range g.PBullets {
op := &ebiten.DrawImageOptions{}
op.GeoM.Translate(bullet.X, bullet.Y)
screen.DrawImage(PlayerBulletImage, op)
}
// draw player
playerOp := &ebiten.DrawImageOptions{}
playerOp.GeoM.Translate(g.Player.X, g.Player.Y)
screen.DrawImage(g.Player.GetSprite(), playerOp)
// draw enemies
enemyOp := &ebiten.DrawImageOptions{}
for _, enemy := range g.Enemies {
if enemy.Hit {
enemyOp.ColorScale.SetB(255)
enemyOp.ColorScale.SetG(100)
}
enemyOp.GeoM.Translate(enemy.X, enemy.Y)
screen.DrawImage(enemy.GetSprite(), enemyOp)
enemyOp.ColorScale.Reset()
enemyOp.GeoM.Reset()
}
// Death Walls warnings
if g.ShowDWWL {
screen.DrawImage(DWWLImage, nil)
}
if g.ShowDWWR {
DWWROp := &ebiten.DrawImageOptions{}
DWWROp.GeoM.Translate(1200, 0)
screen.DrawImage(DWWRImage, DWWROp)
}
// End Death Walls warnings
// Death Walls ☠️
if g.DWL.Active {
dwlOp := &ebiten.DrawImageOptions{}
dwlOp.GeoM.Translate(g.DWL.X, 0)
screen.DrawImage(g.DWL.Image, dwlOp)
}
if g.DWR.Active {
dwrOp := &ebiten.DrawImageOptions{}
dwrOp.GeoM.Translate(g.DWR.X, 0)
screen.DrawImage(g.DWR.Image, dwrOp)
}
// End Death Walls
// Drawing arcshot
arcshotOP := &ebiten.DrawImageOptions{}
arcshotOP.GeoM.Translate(g.Arcshot.X, g.Arcshot.Y+100)
switch g.Arcshot.State {
case "idle":
screen.DrawImage(ArcshotSheet.SubImage(image.Rect(0, 0, 150, 200)).(*ebiten.Image), arcshotOP)
case "firing":
screen.DrawImage(ArcshotSheet.SubImage(image.Rect(150, 0, 300, 200)).(*ebiten.Image), arcshotOP)
}
// End Arcshot
// Enemy Homming bullets
for _, bullet := range g.EHBullets {
bulletOp := &ebiten.DrawImageOptions{}
bulletOp.GeoM.Translate(bullet.X, bullet.Y)
if bullet.Size == 30 {
screen.DrawImage(EnemyBullet30Image, bulletOp)
} else {
screen.DrawImage(EnemyBullet50Image, bulletOp)
}
}
// End Enemy Homming bullets
// Score 🏆
text.Draw(screen, fmt.Sprintf("Score: %v", g.Score), MyEpicGamerFont, 15, 40, color.White)
levelOp := &ebiten.DrawImageOptions{}
levelOp.GeoM.Scale(0.7, 0.7)
levelOp.GeoM.Translate(10, SCREENHEIGHT-15)
text.DrawWithOptions(screen, fmt.Sprintf("Lvl: %v", g.Diff.Level), MyEpicGamerFont, levelOp)
}