OSDN Git Service

最初のコミット
[shooting3/shootinggame.git] / ShootingGame / SimpleSprites.h
1 //// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
2 //// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
3 //// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
4 //// PARTICULAR PURPOSE.
5 ////
6 //// Copyright (c) Microsoft Corporation. All rights reserved
7
8 #pragma once
9
10 #include "DirectXBase.h"
11 #include "SampleOverlay.h"
12 #include "AutoThrottle.h"
13 #include "BasicSprites.h"
14
15 namespace SampleSettings
16 {
17     static const unsigned int NumAsteroids = 50;
18     namespace Performance
19     {
20         static const float TargetFrameTime = 1.0f / 20.0f;
21         static const unsigned int InitialParticleCount = 5000;
22         static const unsigned int ParticleCountDelta = 32;
23         static const unsigned int ParticleCountMin = 1000;
24         static const unsigned int ParticleCountMax = 60000;
25     }
26     namespace Physics
27     {
28         static const float Gravity = 40000000.0f;
29         static const float Damping = 0.015f;
30     }
31 }
32
33 struct AsteroidData
34 {
35     float2 pos;
36     float2 vel;
37     float rot;
38     float rotVel;
39     float scale;
40 };
41
42 struct ParticleData
43 {
44     float2 pos;
45     float2 vel;
46 };
47
48 ref class SimpleSprites : public DirectXBase
49 {
50 public:
51     SimpleSprites();
52     virtual void CreateDeviceIndependentResources() override;
53     virtual void CreateDeviceResources() override;
54     virtual void CreateWindowSizeDependentResources() override;
55     virtual void Render() override;
56     void Initialize(
57         _In_ Windows::UI::Core::CoreWindow^ window,
58         _In_ Windows::UI::Xaml::Controls::SwapChainBackgroundPanel^ swapChainPanel,
59         _In_ float dpi
60         ) new;
61     void Update(float timeTotal, float timeDelta);
62     void AddRepulsor(_In_ uint32 id, _In_ float2 position);
63     void MoveRepulsor(_In_ uint32 id, _In_ float2 position);
64     void RemoveRepulsor(_In_ uint32 id);
65
66 private:
67     float RandFloat(float min, float max);
68     SampleOverlay^ m_sampleOverlay;
69     AutoThrottle^ m_autoThrottle;
70     BasicSprites::SpriteBatch^ m_spriteBatch;
71     Microsoft::WRL::ComPtr<ID3D11Texture2D> m_background;
72     Microsoft::WRL::ComPtr<ID3D11Texture2D> m_asteroid;
73     Microsoft::WRL::ComPtr<ID3D11Texture2D> m_particle;
74     std::vector<AsteroidData> m_asteroidData;
75     std::vector<ParticleData> m_particleData;
76     std::map<uint32, float2> m_repulsors;
77     int m_numParticlesToDraw;
78         Windows::UI::Xaml::Controls::SwapChainBackgroundPanel^ panel_;
79 };