-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathenvironment.go
84 lines (74 loc) · 1.66 KB
/
environment.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
package main
import (
"log"
"github.com/hajimehoshi/ebiten/v2"
)
const (
blockHW = 50
portalWidth = 100
portalHeight = 150
)
var (
brick *ebiten.Image
hazard *ebiten.Image
portal *ebiten.Image
)
var (
hazardFrame = 2
hazardFrameCount = 10
portalFrame = 2
portalFrameCount = 5
enviroList []*Brick
hazardList []*Hazard
)
// Brick describes a specific environment object
type Brick struct {
name string
sprite *ebiten.Image
xCoord int
yCoord int
impenetrable bool // can you walk through it
supportive bool // can you land on it
destructible bool // can you destroy it
//lethal bool // will it kill you on contact
damage int // amount of damage per encounter -- if lethal, set absurdly high
}
// NewBrick creates a new Brick within a level
func NewBrick(name string, sprite *ebiten.Image, x int, y int) *Brick {
log.Printf("Creating new brick")
brick := &Brick{
name: name,
sprite: sprite,
xCoord: x,
yCoord: y,
impenetrable: true,
supportive: true,
destructible: false,
damage: 0,
}
return brick
}
// Hazard describes a specific hazardous object
type Hazard struct {
name string
sprite *ebiten.Image
frameCurr int
frameTotal int
xCoord int
yCoord int
damage int
}
// NewHazard creates a new Hazard within a level
func NewHazard(name string, sprite *ebiten.Image, frames int, x int, y int, damage int) *Hazard {
log.Printf("Creating new hazard")
hazard := &Hazard{
name: name,
sprite: sprite,
frameCurr: defaultFrame,
frameTotal: frames,
xCoord: x,
yCoord: y,
damage: damage,
}
return hazard
}