aboutsummaryrefslogtreecommitdiff
path: root/game/prefab/ZapperObject.cpp
blob: 2791162b97b2c0840c870e6754c50b9d1e51ad60 (plain)
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
#include "Config.h"
#include "ZapperObject.h"
#include "ZapperScript.h"

using namespace crepe;

ZapperObject::ZapperObject(crepe::GameObject && base)
	: GameObject(std::move(base)),
	  sprite {
		  .orb_start = add_component<Sprite>(
			  Asset {"asset/obstacles/zapper/orbAnim.png"},
			  Sprite::Data {
				  .sorting_in_layer = SORT_IN_LAY_OBSTACLES,
					.order_in_layer = 1,
				  .size = vec2{0, 1} * SCALE,
					.position_offset = {0, 100},
			  }
		  ),
		  .orb_end = add_component<Sprite>(
				sprite.orb_start.source,
				Sprite::Data {
					.flip = {true, true},
					.sorting_in_layer = SORT_IN_LAY_OBSTACLES,
					.order_in_layer = 1,
				  .size = vec2{0, 1} * SCALE,
					.position_offset = {0, -100},
				}
		  ),
		  .glow_start = add_component<Sprite>(
			  Asset {"asset/obstacles/zapper/regular_zappers/glow.png"},
			  Sprite::Data {
				  .sorting_in_layer = SORT_IN_LAY_OBSTACLES,
					.order_in_layer = -1,
				  .size = vec2{2, 2} * SCALE,
					.position_offset = {0, 100},
			  }
		  ),
		  .glow_end = add_component<Sprite>(
				sprite.glow_start.source,
				Sprite::Data {
					.flip = {true, true},
					.sorting_in_layer = SORT_IN_LAY_OBSTACLES,
					.order_in_layer = -1,
				  .size = vec2{2, 2} * SCALE,
					.position_offset = {0, -100},
				}
		  ),
			.beam = add_component<Sprite>(
			  Asset {"asset/obstacles/zapper/regular_zappers/zapEffect.png"},
			  Sprite::Data {
				  .sorting_in_layer = SORT_IN_LAY_OBSTACLES,
					.order_in_layer = 0,
				  .size = vec2{200, 50},
					.angle_offset = 90,
			  }
			),
	  },
	  animator {
			.orb_start = add_component<Animator>(
			  sprite.orb_start, ivec2(62, 42), uvec2(4, 1),
			  Animator::Data {
				  .fps = 10,
				  .looping = true,
			  }
			),
			.orb_end = add_component<Animator>(
				sprite.orb_end, ivec2(62, 42), uvec2(4, 1),
				animator.orb_start.data
			),
			.glow_start = add_component<Animator>(
				sprite.glow_start, ivec2(128, 128), uvec2(4, 4),
				Animator::Data {
					.fps = 30,
					.looping = true,
				}
			),
			.glow_end = add_component<Animator>(
				sprite.glow_end, ivec2(128, 128), uvec2(4, 4),
				animator.glow_start.data
			),
	  },
	  controller(add_component<BehaviorScript>().set_script<ZapperScript>(*this))
{ }