Corrected web build linux script and fixed animations on Turret flower. Issue #19

Co-authored-by: sigonasr2 <sigonasr2@gmail.com>
pull/28/head
parent 8aba4dfc5b
commit 49b597bfe7
  1. 1
      Crawler/MonsterAttribute.h
  2. 9
      Crawler/Turret.cpp
  3. 2
      Crawler/buildtemplate.html
  4. 75
      Crawler/play.html

@ -20,4 +20,5 @@ enum class Attribute{
JUMP_TARGET_POS,
JUMP_ORIGINAL_POS,
RECOVERY_TIME,
SHOOT_ANIMATION_TIME,
};

@ -4,11 +4,19 @@
#include "Crawler.h"
#include "utils.h"
typedef Attribute A;
INCLUDE_game
INCLUDE_BULLET_LIST
void Monster::STRATEGY::TURRET(Monster&m,float fElapsedTime,int strategyNumber){
m.attackCooldownTimer=std::max(0.f,m.attackCooldownTimer-fElapsedTime);
if(m.F(A::SHOOT_ANIMATION_TIME)>0){
m.F(A::SHOOT_ANIMATION_TIME)=std::max(0.f,m.F(A::SHOOT_ANIMATION_TIME)-fElapsedTime);
if(m.F(A::SHOOT_ANIMATION_TIME)==0){
m.PerformIdleAnimation();
}
}
if(m.queueShotTimer>0){
m.queueShotTimer-=fElapsedTime;
@ -23,6 +31,7 @@ void Monster::STRATEGY::TURRET(Monster&m,float fElapsedTime,int strategyNumber){
if(m.attackCooldownTimer==0){
m.attackCooldownTimer=ConfigFloat("ShootingSpeed");
m.queueShotTimer=std::min(m.attackCooldownTimer-0.001,0.3);
m.F(A::SHOOT_ANIMATION_TIME)=ConfigIntArr("ShootAnimation",0)*ConfigFloatArr("ShootAnimation",1);
m.PerformShootAnimation();
}
}

@ -35,7 +35,7 @@ var Module = {
})(),
};
</script>
<script async type="text/javascript" src="pge.js"></script>
<script async type="text/javascript" src="_REPLACEME_"></script>
<script type="text/javascript">
Module.canvas.addEventListener("resize", (e) => {

@ -0,0 +1,75 @@
<!doctype html>
<html lang="en-us">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta charset="utf-8">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Emscripten-Generated Code</title>
<style>
html,body { width: 100%; height: 100%; }
body { font-family: arial; margin: 0; padding: 0; background: #000; }
.emscripten { padding-right: 0; margin-left: auto; margin-right: auto; display: block; }
div.emscripten_border { border: none; }
/* the canvas *must not* have any border or padding, or mouse coords will be wrong */
canvas.emscripten { border: 0px none; background-color: black; }
</style>
</head>
<body>
<canvas class="emscripten" id="canvas" oncontextmenu="event.preventDefault()" tabindex=-1></canvas>
<script type='text/javascript'>
var Module = {
preRun: [],
postRun: [],
canvas: (function() {
var canvas = document.getElementById('canvas');
// As a default initial behavior, pop up an alert when webgl context is lost. To make your
// application robust, you may want to override this behavior before shipping!
// See http://www.khronos.org/registry/webgl/specs/latest/1.0/#5.15.2
canvas.addEventListener("webglcontextlost", function(e) { alert('WebGL context lost. You will need to reload the page.'); e.preventDefault(); }, false);
return canvas;
})(),
};
</script>
<script async type="text/javascript" src="pge.js"></script>
<script type="text/javascript">
Module.canvas.addEventListener("resize", (e) => {
var viewWidth = e.detail.width;
var viewHeight = e.detail.width / Module._olc_WindowAspectRatio;
if(viewHeight > e.detail.height)
{
viewHeight = e.detail.height;
viewWidth = e.detail.height * Module._olc_WindowAspectRatio;
}
// update dom attributes
Module.canvas.setAttribute("width", viewWidth);
Module.canvas.setAttribute("height", viewHeight);
var top = (e.detail.height - viewHeight) / 2;
var left = (e.detail.width - viewWidth) / 2;
// update styles
Module.canvas.style.position = "fixed";
Module.canvas.style.top = top.toString() + "px";
Module.canvas.style.left = left.toString() + "px";
Module.canvas.style.width = "";
Module.canvas.style.height = "";
// trigger PGE update
Module._olc_PGE_UpdateWindowSize(viewWidth, viewHeight);
// ensure canvas has focus
Module.canvas.focus();
e.preventDefault();
});
</script>
</body>
</html>
Loading…
Cancel
Save