-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRandomItem.cpp
72 lines (59 loc) · 1.48 KB
/
RandomItem.cpp
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
#include "Header.h"
void RandomItem::OnCollisionBoundary()
{
int RandomRotate = rand() % 15 + 1;
tarRotate += (float)RandomRotate;
}
RandomItem::RandomItem()
{
sprite.LoadAll(TEXT("Assets/item/randomitem"));
moveSpeed = 100.0f;
//tarRotate = rand() % 360 + 1;
layer = 1;
}
void RandomItem::FixedUpdate(float _fixedDeltaTime)
{
sprite.Update(_fixedDeltaTime);
auto scene = static_cast<GameScene*>(SceneManager::GetInstance().GetActiveScene());
auto cpps = scene->pMap->GetPixelState({ pos.x, -pos.y });
float deltaRotate = (tarRotate - curRotate) * _fixedDeltaTime * 10.0f;
curRotate += deltaRotate;
moveDirection = MathUtility::DegreeToVector2(curRotate);
spriteRI.rotate = curRotate;
//Item::FixedUpdate(_fixedDeltaTime);
if (cpps == Map::PixelState::OPEN)
{
scene->pPlayer->curItem = rand() % 4 + 1;
switch (scene->pPlayer->curItem)
{
case 1:
scene->pPlayer->ItemSpritePlayTime = 180.0f;
scene->pPlayer->IsDefense = true;
scene->pPlayer->i_frame = 1.0f;
break;
case 2:
scene->pPlayer->ItemSpritePlayTime = 1.0f;
if (playerInfo.GetInstance().hp >= 5)
{
playerInfo.GetInstance().score += 15000;
}
else
{
playerInfo.GetInstance().hp++;
}
break;
case 3:
scene->pPlayer->curItem = 3;
scene->pPlayer->moveSpeed = 370.0f;
scene->pPlayer->ItemSpritePlayTime = 180.0f;
break;
case 4:
scene->pPlayer->i_frame = 4.0f;
scene->pPlayer->ItemSpritePlayTime = 4.0f;
break;
}
OnDead();
destroy = true;
return;
}
}