Stupid bullet. Also fixed WIZARD_IDLE animations missing.
This commit is contained in:
parent
34f44f0f6f
commit
934bf5be79
@ -138,7 +138,7 @@ bool Crawler::OnUserCreate(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool Crawler::OnUserUpdate(float fElapsedTime){
|
bool Crawler::OnUserUpdate(float fElapsedTime){
|
||||||
fElapsedTime=std::clamp(fElapsedTime,0.f,1/60.f);
|
fElapsedTime=std::clamp(fElapsedTime,0.f,1/60.f); //HACK fix. We can't have a negative time. Although using a more precise system clock should make this never occur. Also make sure if the game is too slow we advance by only 1/60th of a second.
|
||||||
HandleUserInput(fElapsedTime);
|
HandleUserInput(fElapsedTime);
|
||||||
UpdateEffects(fElapsedTime);
|
UpdateEffects(fElapsedTime);
|
||||||
player->Update(fElapsedTime);
|
player->Update(fElapsedTime);
|
||||||
@ -436,13 +436,8 @@ void Crawler::UpdateBullets(float fElapsedTime){
|
|||||||
moveStep=(b->vel*fElapsedTime).norm();
|
moveStep=(b->vel*fElapsedTime).norm();
|
||||||
}
|
}
|
||||||
while(totalDistance>0){
|
while(totalDistance>0){
|
||||||
if(totalDistance>=1){
|
totalDistance=std::max(0.f,totalDistance-1);
|
||||||
b->pos+=moveStep;
|
b->pos+=moveStep;
|
||||||
totalDistance--;
|
|
||||||
} else {
|
|
||||||
b->pos+=moveStep*totalDistance;
|
|
||||||
totalDistance=0;
|
|
||||||
}
|
|
||||||
if(b->friendly){
|
if(b->friendly){
|
||||||
for(Monster&m:MONSTER_LIST){
|
for(Monster&m:MONSTER_LIST){
|
||||||
if(geom2d::overlaps(geom2d::circle(m.GetPos(),12*m.GetSizeMult()),geom2d::circle(b->pos,b->radius))){
|
if(geom2d::overlaps(geom2d::circle(m.GetPos(),12*m.GetSizeMult()),geom2d::circle(b->pos,b->radius))){
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
#define VERSION_MAJOR 0
|
#define VERSION_MAJOR 0
|
||||||
#define VERSION_MINOR 2
|
#define VERSION_MINOR 2
|
||||||
#define VERSION_PATCH 0
|
#define VERSION_PATCH 0
|
||||||
#define VERSION_BUILD 1025
|
#define VERSION_BUILD 1033
|
||||||
|
|
||||||
#define stringify(a) stringify_(a)
|
#define stringify(a) stringify_(a)
|
||||||
#define stringify_(a) #a
|
#define stringify_(a) #a
|
||||||
|
@ -24,4 +24,5 @@ Player
|
|||||||
PLAYER_ANIMATION[8] = WIZARD_IDLE_ATTACK
|
PLAYER_ANIMATION[8] = WIZARD_IDLE_ATTACK
|
||||||
PLAYER_ANIMATION[9] = WIZARD_ATTACK
|
PLAYER_ANIMATION[9] = WIZARD_ATTACK
|
||||||
PLAYER_ANIMATION[10] = WIZARD_CAST
|
PLAYER_ANIMATION[10] = WIZARD_CAST
|
||||||
|
PLAYER_ANIMATION[11] = WIZARD_IDLE
|
||||||
}
|
}
|
@ -35,7 +35,7 @@ var Module = {
|
|||||||
})(),
|
})(),
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
<script async type="text/javascript" src="_REPLACEME_"></script>
|
<script async type="text/javascript" src="pge.js"></script>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
Module.canvas.addEventListener("resize", (e) => {
|
Module.canvas.addEventListener("resize", (e) => {
|
||||||
|
|
||||||
|
@ -1021,6 +1021,8 @@ namespace olc
|
|||||||
uint32_t GetFPS() const;
|
uint32_t GetFPS() const;
|
||||||
// Gets last update of elapsed time
|
// Gets last update of elapsed time
|
||||||
float GetElapsedTime() const;
|
float GetElapsedTime() const;
|
||||||
|
// Gets Actual Window pos
|
||||||
|
const olc::vi2d& GetWindowPos() const;
|
||||||
// Gets Actual Window size
|
// Gets Actual Window size
|
||||||
const olc::vi2d& GetWindowSize() const;
|
const olc::vi2d& GetWindowSize() const;
|
||||||
// Gets pixel scale
|
// Gets pixel scale
|
||||||
@ -1222,6 +1224,7 @@ namespace olc
|
|||||||
olc::vi2d vMousePosCache = { 0, 0 };
|
olc::vi2d vMousePosCache = { 0, 0 };
|
||||||
olc::vi2d vMouseWindowPos = { 0, 0 };
|
olc::vi2d vMouseWindowPos = { 0, 0 };
|
||||||
int32_t nMouseWheelDeltaCache = 0;
|
int32_t nMouseWheelDeltaCache = 0;
|
||||||
|
olc::vi2d vWindowPos = { 0, 0 };
|
||||||
olc::vi2d vWindowSize = { 0, 0 };
|
olc::vi2d vWindowSize = { 0, 0 };
|
||||||
olc::vi2d vViewPos = { 0, 0 };
|
olc::vi2d vViewPos = { 0, 0 };
|
||||||
olc::vi2d vViewSize = { 0,0 };
|
olc::vi2d vViewSize = { 0,0 };
|
||||||
@ -1292,6 +1295,7 @@ namespace olc
|
|||||||
// "Break In" Functions
|
// "Break In" Functions
|
||||||
void olc_UpdateMouse(int32_t x, int32_t y);
|
void olc_UpdateMouse(int32_t x, int32_t y);
|
||||||
void olc_UpdateMouseWheel(int32_t delta);
|
void olc_UpdateMouseWheel(int32_t delta);
|
||||||
|
void olc_UpdateWindowPos(int32_t x, int32_t y);
|
||||||
void olc_UpdateWindowSize(int32_t x, int32_t y);
|
void olc_UpdateWindowSize(int32_t x, int32_t y);
|
||||||
void olc_UpdateViewport();
|
void olc_UpdateViewport();
|
||||||
void olc_ConstructFontSheet();
|
void olc_ConstructFontSheet();
|
||||||
@ -2001,6 +2005,7 @@ namespace olc
|
|||||||
|
|
||||||
// Construct the window
|
// Construct the window
|
||||||
if (platform->CreateWindowPane({ 30,30 }, vWindowSize, bFullScreen) != olc::OK) return olc::FAIL;
|
if (platform->CreateWindowPane({ 30,30 }, vWindowSize, bFullScreen) != olc::OK) return olc::FAIL;
|
||||||
|
olc_UpdateWindowPos(30,30);
|
||||||
olc_UpdateWindowSize(vWindowSize.x, vWindowSize.y);
|
olc_UpdateWindowSize(vWindowSize.x, vWindowSize.y);
|
||||||
|
|
||||||
// Start the thread
|
// Start the thread
|
||||||
@ -2126,6 +2131,9 @@ namespace olc
|
|||||||
float PixelGameEngine::GetElapsedTime() const
|
float PixelGameEngine::GetElapsedTime() const
|
||||||
{ return fLastElapsed; }
|
{ return fLastElapsed; }
|
||||||
|
|
||||||
|
const olc::vi2d& PixelGameEngine::GetWindowPos() const
|
||||||
|
{ return vWindowPos; }
|
||||||
|
|
||||||
const olc::vi2d& PixelGameEngine::GetWindowSize() const
|
const olc::vi2d& PixelGameEngine::GetWindowSize() const
|
||||||
{ return vWindowSize; }
|
{ return vWindowSize; }
|
||||||
|
|
||||||
@ -3761,6 +3769,11 @@ namespace olc
|
|||||||
olc_UpdateViewport();
|
olc_UpdateViewport();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PixelGameEngine::olc_UpdateWindowPos(int32_t x, int32_t y)
|
||||||
|
{
|
||||||
|
vWindowPos = { x, y };
|
||||||
|
}
|
||||||
|
|
||||||
void PixelGameEngine::olc_UpdateMouseWheel(int32_t delta)
|
void PixelGameEngine::olc_UpdateMouseWheel(int32_t delta)
|
||||||
{ nMouseWheelDeltaCache += delta; }
|
{ nMouseWheelDeltaCache += delta; }
|
||||||
|
|
||||||
@ -5589,6 +5602,7 @@ namespace olc
|
|||||||
ptrPGE->olc_UpdateMouse(ix, iy);
|
ptrPGE->olc_UpdateMouse(ix, iy);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
case WM_MOVE: ptrPGE->olc_UpdateWindowPos(lParam & 0xFFFF, (lParam >> 16) & 0xFFFF); return 0;
|
||||||
case WM_SIZE: ptrPGE->olc_UpdateWindowSize(lParam & 0xFFFF, (lParam >> 16) & 0xFFFF); return 0;
|
case WM_SIZE: ptrPGE->olc_UpdateWindowSize(lParam & 0xFFFF, (lParam >> 16) & 0xFFFF); return 0;
|
||||||
case WM_MOUSEWHEEL: ptrPGE->olc_UpdateMouseWheel(GET_WHEEL_DELTA_WPARAM(wParam)); return 0;
|
case WM_MOUSEWHEEL: ptrPGE->olc_UpdateMouseWheel(GET_WHEEL_DELTA_WPARAM(wParam)); return 0;
|
||||||
case WM_MOUSELEAVE: ptrPGE->olc_UpdateMouseFocus(false); return 0;
|
case WM_MOUSELEAVE: ptrPGE->olc_UpdateMouseFocus(false); return 0;
|
||||||
@ -5834,11 +5848,13 @@ namespace olc
|
|||||||
{
|
{
|
||||||
XWindowAttributes gwa;
|
XWindowAttributes gwa;
|
||||||
XGetWindowAttributes(olc_Display, olc_Window, &gwa);
|
XGetWindowAttributes(olc_Display, olc_Window, &gwa);
|
||||||
|
ptrPGE->olc_UpdateWindowPos(gwa.x, gwa.y);
|
||||||
ptrPGE->olc_UpdateWindowSize(gwa.width, gwa.height);
|
ptrPGE->olc_UpdateWindowSize(gwa.width, gwa.height);
|
||||||
}
|
}
|
||||||
else if (xev.type == ConfigureNotify)
|
else if (xev.type == ConfigureNotify)
|
||||||
{
|
{
|
||||||
XConfigureEvent xce = xev.xconfigure;
|
XConfigureEvent xce = xev.xconfigure;
|
||||||
|
ptrPGE->olc_UpdateWindowPos(xce.x, xce.y);
|
||||||
ptrPGE->olc_UpdateWindowSize(xce.width, xce.height);
|
ptrPGE->olc_UpdateWindowSize(xce.width, xce.height);
|
||||||
}
|
}
|
||||||
else if (xev.type == KeyPress)
|
else if (xev.type == KeyPress)
|
||||||
@ -6316,19 +6332,19 @@ namespace olc
|
|||||||
mapKeys[DOM_PK_QUOTE] = Key::OEM_7; mapKeys[DOM_PK_BACKSLASH] = Key::OEM_8;
|
mapKeys[DOM_PK_QUOTE] = Key::OEM_7; mapKeys[DOM_PK_BACKSLASH] = Key::OEM_8;
|
||||||
|
|
||||||
// Keyboard Callbacks
|
// Keyboard Callbacks
|
||||||
emscripten_set_keydown_callback("#canvas", 0, 1, keyboard_callback);
|
emscripten_set_keydown_callback("body", 0, 1, keyboard_callback);
|
||||||
emscripten_set_keyup_callback("#canvas", 0, 1, keyboard_callback);
|
emscripten_set_keyup_callback("body", 0, 1, keyboard_callback);
|
||||||
|
|
||||||
// Mouse Callbacks
|
// Mouse Callbacks
|
||||||
emscripten_set_wheel_callback("#canvas", 0, 1, wheel_callback);
|
emscripten_set_wheel_callback("#canvas", 0, 1, wheel_callback);
|
||||||
emscripten_set_mousedown_callback("#canvas", 0, 1, mouse_callback);
|
emscripten_set_mousedown_callback("body", 0, 1, mouse_callback);
|
||||||
emscripten_set_mouseup_callback("#canvas", 0, 1, mouse_callback);
|
emscripten_set_mouseup_callback("body", 0, 1, mouse_callback);
|
||||||
emscripten_set_mousemove_callback("#canvas", 0, 1, mouse_callback);
|
emscripten_set_mousemove_callback("body", 0, 1, mouse_callback);
|
||||||
|
|
||||||
// Touch Callbacks
|
// Touch Callbacks
|
||||||
emscripten_set_touchstart_callback("#canvas", 0, 1, touch_callback);
|
emscripten_set_touchstart_callback("body", 0, 1, touch_callback);
|
||||||
emscripten_set_touchmove_callback("#canvas", 0, 1, touch_callback);
|
emscripten_set_touchmove_callback("body", 0, 1, touch_callback);
|
||||||
emscripten_set_touchend_callback("#canvas", 0, 1, touch_callback);
|
emscripten_set_touchend_callback("body", 0, 1, touch_callback);
|
||||||
|
|
||||||
// Canvas Focus Callbacks
|
// Canvas Focus Callbacks
|
||||||
emscripten_set_blur_callback("#canvas", 0, 1, focus_callback);
|
emscripten_set_blur_callback("#canvas", 0, 1, focus_callback);
|
||||||
@ -6569,7 +6585,22 @@ namespace olc
|
|||||||
{ return olc::OK; }
|
{ return olc::OK; }
|
||||||
|
|
||||||
virtual olc::rcode HandleSystemEvent() override
|
virtual olc::rcode HandleSystemEvent() override
|
||||||
{ return olc::OK; }
|
{
|
||||||
|
ptrPGE->olc_UpdateWindowPos(EM_ASM_INT({return Module.canvas.getBoundingClientRect().left}),EM_ASM_INT({return Module.canvas.getBoundingClientRect().top}));
|
||||||
|
int mouseDown=EM_ASM_INT({return Module.olc_MOUSEDOWN});
|
||||||
|
int mouseUp=EM_ASM_INT({return Module.olc_MOUSEUP});
|
||||||
|
if(mouseDown!=-1){
|
||||||
|
if(mouseDown==2){mouseDown=1;}//Javascript uses button 2 as right click while PGE uses button 1. This translates it back.
|
||||||
|
ptrPGE->olc_UpdateMouseState(mouseDown,true);
|
||||||
|
EM_ASM({Module.olc_MOUSEDOWN=-1});
|
||||||
|
}
|
||||||
|
if(mouseUp!=-1){
|
||||||
|
if(mouseUp==2){mouseUp=1;}//Javascript uses button 2 as right click while PGE uses button 1. This translates it back.
|
||||||
|
ptrPGE->olc_UpdateMouseState(mouseUp,false);
|
||||||
|
EM_ASM({Module.olc_MOUSEUP=-1});
|
||||||
|
}
|
||||||
|
return olc::OK;
|
||||||
|
}
|
||||||
|
|
||||||
static void MainLoop()
|
static void MainLoop()
|
||||||
{
|
{
|
||||||
|
@ -8964,7 +8964,7 @@ MonsterStrategy
|
|||||||
{
|
{
|
||||||
Name = Run Towards
|
Name = Run Towards
|
||||||
# How long to wait before attempting to path again.
|
# How long to wait before attempting to path again.
|
||||||
WaitTime = 2
|
WaitTime = 3
|
||||||
# How far the monster will travel before reassessing for a new path.
|
# How far the monster will travel before reassessing for a new path.
|
||||||
MaxDistance = 999999
|
MaxDistance = 999999
|
||||||
}
|
}
|
||||||
@ -8972,12 +8972,14 @@ MonsterStrategy
|
|||||||
{
|
{
|
||||||
Name = Shoot Afar
|
Name = Shoot Afar
|
||||||
# How far away the monster attempts to distance itself from the player
|
# How far away the monster attempts to distance itself from the player
|
||||||
Range = 800
|
Range = 700
|
||||||
|
# If the player is farther than this distance, close in on them.
|
||||||
|
CloseInRange = 850
|
||||||
# How often the enemy shoots.
|
# How often the enemy shoots.
|
||||||
ShootingSpeed = 1
|
ShootingSpeed = 1
|
||||||
BulletSpeed = 100
|
BulletSpeed = 300
|
||||||
BulletSize = 100
|
BulletSize = 20
|
||||||
BulletColor = 0, 0, 255, 255
|
BulletColor = 37, 131, 112, 255
|
||||||
}
|
}
|
||||||
2
|
2
|
||||||
{
|
{
|
||||||
@ -8985,10 +8987,10 @@ MonsterStrategy
|
|||||||
# How far away the monster starts shooting from
|
# How far away the monster starts shooting from
|
||||||
Range = 800
|
Range = 800
|
||||||
# How often the enemy shoots.
|
# How often the enemy shoots.
|
||||||
ShootingSpeed = 1
|
ShootingSpeed = 0.6
|
||||||
BulletSpeed = 100
|
BulletSpeed = 450
|
||||||
BulletSize = 100
|
BulletSize = 30
|
||||||
BulletColor = 0, 0, 255, 255
|
BulletColor = 0, 255, 0, 255
|
||||||
}
|
}
|
||||||
}Monsters
|
}Monsters
|
||||||
{
|
{
|
||||||
@ -9014,8 +9016,9 @@ MonsterStrategy
|
|||||||
ShootAnimation = 10, 0.1, OneShot
|
ShootAnimation = 10, 0.1, OneShot
|
||||||
DeathAnimation = 10, 0.1, OneShot
|
DeathAnimation = 10, 0.1, OneShot
|
||||||
|
|
||||||
#Additional custom animations go down below. Start with ANIMATION[0]
|
#Additional custom animations go down below. Start with ANIMATION[0]. Order is:
|
||||||
#ANIMATION[0] = MY_NEW_ANIMATION
|
# Frame Count, Frame Speed (s), Frame Cycling (Repeat,OneShot,PingPong,Reverse)
|
||||||
|
#ANIMATION[0] = 6, 0.1, Repeat
|
||||||
}
|
}
|
||||||
1
|
1
|
||||||
{
|
{
|
||||||
@ -9036,7 +9039,7 @@ MonsterStrategy
|
|||||||
# Frame Count, Frame Speed (s), Frame Cycling (Repeat,OneShot,PingPong,Reverse)
|
# Frame Count, Frame Speed (s), Frame Cycling (Repeat,OneShot,PingPong,Reverse)
|
||||||
IdleAnimation = 10, 0.1, Repeat
|
IdleAnimation = 10, 0.1, Repeat
|
||||||
JumpAnimation = 10, 0.06, Repeat
|
JumpAnimation = 10, 0.06, Repeat
|
||||||
ShootAnimation = 10, 0.1, OneShot
|
ShootAnimation = 10, 0.1, Repeat
|
||||||
DeathAnimation = 10, 0.1, OneShot
|
DeathAnimation = 10, 0.1, OneShot
|
||||||
|
|
||||||
#Additional custom animations go down below. Start with ANIMATION[0]
|
#Additional custom animations go down below. Start with ANIMATION[0]
|
||||||
@ -9130,6 +9133,19 @@ MonsterStrategy
|
|||||||
|
|
||||||
# How much speed the player loses while no momentum is being added.
|
# How much speed the player loses while no momentum is being added.
|
||||||
Friction = 400
|
Friction = 400
|
||||||
|
|
||||||
|
# Each attack will have _N,_E,_S,_W appended to them once read in-game.
|
||||||
|
PLAYER_ANIMATION[0] = WARRIOR_WALK
|
||||||
|
PLAYER_ANIMATION[1] = WARRIOR_IDLE
|
||||||
|
PLAYER_ANIMATION[2] = WARRIOR_SWINGSWORD
|
||||||
|
PLAYER_ANIMATION[3] = WARRIOR_SWINGSONICSWORD
|
||||||
|
PLAYER_ANIMATION[4] = RANGER_WALK
|
||||||
|
PLAYER_ANIMATION[5] = RANGER_IDLE
|
||||||
|
PLAYER_ANIMATION[6] = RANGER_SHOOT
|
||||||
|
PLAYER_ANIMATION[7] = WIZARD_WALK
|
||||||
|
PLAYER_ANIMATION[8] = WIZARD_IDLE_ATTACK
|
||||||
|
PLAYER_ANIMATION[9] = WIZARD_ATTACK
|
||||||
|
PLAYER_ANIMATION[10] = WIZARD_CAST
|
||||||
}Ranger
|
}Ranger
|
||||||
{
|
{
|
||||||
ClassName = Ranger
|
ClassName = Ranger
|
||||||
@ -9377,7 +9393,7 @@ MonsterStrategy
|
|||||||
Right Click Ability
|
Right Click Ability
|
||||||
{
|
{
|
||||||
Name = Block
|
Name = Block
|
||||||
Cooldown = 1
|
Cooldown = 15
|
||||||
Mana Cost = 0
|
Mana Cost = 0
|
||||||
|
|
||||||
#RGB Values. Color 1 is the left side of the bar, Color 2 is the right side.
|
#RGB Values. Color 1 is the left side of the bar, Color 2 is the right side.
|
||||||
@ -16645,6 +16661,19 @@ D
|
|||||||
$Œéôjyƒhëô<C3AB>®}[¯Ó«©ê§tþwW¬€Eh… l‚ݯTEDd$
ICüJUFÒ°ƒ(·¾ Jm}¿R¥þ}I$”–¾=Çv›‚tÓ~W´;¶Š·…ûBÅçûüv?öÖö…Î2æÖâ±]h} |