forked from ThomasGrell/Software-Projekt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtiles-test.go
116 lines (103 loc) · 2.45 KB
/
tiles-test.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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
package main
import (
"./animations"
. "./constants"
"./tiles"
"github.com/faiface/pixel"
"github.com/faiface/pixel/pixelgl"
"./characters"
"golang.org/x/image/colornames"
"fmt"
"time"
)
func sun() {
wincfg := pixelgl.WindowConfig{
Title: "GameStat Test",
Bounds: pixel.R(-100,-100, 400, 400),
VSync: true,
}
win, err := pixelgl.NewWindow(wincfg)
if err != nil {
panic(err)
}
mod := 1
win.SetMatrix(pixel.IM)//.Scaled(pixel.V(0, 0), 3))
win.Clear(colornames.Blue)
win.Update()
wB := characters.NewPlayer(WhiteBomberman)
itemBatch := pixel.NewBatch(&pixel.TrianglesData{}, animations.ItemImage)
var ti []tiles.Tile
var it []tiles.Item
var bs []tiles.Bombe
i:= tiles.NewItem(SkullItem,pixel.V(0, 0))
fmt.Println(i.GetType())
for !win.Closed() && !win.Pressed(pixelgl.KeyEscape) {
itemBatch.Clear()
if mod%2==0 {
for _,w := range ti {
w.SetVisible(true)
}
for _,w := range it {
w.SetVisible(false)
w.SetDestroyable(false)
w.SetTimeStamp(time.Now())
}
} else {
for _,w := range ti {
w.SetVisible(false)
}
for _,w := range it {
w.SetVisible(true)
w.SetDestroyable(true)
}
}
if win.JustPressed(pixelgl.MouseButton1){ // Move Tile
t:= tiles.NewTile(House,win.MousePosition())
ti = append(ti,t)
fmt.Println("Zeichenmatrix: ",t.GetMatrix())
fmt.Println("Position: ",t.GetPos())
fmt.Println("Ist sichtbar: ",t.IsVisible())
fmt.Println(t.GetType())
mod++
} else if win.JustPressed(pixelgl.MouseButton2){ // Move Item
i:=tiles.NewItem(SkullItem,win.MousePosition())//.Scaled(1/3))
it = append(it,i)
mod++
}
if win.JustPressed(pixelgl.KeySpace) { // stats
for _,w := range ti {
fmt.Println("Tile Animation sichtbar? ",w.IsVisible())
}
for _,w := range it {
fmt.Println("Item Animation sichtbar? ",w.IsVisible())
fmt.Println("Item zerstörbar? ",w.IsDestroyable())
fmt.Println("Item TimeStamp: ",w.GetTimeStamp())
}
for _,w:=range bs {
fmt.Println("Bombenpower: ",w.GetPower())
bb,cc := w.Owner()
fmt.Println("Bombenpower: ",bb,cc)
}
}
if win.JustPressed(pixelgl.KeyB) {
b:= tiles.NewBomb(wB,win.MousePosition())
b.SetPower(1)
bs = append(bs,b)
}
for _,w:=range ti {
w.Draw(itemBatch)
}
for _,w:=range it {
w.Draw(itemBatch)
}
for _,w:=range bs {
w.Draw(itemBatch)
}
//win.Clear(colornames.Blue)
itemBatch.Draw(win)
win.Update()
}
}
func main (){
pixelgl.Run(sun)
}