Skip to content

Commit 029891f

Browse files
authored
Merge pull request #34 from lr8soft/dev-y
v0.36release
2 parents 1c60a86 + c10be8f commit 029891f

36 files changed

+724
-56
lines changed

.idea/workspace.xml

+8-6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

PythonSTG/PythonSTG.vcxproj

+4
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@
153153
<ClCompile Include="XCCore\Boss\SpellCard.cpp" />
154154
<ClCompile Include="XCCore\Bullet\BulletHelper.cpp" />
155155
<ClCompile Include="XCCore\Bullet\CircleTypeBullet.cpp" />
156+
<ClCompile Include="XCCore\Bullet\LaserTypeBullet.cpp" />
156157
<ClCompile Include="XCCore\Bullet\OvalTypeBullet.cpp" />
157158
<ClCompile Include="XCCore\Bullet\RectangleTypeBullet.cpp" />
158159
<ClCompile Include="XCCore\Enemy\EnemyObject.cpp" />
@@ -175,6 +176,7 @@
175176
<ClCompile Include="XCCore\XCRender\RenderManager.cpp" />
176177
<ClCompile Include="XCCore\XCRender\ParticleHelper.cpp" />
177178
<ClCompile Include="XCCore\XCRender\SpecialEffect\XCParticle.cpp" />
179+
<ClCompile Include="XCCore\XCRender\XCFlexibleImageHelper.cpp" />
178180
<ClCompile Include="XCCore\XCRender\XCFont.cpp" />
179181
<ClCompile Include="XCCore\Player\Player.cpp" />
180182
<ClCompile Include="XCCore\XCRender\SpecialEffect\DecisionPointSE.cpp" />
@@ -200,6 +202,7 @@
200202
<ClInclude Include="XCCore\Boss\BossHelper.h" />
201203
<ClInclude Include="XCCore\Boss\BossObject.h" />
202204
<ClInclude Include="XCCore\Boss\SpellCard.h" />
205+
<ClInclude Include="XCCore\Bullet\LaserTypeBullet.h" />
203206
<ClInclude Include="XCCore\Bullet\OvalTypeBullet.h" />
204207
<ClInclude Include="XCCore\Item\Item.h" />
205208
<ClInclude Include="XCCore\Item\ItemHelper.h" />
@@ -240,6 +243,7 @@
240243
<ClInclude Include="XCCore\XCRender\ParticleHelper.h" />
241244
<ClInclude Include="XCCore\XCRender\AbsorbParticleHelper.h" />
242245
<ClInclude Include="XCCore\XCRender\SpecialEffect\XCParticle.h" />
246+
<ClInclude Include="XCCore\XCRender\XCFlexibleImageHelper.h" />
243247
<ClInclude Include="XCCore\XCRender\XCFont.h" />
244248
<ClInclude Include="XCCore\Player\Player.h" />
245249
<ClInclude Include="XCCore\XCRender\BlendHelper.h" />

PythonSTG/PythonSTG.vcxproj.filters

+12
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,12 @@
220220
<ClCompile Include="XCInterpreter\ImageParseHelper.cpp">
221221
<Filter>XCInterpreter</Filter>
222222
</ClCompile>
223+
<ClCompile Include="XCCore\Bullet\LaserTypeBullet.cpp">
224+
<Filter>XCCore\Bullet</Filter>
225+
</ClCompile>
226+
<ClCompile Include="XCCore\XCRender\XCFlexibleImageHelper.cpp">
227+
<Filter>XCCore\XCRender</Filter>
228+
</ClCompile>
223229
</ItemGroup>
224230
<ItemGroup>
225231
<ClInclude Include="util\ConfigManager.h">
@@ -408,6 +414,12 @@
408414
<ClInclude Include="XCInterpreter\ImageParseHelper.h">
409415
<Filter>XCInterpreter</Filter>
410416
</ClInclude>
417+
<ClInclude Include="XCCore\Bullet\LaserTypeBullet.h">
418+
<Filter>XCCore\Bullet</Filter>
419+
</ClInclude>
420+
<ClInclude Include="XCCore\XCRender\XCFlexibleImageHelper.h">
421+
<Filter>XCCore\XCRender</Filter>
422+
</ClInclude>
411423
</ItemGroup>
412424
<ItemGroup>
413425
<Image Include="..\pystg.ico">

PythonSTG/XCCore/Bullet/BulletHelper.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#include "CircleTypeBullet.h"
33
#include "OvalTypeBullet.h"
44
#include "RectangleTypeBullet.h"
5+
#include "LaserTypeBullet.h"
56
#include "../../XCInterpreter/ScriptLoader.h"
67
#include "../../XCInterpreter/ImageParseHelper.h"
78
Bullet * BulletHelper::getNewBulletObject(std::string bulletImage,std::string bulletType, glm::vec4 divideInfo, glm::vec3 scaleInfo, glm::vec3 collideSize,
@@ -21,6 +22,10 @@ Bullet * BulletHelper::getNewBulletObject(std::string bulletImage,std::string bu
2122
bullet = new RectangleTypeBullet(bulletImage, divideInfo, scaleInfo, collideSize, initCoord, velocity, acceleration, angle, increateAngle, reboundTime, aimPlayer,
2223
particleDensity, particleFinishTime, particleVelocity, particleSize, particleColor);
2324
}
25+
else if (bulletType == "laserTypeBullet") {
26+
bullet = new LaserTypeBullet(bulletImage, divideInfo, scaleInfo, collideSize, initCoord, velocity, acceleration, angle, increateAngle, reboundTime, aimPlayer,
27+
particleDensity, particleFinishTime, particleVelocity, particleSize, particleColor);
28+
}
2429
return bullet;
2530
}
2631

+115
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
#include "LaserTypeBullet.h"
2+
#include "../../XCFrameInfo.h"
3+
#include "../XCCollide/CollideInfo.h"
4+
#include "../XCRender/ParticleHelper.h"
5+
#include "../XCRender/RenderManager.h"
6+
#include <glm/glm.hpp>
7+
#include <glm/gtc/matrix_transform.hpp>
8+
#include <glm/gtc/type_ptr.hpp>
9+
#include <GL3/gl3w.h>
10+
#include <iostream>
11+
LaserTypeBullet::LaserTypeBullet(std::string bulletImagePath, glm::vec4 dInfo, glm::vec3 sInfo, glm::vec3 cSize, glm::vec3 initCoord,
12+
float v, float a, float agl, float incA, int rbTime, bool ap,
13+
int pDensity, float pFinishTime, float pVelocity, float pSize, glm::vec4 pColor)
14+
{
15+
//init part
16+
imagePath = bulletImagePath;
17+
divideInfo = dInfo;
18+
scaleInfo = sInfo;
19+
collideSize = cSize;
20+
NowPosition[0] = initCoord[0];
21+
NowPosition[1] = initCoord[1];
22+
NowPosition[2] = initCoord[2];
23+
//work part
24+
velocity = v;
25+
acceleration = a;
26+
angle = agl;
27+
increaseAngle = incA;
28+
reBoundTime = rbTime;
29+
aimToPlayer = ap;
30+
//release part
31+
particleDensity = pDensity;
32+
particleFinishTime = pFinishTime;
33+
particleVelocity = pVelocity;
34+
particleSize = pSize;
35+
particleColor = pColor;
36+
37+
//define current type
38+
setCurrentType(BulletType);
39+
40+
}
41+
42+
void LaserTypeBullet::Init()
43+
{
44+
if (!isInit) {
45+
image = new XCImageHelper(imagePath, true);
46+
47+
isInit = true;
48+
}
49+
}
50+
51+
void LaserTypeBullet::Render()
52+
{
53+
if (isInit) {
54+
timer.Tick();
55+
auto pPlayerHelper1 = CollideInfo::getCollideHelper();
56+
float* playerPos = (pPlayerHelper1 == nullptr ? nullptr : pPlayerHelper1->getPlayerPosition());
57+
Bullet::solveBulletMovement(aimToPlayer, playerPos, velocity, angle, acceleration, increaseAngle, timer.getDeltaFrame());
58+
59+
60+
glEnable(GL_BLEND);
61+
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
62+
image->Render(glm::vec3(NowPosition[0], NowPosition[1], NowPosition[2]), glm::vec4(1.0f), glm::radians(angle), glm::vec3(0, 0, 1),
63+
scaleInfo * glm::vec3(XCFrameInfo::FrameRight, XCFrameInfo::FrameTop, 1.0f),
64+
IRenderHelper::GetSpecificTexture(divideInfo[0], divideInfo[1], divideInfo[2], divideInfo[3]));
65+
glDisable(GL_BLEND);
66+
if (Bullet::checkReboundOrOverflow(&reBoundTime, &angle, scaleInfo[0], scaleInfo[1])) {//超出边界不渲染结束特效
67+
isWorkFinish = true;
68+
}
69+
}
70+
}
71+
72+
void LaserTypeBullet::setBulletTerminate()
73+
{
74+
75+
ParticleHelper* particleGroup = new ParticleHelper;
76+
particleGroup->addNewParticle(particleDensity, particleSize, particleVelocity, particleFinishTime, particleColor,
77+
glm::vec3(NowPosition[0], NowPosition[1], NowPosition[2]));
78+
RenderManager::getInstance()->AddRenderObject(ParticleGroupUuid, particleGroup);
79+
isWorkFinish = true;
80+
}
81+
void LaserTypeBullet::Release()
82+
{
83+
if (isInit) {
84+
image->Release();
85+
delete image;
86+
87+
image = nullptr;
88+
isInit = false;
89+
}
90+
}
91+
92+
bool LaserTypeBullet::BulletCollideWithPoint(float x, float y, bool &haveGraze)
93+
{
94+
bool value = false;
95+
if (isInit && timer.getAccumlateTime() >= 0.2f) {
96+
x -= NowPosition[0];
97+
y -= NowPosition[1];
98+
99+
float theta = glm::radians(angle);
100+
float NewX = x * cos(theta) + y * sin(theta);
101+
float NewY = -x * sin(theta) + y * cos(theta);
102+
103+
float distance = pow(NewX, 2) + pow(NewY, 2);
104+
float ovalParameter = pow(NewX, 2) / pow(collideSize.x, 2) + pow(NewY, 2) / pow(collideSize.y, 2);
105+
106+
if (!haveCheckGraze && distance <= CollideInfo::getGrazeDistance()) {
107+
haveGraze = true;
108+
haveCheckGraze = true;
109+
}
110+
value = (ovalParameter < 1.0f);
111+
}
112+
113+
return value;
114+
}
115+
+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
#pragma once
2+
#ifndef _LASER_TYPE_BULLET_H_
3+
#define _LASER_TYPE_BULLET_H_
4+
#include "Bullet.h"
5+
#include <glm/glm.hpp>
6+
#include "../../util/GameTimer.h"
7+
#include "../XCRender/XCImageHelper.h"
8+
class LaserTypeBullet :public Bullet {
9+
private:
10+
/*
11+
float velocity = 0.0f, acceleration = 0.0f, angle = 0.0f;
12+
float NowPosition[3] = { 0.0f, 0.0f, 0.0f };
13+
bool isWorkFinish = false;
14+
bool isFinishTime = false;
15+
*/
16+
std::string imagePath;
17+
glm::vec4 divideInfo;
18+
glm::vec3 scaleInfo;
19+
glm::vec3 collideSize;
20+
int reBoundTime = 0;
21+
float velocity = 0.0f, acceleration = 0.0f, angle = 0.0f, increaseAngle = 0.0f;
22+
23+
int particleDensity = 3;
24+
float particleFinishTime = 0.0f, particleVelocity = 0.6f, particleSize = 15.0f;
25+
glm::vec4 particleColor;
26+
27+
XCGameTimer timer;
28+
XCImageHelper* image;
29+
30+
bool aimToPlayer = false, haveCheckGraze = false;
31+
32+
public:
33+
/*#£¡Attention scaleInfo will work both collide and render.
34+
#£¡renderSize: scaleX * widthRate : scaleY * heightRate ,collideSize : scaleX : scaleY*/
35+
LaserTypeBullet(std::string bulletImagePath, glm::vec4 divideInfo, glm::vec3 scaleInfo, glm::vec3 collideSize, glm::vec3 initCoord,
36+
float velocity, float acceleration, float angle, float increateAngle, int reboundTime, bool aimPlayer,
37+
int particleDensity, float particleFinishTime, float particleVelocity, float particleSize, glm::vec4 particleColor);
38+
39+
virtual void Init() override;
40+
virtual void Render() override;
41+
virtual void Release() override;
42+
43+
virtual bool BulletCollideWithPoint(float x, float y, bool &haveGraze) override;
44+
virtual void setBulletTerminate() override;
45+
};
46+
#endif

PythonSTG/XCCore/Bullet/OvalTypeBullet.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ void OvalTypeBullet::Render()
5959

6060
glEnable(GL_BLEND);
6161
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
62-
image->Render(glm::vec3(NowPosition[0], NowPosition[1], NowPosition[2]), glm::vec4(1.0f), glm::radians(angle), glm::vec3(0, 0, 1),
62+
image->Render(glm::vec3(NowPosition[0], NowPosition[1], 0.0f), glm::vec4(1.0f), glm::radians(angle), glm::vec3(0, 0, 1),
6363
scaleInfo * glm::vec3(XCFrameInfo::FrameRight, XCFrameInfo::FrameTop, 1.0f),
6464
IRenderHelper::GetSpecificTexture(divideInfo[0], divideInfo[1], divideInfo[2], divideInfo[3]));
6565
glDisable(GL_BLEND);

PythonSTG/XCCore/Bullet/RectangleTypeBullet.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ void RectangleTypeBullet::Render()
5454
glEnable(GL_BLEND);
5555
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
5656

57-
image->Render(glm::vec3(NowPosition[0], NowPosition[1], NowPosition[2]), glm::vec4(1.0f), glm::radians(angle), glm::vec3(0, 0, 1),
57+
image->Render(glm::vec3(NowPosition[0], NowPosition[1], 0.0f), glm::vec4(1.0f), glm::radians(angle), glm::vec3(0, 0, 1),
5858
scaleInfo * glm::vec3(XCFrameInfo::FrameRight, XCFrameInfo::FrameTop, 1.0f),
5959
IRenderHelper::GetSpecificTexture(divideInfo[0], divideInfo[1], divideInfo[2], divideInfo[3]));
6060
glDisable(GL_BLEND);

PythonSTG/XCCore/Item/Item.cpp

+38-16
Original file line numberDiff line numberDiff line change
@@ -13,29 +13,42 @@ Item::Item(const glm::vec2& generateCoord, ItemType itemType, float v, float a,
1313
angle = a;
1414
explodeEffect = exp;
1515

16-
divideInfo = glm::vec4();
17-
divideInfo.x = 4;
18-
divideInfo.y = 5;
16+
ItemDivideInfo = glm::vec4();
17+
ItemDivideInfo.x = 4;
18+
ItemDivideInfo.y = 6;
19+
1920
switch (itemType) {
2021
case ItemType::PointType:
21-
divideInfo.z = 2;
22-
divideInfo.w = 5;
22+
ItemDivideInfo.z = 2;
23+
ItemDivideInfo.w = 5;
2324
break;
2425
case ItemType::BombType:
25-
divideInfo.z = 2;
26-
divideInfo.w = 1;
26+
ItemDivideInfo.z = 2;
27+
ItemDivideInfo.w = 1;
2728
break;
2829
case ItemType::PowerType:
29-
divideInfo.z = 1;
30-
divideInfo.w = 5;
30+
ItemDivideInfo.z = 1;
31+
ItemDivideInfo.w = 5;
3132
break;
3233
case ItemType::FullPowerType:
33-
divideInfo.z = 2;
34-
divideInfo.w = 4;
34+
ItemDivideInfo.z = 2;
35+
ItemDivideInfo.w = 4;
3536
break;
3637
case ItemType::LifeType:
37-
divideInfo.z = 1;
38-
divideInfo.w = 2;
38+
ItemDivideInfo.z = 1;
39+
ItemDivideInfo.w = 2;
40+
break;
41+
case ItemType::MoonPointType:
42+
ItemDivideInfo.z = 1;
43+
ItemDivideInfo.w = 6;
44+
break;
45+
case ItemType::MoonPointMirror:
46+
ItemDivideInfo.z = 2;
47+
ItemDivideInfo.w = 6;
48+
break;
49+
case ItemType::MoonPointUp:
50+
ItemDivideInfo.z = 3;
51+
ItemDivideInfo.w = 6;
3952
break;
4053
}
4154
setCurrentType(ObjectType::ItemType);
@@ -62,7 +75,7 @@ void Item::Render()
6275
glEnable(GL_BLEND);
6376
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
6477
itemImage->Render(glm::vec3(NowPosition, 0.0f), glm::vec4(1.0f), 0.0f, glm::vec3(0, 0, 1), glm::vec3(0.05f),
65-
IRenderHelper::GetSpecificTexWithRate(XCFrameInfo::FrameRight, XCFrameInfo::FrameTop, divideInfo.x, divideInfo.y, divideInfo.z, divideInfo.w));
78+
IRenderHelper::GetSpecificTexWithRate(XCFrameInfo::FrameRight, XCFrameInfo::FrameTop, ItemDivideInfo.x, ItemDivideInfo.y, ItemDivideInfo.z, ItemDivideInfo.w));
6679
glDisable(GL_BLEND);
6780

6881
if (NowPosition.y + 0.1f< -1.0f ) {
@@ -76,7 +89,6 @@ void Item::Release()
7689
if (isInit) {
7790
itemImage->Release();
7891
delete itemImage;
79-
8092
isInit = false;
8193
}
8294
}
@@ -88,7 +100,7 @@ void Item::checkCollideWithPlayer(CollideHelper * helper)
88100
float x = *(pos), y = *(pos + 1);
89101
AbsorbParticleHelper* particleHelper = new AbsorbParticleHelper;
90102
float dist = pow(pow(x - NowPosition.x, 2) + pow(y - NowPosition.y, 2), 0.5f);
91-
if (dist < 0.1f || y> 0.7f) {
103+
if (dist < 0.1f || y> 0.65f || helper->getPlayerIsMoonState()) {
92104
switch (currentType) {
93105
case ItemType::PointType:
94106
helper->addPlayerPoint();
@@ -109,6 +121,16 @@ void Item::checkCollideWithPlayer(CollideHelper * helper)
109121
helper->addPlayerLife();
110122
particleHelper->addNewParticle(24, 18.0f, 1.0f, 1.0f, glm::vec4(0.9, 0.01, 0.01, 1.0f), NowPosition, glm::vec2(x, y));
111123
break;
124+
125+
case ItemType::MoonPointType:
126+
case ItemType::MoonPointMirror:
127+
case ItemType::MoonPointUp:
128+
helper->addPlayerMoonPoint();
129+
particleHelper->addNewParticle(9, 14.0f, 1.0f, 0.6f, glm::vec4(0.3, 0.3, 1.0, 1.0f), NowPosition, glm::vec2(x, y));
130+
break;
131+
132+
default:
133+
break;
112134
}
113135
RenderManager::getInstance()->AddRenderObject(ParticleGroupUuid, particleHelper);
114136
isWorkFinish = true;

0 commit comments

Comments
 (0)