-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtreasure.go
53 lines (45 loc) · 1010 Bytes
/
treasure.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
package main
import (
"log"
"github.com/hajimehoshi/ebiten/v2"
)
var (
shinyGreenBall *ebiten.Image
portalGem *ebiten.Image
treasureTypeList map[int]*TreasureType
treasureList []*Treasure
)
func initializeTreasures() {
treasureTypeList = map[int]*TreasureType{
3: {"Portal Gem", portalGem, 50, 50, 0, 0, 5},
4: {"Shiny Green Ball", shinyGreenBall, 40, 40, 10, 0, 7},
}
}
// TreasureType holds general description for a specific type of treasure
type TreasureType struct {
name string
sprite *ebiten.Image
width int
height int
value int
frame int
frameCt int
}
// Treasure describes a specific treasure object in a level
type Treasure struct {
*TreasureType
xCoord int
yCoord int
collected bool
}
// NewTreasure creates a new Treasure object at specific coordinates in a level
func NewTreasure(id int, x int, y int) *Treasure {
log.Printf("Creating new treasure")
treasure := &Treasure{
treasureTypeList[id],
x,
y,
false,
}
return treasure
}