-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathobjects.go
68 lines (60 loc) · 3.29 KB
/
objects.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
package main
import rl "github.com/gen2brain/raylib-go/raylib"
type Object struct {
Position rl.Vector2
Texture *rl.Texture2D
}
type PreObject struct {
Texture rl.Texture2D
CollisionRect []CollisionRect
}
const (
OBJECT_CONTAINER_RED = iota
OBJECT_CONTAINER_GREEN
OBJECT_CONTAINER_BLUE
OBJECT_CONTAINER_YELLOW
OBJECT_CARDBOARD_BOX
OBJECT_PALLETS
OBJECT_METAL_PIPE
OBJECT_METAL_SUPPORT
OBJECT_METAL_SUPPORT_HORIZONTAL
OBJECT_BRICK
OBJECT_BOLT
OBJECT_TOILET
OBJECT_SCAFFOLDING
OBJECT_SCAFFOLDING_HOLE
OBJECT_SCAFFOLDING_LADDER_LEFT
OBJECT_SCAFFOLDING_LADDER_RIGHT
OBJECT_SHIP
)
var pre_objects = []PreObject{
{rl.Texture2D{}, []CollisionRect{{rl.Rectangle{X: 0, Y: 0, Width: 250, Height: 100}, true}}},
{rl.Texture2D{}, []CollisionRect{{rl.Rectangle{X: 0, Y: 0, Width: 250, Height: 100}, true}}},
{rl.Texture2D{}, []CollisionRect{{rl.Rectangle{X: 0, Y: 0, Width: 250, Height: 100}, true}}},
{rl.Texture2D{}, []CollisionRect{{rl.Rectangle{X: 0, Y: 0, Width: 250, Height: 100}, true}}},
{rl.Texture2D{}, []CollisionRect{{rl.Rectangle{X: 0, Y: 0, Width: 25, Height: 25}, true}}},
{rl.Texture2D{}, []CollisionRect{{rl.Rectangle{X: 0, Y: 0, Width: 50, Height: 10}, false}}},
{rl.Texture2D{}, []CollisionRect{{rl.Rectangle{X: 0, Y: 0, Width: 200, Height: 50}, true}}},
{rl.Texture2D{}, []CollisionRect{{rl.Rectangle{X: 0, Y: 0, Width: 20, Height: 150}, true}}},
{rl.Texture2D{}, []CollisionRect{{rl.Rectangle{X: 0, Y: 0, Width: 150, Height: 20}, true}}},
{rl.Texture2D{}, []CollisionRect{{rl.Rectangle{X: 0, Y: 0, Width: 20, Height: 10}, true}}},
{rl.Texture2D{}, []CollisionRect{{rl.Rectangle{X: 0, Y: 0, Width: 4, Height: 9}, false}}},
{rl.Texture2D{}, []CollisionRect{{rl.Rectangle{X: 0, Y: 2, Width: 20, Height: 28}, false}}},
{rl.Texture2D{}, []CollisionRect{{rl.Rectangle{X: 0, Y: 0, Width: 100, Height: 3}, false}}},
{rl.Texture2D{}, []CollisionRect{{rl.Rectangle{X: 0, Y: 0, Width: 20, Height: 3}, false}, {rl.Rectangle{X: 48, Y: 0, Width: 52, Height: 3}, false}}},
{rl.Texture2D{}, []CollisionRect{{rl.Rectangle{X: 0, Y: 0, Width: 20, Height: 3}, false}, {rl.Rectangle{X: 48, Y: 0, Width: 52, Height: 3}, false}, {rl.Rectangle{X: 19, Y: 0, Width: 4, Height: 45}, true}}},
{rl.Texture2D{}, []CollisionRect{{rl.Rectangle{X: 0, Y: 0, Width: 52, Height: 3}, false}, {rl.Rectangle{X: 77, Y: 0, Width: 23, Height: 3}, false}, {rl.Rectangle{X: 77, Y: 0, Width: 4, Height: 45}, true}}},
{rl.Texture2D{}, []CollisionRect{{rl.Rectangle{X: 0, Y: 250, Width: 1300, Height: 100}, true}, {rl.Rectangle{X: 20, Y: 350, Width: 1260, Height: 100}, false}, {rl.Rectangle{X: 1052, Y: 0, Width: 200, Height: 250}, true}}},
}
func NewObject(x, y float32, obj uint, collision_rects *[]CollisionRect) Object {
for i := 0; i < len(pre_objects[obj].CollisionRect); i++ {
*collision_rects = append(*collision_rects, NewCollisionRect(x+pre_objects[obj].CollisionRect[i].Rect.X, -y+pre_objects[obj].CollisionRect[i].Rect.Y, pre_objects[obj].CollisionRect[i].Rect.Width, pre_objects[obj].CollisionRect[i].Rect.Height, pre_objects[obj].CollisionRect[i].Climbable))
}
return Object{
Position: rl.NewVector2(x, -y),
Texture: &pre_objects[obj].Texture,
}
}
func (o *Object) Draw() {
rl.DrawTexture(*o.Texture, int32(o.Position.X), int32(o.Position.Y), rl.White)
}