Skip to content

Commit 10e5479

Browse files
authored
Merge pull request #24 from lr8soft/dev-y
v0.30x
2 parents f5bc435 + 0a0e805 commit 10e5479

17 files changed

Lines changed: 332 additions & 22 deletions

.idea/workspace.xml

Lines changed: 3 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Python2D/LaunchHelper.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ void LaunchHelper::StartGame()
2020

2121
/*render manager init*/
2222
auto infoInterface = GameInfoInterface::getInstance();
23-
RenderManager::getInstance()->AddUserInterface("gameInfo", infoInterface);
23+
RenderManager::getInstance()->AddUserInterface(GameInfoUIUuid, infoInterface);
2424

2525
}
2626

@@ -32,7 +32,7 @@ void LaunchHelper::LoadGameMenu()
3232
{
3333
TaskManager::getInstance()->CleanAllStage();
3434
RenderManager::getInstance()->CleanAllRenderObject();
35-
RenderManager::getInstance()->CleanUserInterface("gameInfo");
35+
RenderManager::getInstance()->CleanUserInterface(GameInfoUIUuid);
3636
if (RenderManager::getInstance()->getPlayer()!=nullptr) {
3737
RenderManager::getInstance()->getPlayer()->PlayerRelease();
3838
RenderManager::getInstance()->setPlayer(nullptr);

Python2D/Python2D.vcxproj

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,9 @@
123123
<SDLCheck>true</SDLCheck>
124124
<ConformanceMode>true</ConformanceMode>
125125
<AdditionalIncludeDirectories>C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\include;D:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
126+
<EnableEnhancedInstructionSet>AdvancedVectorExtensions2</EnableEnhancedInstructionSet>
127+
<LanguageStandard>
128+
</LanguageStandard>
126129
</ClCompile>
127130
<Link>
128131
<EnableCOMDATFolding>true</EnableCOMDATFolding>
@@ -144,9 +147,11 @@
144147
<ClCompile Include="XCCore\Background\MagicForest.cpp" />
145148
<ClCompile Include="XCCore\Bullet\BulletHelper.cpp" />
146149
<ClCompile Include="XCCore\Bullet\CircleTypeBullet.cpp" />
150+
<ClCompile Include="XCCore\Bullet\OvalTypeBullet.cpp" />
147151
<ClCompile Include="XCCore\Bullet\RectangleTypeBullet.cpp" />
148152
<ClCompile Include="XCCore\Enemy\EnemyObject.cpp" />
149153
<ClCompile Include="XCCore\Menu\GameMenu.cpp" />
154+
<ClCompile Include="XCCore\Menu\PauseMenu.cpp" />
150155
<ClCompile Include="XCCore\Task\Task.cpp" />
151156
<ClCompile Include="XCCore\Task\TaskBoss.cpp" />
152157
<ClCompile Include="XCCore\Task\TaskDispatcher.cpp" />
@@ -179,6 +184,8 @@
179184
</ItemGroup>
180185
<ItemGroup>
181186
<ClInclude Include="LaunchHelper.h" />
187+
<ClInclude Include="XCCore\Bullet\OvalTypeBullet.h" />
188+
<ClInclude Include="XCCore\Menu\PauseMenu.h" />
182189
<ClInclude Include="util\ConfigManager.h" />
183190
<ClInclude Include="util\GameTimer.h" />
184191
<ClInclude Include="util\ImageLoader.h" />

Python2D/Python2D.vcxproj.filters

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,12 @@
178178
<Filter>XCCore\Menu</Filter>
179179
</ClCompile>
180180
<ClCompile Include="LaunchHelper.cpp" />
181+
<ClCompile Include="XCCore\Menu\PauseMenu.cpp">
182+
<Filter>XCCore\Menu</Filter>
183+
</ClCompile>
184+
<ClCompile Include="XCCore\Bullet\OvalTypeBullet.cpp">
185+
<Filter>XCCore\Bullet</Filter>
186+
</ClCompile>
181187
</ItemGroup>
182188
<ItemGroup>
183189
<ClInclude Include="util\ConfigManager.h">
@@ -330,5 +336,11 @@
330336
<Filter>XCCore\Menu</Filter>
331337
</ClInclude>
332338
<ClInclude Include="LaunchHelper.h" />
339+
<ClInclude Include="XCCore\Menu\PauseMenu.h">
340+
<Filter>XCCore\Menu</Filter>
341+
</ClInclude>
342+
<ClInclude Include="XCCore\Bullet\OvalTypeBullet.h">
343+
<Filter>XCCore\Bullet</Filter>
344+
</ClInclude>
333345
</ItemGroup>
334346
</Project>

Python2D/XCCore/Bullet/BulletHelper.cpp

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#include "BulletHelper.h"
22
#include "CircleTypeBullet.h"
3+
#include "OvalTypeBullet.h"
4+
#include "RectangleTypeBullet.h"
35
#include "../../XCInterpreter/ScriptLoader.h"
46
Bullet * BulletHelper::getNewBulletObject(std::string bulletImage,std::string bulletType, glm::vec4 divideInfo, glm::vec3 scaleInfo, glm::vec3 collideSize,
57
glm::vec3 initCoord, float velocity, float acceleration, float angle, float increateAngle, int reboundTime, bool aimPlayer,
@@ -10,6 +12,14 @@ Bullet * BulletHelper::getNewBulletObject(std::string bulletImage,std::string bu
1012
bullet = new CircleTypeBullet(bulletImage, divideInfo, scaleInfo, collideSize, initCoord, velocity, acceleration, angle, increateAngle, reboundTime, aimPlayer,
1113
particleDensity, particleFinishTime, particleVelocity, particleSize, particleColor);
1214
}
15+
else if (bulletType == "ovalTypeBullet") {
16+
bullet = new OvalTypeBullet(bulletImage, divideInfo, scaleInfo, collideSize, initCoord, velocity, acceleration, angle, increateAngle, reboundTime, aimPlayer,
17+
particleDensity, particleFinishTime, particleVelocity, particleSize, particleColor);
18+
}
19+
else if (bulletType == "rectangleTypeBullet") {
20+
/*bullet = new RectangleTypeBullet(bulletImage, divideInfo, scaleInfo, collideSize, initCoord, velocity, acceleration, angle, increateAngle, reboundTime, aimPlayer,
21+
particleDensity, particleFinishTime, particleVelocity, particleSize, particleColor);*/
22+
}
1323
return bullet;
1424
}
1525

@@ -18,10 +28,10 @@ Bullet * BulletHelper::parseBulletObject(PyObject * bulletObject)
1828
Bullet* bullet = nullptr;
1929

2030
if (bulletObject != nullptr) {
21-
auto imageInfo = PyObject_CallMethod(bulletObject, "_cpp_getInitRenderInfo", NULL);
22-
auto bulletGenerateInfo = PyObject_CallMethod(bulletObject, "_cpp_getGenerateInfo", NULL);
23-
auto bulletCoordInfo = PyObject_CallMethod(bulletObject, "_cpp_getInitCoord", NULL);
24-
auto bulletReleaseInfo = PyObject_CallMethod(bulletObject, "_cpp_getReleaseParticleInfo", NULL);
31+
PyObject* imageInfo = PyObject_CallMethod(bulletObject, "_cpp_getInitRenderInfo", NULL);
32+
PyObject* bulletGenerateInfo = PyObject_CallMethod(bulletObject, "_cpp_getGenerateInfo", NULL);
33+
PyObject* bulletCoordInfo = PyObject_CallMethod(bulletObject, "_cpp_getInitCoord", NULL);
34+
PyObject* bulletReleaseInfo = PyObject_CallMethod(bulletObject, "_cpp_getReleaseParticleInfo", NULL);
2535

2636
const char* bulletImage, *bulletType; int divideInfo[4]; float scaleInfo[3], collideSize[3];
2737
PyArg_ParseTuple(imageInfo, "ss(iiii)(fff)(fff)", &bulletImage, &bulletType, &divideInfo[0], &divideInfo[1], &divideInfo[2], &divideInfo[3],
Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
#include "OvalTypeBullet.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+
OvalTypeBullet::OvalTypeBullet(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 OvalTypeBullet::Init()
43+
{
44+
if (!isInit) {
45+
image = new XCImageHelper(imagePath, true);
46+
47+
isInit = true;
48+
}
49+
}
50+
51+
void OvalTypeBullet::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 OvalTypeBullet::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 OvalTypeBullet::Release()
82+
{
83+
if (isInit) {
84+
image->Release();
85+
delete image;
86+
87+
image = nullptr;
88+
isInit = false;
89+
}
90+
}
91+
92+
bool OvalTypeBullet::BulletCollideWithPoint(float x, float y, bool &haveGraze)
93+
{
94+
bool value = false;
95+
if (isInit && timer.getAccumlateTime() >= 0.4f) {
96+
x -= NowPosition[0];
97+
y -= NowPosition[1];
98+
99+
float NewX = x * cos(angle) + y * sin(angle);
100+
float NewY = -x * sin(angle) + y * cos(angle);
101+
102+
float distance = pow(NewX, 2) + pow(NewY, 2);
103+
float ovalParameter = pow(NewX, 2) / pow(collideSize.x, 2) + pow(NewY, 2) / pow(collideSize.y, 2);
104+
105+
if (!haveCheckGraze && distance <= CollideInfo::getGrazeDistance()) {
106+
haveGraze = true;
107+
haveCheckGraze = true;
108+
}
109+
value = (ovalParameter < 1.0f);
110+
}
111+
112+
return value;
113+
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
#pragma once
2+
#ifndef _OVAL_TYPE_BULLET_H_
3+
#define _OVAL_TYPE_BULLET_H_
4+
#include "Bullet.h"
5+
#include <glm/glm.hpp>
6+
#include "../../util/GameTimer.h"
7+
#include "../XCRender/XCImageHelper.h"
8+
class OvalTypeBullet :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+
OvalTypeBullet(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

Python2D/XCCore/Item/Player.cpp

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -148,12 +148,14 @@ void Player::hurtPlayer()
148148
RenderManager::getInstance()->AddRenderObject(ParticleGroupUuid, particleGroup);
149149
isHitTime = true;
150150

151-
GameInfoInterface::setMaxLife(maxLife);
152-
GameInfoInterface::setNowLife(--nowLife);
153-
if (nowLife < 0) {
151+
152+
if (nowLife -1 >=0) {
153+
nowLife--;
154+
}else{
154155
nowLife = 8;
155-
//LaunchHelper::LoadGameMenu();
156156
}
157+
GameInfoInterface::setMaxLife(maxLife);
158+
GameInfoInterface::setNowLife(nowLife);
157159
}
158160

159161
}
@@ -223,10 +225,11 @@ void Player::playerKeyCheck()
223225

224226
}
225227

226-
if (glfwGetKey(screen, XCFrameInfo::keyItem) == GLFW_PRESS && nowBomb -1 >= 0) {
227-
GameInfoInterface::setMaxBomb(maxBomb);
228-
GameInfoInterface::setNowBomb(--nowBomb);
229-
//player_fire_power += 0.1f;
228+
if (glfwGetKey(screen, XCFrameInfo::keyItem) == GLFW_PRESS ) {
229+
if (nowBomb-1>=0) {
230+
GameInfoInterface::setMaxBomb(maxBomb);
231+
GameInfoInterface::setNowBomb(--nowBomb);
232+
}
230233
}
231234
if (!have_player_change_state) {
232235
if (playerNowState != PLAYER_TURNRIGHT && playerNowState != PLAYER_TURNLEFT)

Python2D/XCCore/Menu/PauseMenu.cpp

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#include "PauseMenu.h"
2+
3+
void PauseMenu::checkKeyInput()
4+
{
5+
}
6+
7+
PauseMenu::PauseMenu()
8+
{
9+
}
10+
11+
void PauseMenu::Init()
12+
{
13+
if (!isInit) {
14+
isInit = true;
15+
}
16+
}
17+
18+
void PauseMenu::Render()
19+
{
20+
if (isInit) {
21+
22+
}
23+
}
24+
25+
void PauseMenu::Release()
26+
{
27+
if (isInit) {
28+
29+
isInit = false;
30+
}
31+
}

Python2D/XCCore/Menu/PauseMenu.h

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#pragma once
2+
#ifndef _PAUSE_MENU_H_
3+
#define _PAUSE_MENU_H_
4+
#include <map>
5+
#include "IMenu.h"
6+
#include "../XCAudio/AudioHelper.h"
7+
#include "../../util/GameTimer.h"
8+
class PauseMenu :public IMenu {
9+
private:
10+
XCGameTimer timer;
11+
12+
XCWavFile confirmEffect, cancelEffect;
13+
int nowSelectIndex = 0;
14+
long double lastClickTime = 0.0;
15+
16+
void checkKeyInput();
17+
public:
18+
PauseMenu();
19+
virtual void Init() override;
20+
virtual void Render() override;
21+
virtual void Release() override;
22+
};
23+
#endif

0 commit comments

Comments
 (0)