[WinAPI] Bullet 속도를 Gauge Bar와 연동
Bullet.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
#pragma once
class Bullet
{
public:
ObLine arrow;
ObCircle arrowPet;
float scalar;
public:
Bullet();
void Update(ObRect player);
void Render();
bool Shoot(ObRect player, float scalar);
};
|
cs |
float scalar 생성
bool Shoot(ObRect player, flaot scalar)
Bullet.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
|
void Bullet::Update(ObRect player)
{
if (!arrow.isVisible) return;
if (!arrowPet.isVisible) return;
arrow.MoveWorldPos(arrow.GetRight() * scalar * DELTA); // scalar 곱함
arrowPet.rotation2 += 360.0f * ToRadian * DELTA;
arrow.Update();
arrowPet.Update();
Vector2 Dis = arrow.GetWorldPos() - player.GetWorldPos();
float dis = Dis.Length();
if (dis > 2000.0f)
{
arrow.isVisible = false;
arrowPet.isVisible = false;
}
}
bool Bullet::Shoot(ObRect player, float scalar)
{
if (!arrow.isVisible)
{
arrow.isVisible = true;
arrowPet.isVisible = true;
arrow.SetWorldPos(player.GetWorldPos());
arrow.rotation = Utility::DirToRadian(player.GetRight());
this->scalar = scalar // float scalar 자기 자신을 받아서 넣어줌
arrowPet.rotation2 = 0.0f;
return true;
}
return false;
}
|
cs |
arrow.MoveWorldPos(arrow.GetRight() * scalar * DELTA);
bool Bullet::Shoot(ObRect player, float scalar)
{ ...
this->scalar = scalar;
...
}
Main.cpp
1
2
3
4
5
|
if (INPUT->KeyDown(VK_SPACE))
{
playerGauge.scale.x = 0.0f;
}
|
cs |
Space Bar를 눌렀다떼면 초기화되게 만들어준다.
https://dev-sbee.tistory.com/15
구형 그래픽카드여서 안 보이면..
Direct3D11.cpp 123줄
D3D_FEATURE_LEVEL_11_1
D3D_FEATURE_LEVEL_11_0 으로 수정
'⭐ DirectX > DirectX11 2D + WinAPI' 카테고리의 다른 글
[WinAPI] 마우스 회전 (0) | 2022.08.09 |
---|---|
[WinAPI] 총알 발사 (0) | 2022.08.08 |
[winAPI] 시계 만들기 (0) | 2022.07.22 |
[WinAPI] 도형 만들기 (0) | 2022.07.07 |
[WinAPI] 좌표 활용 연습 (0) | 2022.07.07 |
댓글
이 글 공유하기
다른 글
-
[WinAPI] 마우스 회전
[WinAPI] 마우스 회전
2022.08.09Input.h 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 #pragma once class Input : public Singleton { friend class Window; private: …. Vector2 mouseScreenPos; //추가 Vector2 mouseWorldPos; //추가 public: Input(); ~Input(); bool KeyDown(int KeyCode); //눌렀을때 최초1회 bool KeyPress(int KeyCode);//누르고있을때 bool KeyUp(int KeyCode); //눌렀다가 떼었을때 최초1회 void Update(); Vector2 GetScreenMousPos() { re… -
[WinAPI] 총알 발사
[WinAPI] 총알 발사
2022.08.08 -
[winAPI] 시계 만들기
[winAPI] 시계 만들기
2022.07.221 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 #pragma once class MainGame : public Scene { public: ObRect rc; ObStar st; ObCircle cc; ObLine hour; ObLine min; ObLine sec; SYSTEMTIME localTime; public: ~MainGame(); void Init() override; void Update() override; void Render() override; }; cs 1 2 3 4 5 6 7 8 9 hour.rotation = -DIV2PI + (float)localTime.wHour * 30.0f * ToRadian + (float)local… -
[WinAPI] 도형 만들기
[WinAPI] 도형 만들기
2022.07.07
댓글을 사용할 수 없습니다.