generated from sigonasr2/CPlusPlusProjectTemplate
	Fix weirdness in web
Co-authored-by: sigonasr2 <sigonasr2@gmail.com>
This commit is contained in:
		
							parent
							
								
									b96b6bf4d0
								
							
						
					
					
						commit
						b34e4f6bcb
					
				| @ -1,3 +1,3 @@ | ||||
| build.sh:530634457ea9041267c05d4ced95eee1  - | ||||
| commit.sh:d03a46e721060c22ccb146e19d27e70a  - | ||||
| web.sh:3dcc2fe7e036359eedd257a864e9a1e1  - | ||||
| web.sh:12471564fd294d236285a94169470b60  - | ||||
|  | ||||
| @ -28,7 +28,7 @@ enum CUTSCENE{ | ||||
| #define ALPHA_SCREEN1 128 | ||||
| #define ALPHA_SCREEN2 20 | ||||
| #define FADE_SPD 6 | ||||
| #define MOVE_SPD 0.01 | ||||
| #define MOVE_SPD 0.4 | ||||
| 
 | ||||
| class Object{ | ||||
| 	public: | ||||
| @ -65,6 +65,7 @@ public: | ||||
| 	CUTSCENE CURRENT_CUTSCENE=PAN_DOME; | ||||
| 	int CUTSCENE_TIMER=0; | ||||
| 	bool CUTSCENE_FLAGS[8]; | ||||
| 	bool messageBoxVisible; | ||||
| 
 | ||||
| 	olc::Decal*DOME_DECAL; | ||||
| 	std::map<std::string,olc::Decal*> BASE_OBJECTS; | ||||
| @ -135,7 +136,7 @@ public: | ||||
| 		return true; | ||||
| 	} | ||||
| 
 | ||||
| 	bool GetAnyKey() { | ||||
| 	bool GetAnyKey() override {  | ||||
| 		switch (GAME_STATE) { | ||||
| 			case CUTSCENE_1:{ | ||||
| 				if (textInd>=STORY_TEXT1.length()) { | ||||
| @ -143,6 +144,7 @@ public: | ||||
| 				} | ||||
| 			}break; | ||||
| 		} | ||||
| 		return true; | ||||
| 	} | ||||
| 
 | ||||
| 	bool OnUserUpdate(float fElapsedTime) override | ||||
| @ -153,23 +155,6 @@ public: | ||||
| 			updateGame(); | ||||
| 		} | ||||
| 
 | ||||
| 		if (GetKey(olc::F1).bPressed) { | ||||
| 		} | ||||
| 		if (!CUTSCENE_ACTIVE) { | ||||
| 			if (GetKey(olc::D).bHeld||GetKey(olc::RIGHT).bHeld) { | ||||
| 				PLAYER_COORDS[0]=clamp(PLAYER_COORDS[0]+MOVE_SPD,0.0,(double)MAP_WIDTH); | ||||
| 			} | ||||
| 			if (GetKey(olc::A).bHeld||GetKey(olc::LEFT).bHeld) { | ||||
| 				PLAYER_COORDS[0]=clamp(PLAYER_COORDS[0]-MOVE_SPD,0.0,(double)MAP_WIDTH); | ||||
| 			} | ||||
| 			if (GetKey(olc::W).bHeld||GetKey(olc::UP).bHeld) { | ||||
| 				PLAYER_COORDS[1]=clamp(PLAYER_COORDS[1]-MOVE_SPD,0.0,(double)MAP_HEIGHT); | ||||
| 			} | ||||
| 			if (GetKey(olc::S).bHeld||GetKey(olc::DOWN).bHeld) { | ||||
| 				PLAYER_COORDS[1]=clamp(PLAYER_COORDS[1]+MOVE_SPD,0.0,(double)MAP_HEIGHT); | ||||
| 			} | ||||
| 		} | ||||
| 
 | ||||
| 		drawGame(); | ||||
| 		// called once per frame
 | ||||
| 		return true; | ||||
| @ -229,6 +214,25 @@ public: | ||||
| 				fadeInCompleted(); | ||||
| 			} | ||||
| 		} | ||||
| 
 | ||||
| 		if (GetKey(olc::F1).bPressed) { | ||||
| 		} | ||||
| 		 | ||||
| 		if (!CUTSCENE_ACTIVE) { | ||||
| 			if (GetKey(olc::D).bHeld||GetKey(olc::RIGHT).bHeld) { | ||||
| 				PLAYER_COORDS[0]=clamp(PLAYER_COORDS[0]+MOVE_SPD,0.0,(double)MAP_WIDTH); | ||||
| 			} | ||||
| 			if (GetKey(olc::A).bHeld||GetKey(olc::LEFT).bHeld) { | ||||
| 				PLAYER_COORDS[0]=clamp(PLAYER_COORDS[0]-MOVE_SPD,0.0,(double)MAP_WIDTH); | ||||
| 			} | ||||
| 			if (GetKey(olc::W).bHeld||GetKey(olc::UP).bHeld) { | ||||
| 				PLAYER_COORDS[1]=clamp(PLAYER_COORDS[1]-MOVE_SPD,0.0,(double)MAP_HEIGHT); | ||||
| 			} | ||||
| 			if (GetKey(olc::S).bHeld||GetKey(olc::DOWN).bHeld) { | ||||
| 				PLAYER_COORDS[1]=clamp(PLAYER_COORDS[1]+MOVE_SPD,0.0,(double)MAP_HEIGHT); | ||||
| 			} | ||||
| 		} | ||||
| 
 | ||||
| 		switch (GAME_STATE) { | ||||
| 			case CUTSCENE_1: | ||||
| 			case CUTSCENE_3:{ | ||||
| @ -294,9 +298,9 @@ public: | ||||
| 			case CUTSCENE_1:{ | ||||
| 				DrawStringDecal({16,16},CUTSCENE_CONSOLE_TEXT,olc::GREEN,{1,1}); | ||||
| 				if (textInd<STORY_TEXT1.length()) { | ||||
| 					FillRectDecal({16+(cursorX)*8%(WIDTH-32),8+GetTextSize(CUTSCENE_CONSOLE_TEXT).y+((cursorX==28)?8:0)},{4,8},olc::GREEN); | ||||
| 					FillRectDecal({(float)(16+(cursorX)*8%(WIDTH-32)),(float)(8+GetTextSize(CUTSCENE_CONSOLE_TEXT).y+((cursorX==28)?8:0))},{4,8},olc::GREEN); | ||||
| 				} else { | ||||
| 					FillRectDecal({16+(cursorX)*8%(WIDTH-32),8+GetTextSize(CUTSCENE_CONSOLE_TEXT).y+((cursorX==28)?8:0)},{4,8},olc::Pixel(0,255,0,(0.5*sin(frameCount*4/60.0)+0.5)*256)); | ||||
| 					FillRectDecal({(float)(16+(cursorX)*8%(WIDTH-32)),(float)(8+GetTextSize(CUTSCENE_CONSOLE_TEXT).y+((cursorX==28)?8:0))},{4,8},olc::Pixel(0,255,0,(0.5*sin(frameCount*4/60.0)+0.5)*256)); | ||||
| 				} | ||||
| 				GradientFillRectDecal({0,0},{WIDTH/2,HEIGHT/2},{20, 28, 22,ALPHA_SCREEN1},{20, 28, 22,ALPHA_SCREEN1},{20, 28, 22,ALPHA_SCREEN2},{20, 28, 22,ALPHA_SCREEN1}); | ||||
| 				GradientFillRectDecal({WIDTH/2,0},{WIDTH/2,HEIGHT/2},{20, 28, 22,ALPHA_SCREEN1},{20, 28, 22,ALPHA_SCREEN2},{20, 28, 22,ALPHA_SCREEN1},{20, 28, 22,ALPHA_SCREEN1}); | ||||
| @ -310,9 +314,9 @@ public: | ||||
| 			case CUTSCENE_3:{ | ||||
| 				DrawStringDecal({48,16},CUTSCENE_CONSOLE_TEXT,olc::Pixel(100, 10, 255),{2,2}); | ||||
| 				if (textInd<STORY_TEXT2.length()) { | ||||
| 					FillRectDecal({48+(cursorX)*16%(WIDTH-32),GetTextSize(CUTSCENE_CONSOLE_TEXT).y*2+((cursorX==28)?16:0)},{4*2,8*2},olc::Pixel(100, 10, 255)); | ||||
| 					FillRectDecal({(float)(48+(cursorX)*16%(WIDTH-32)),(float)(GetTextSize(CUTSCENE_CONSOLE_TEXT).y*2+((cursorX==28)?16:0))},{4*2,8*2},olc::Pixel(100, 10, 255)); | ||||
| 				} else { | ||||
| 					FillRectDecal({48+(cursorX)*16%(WIDTH-32),GetTextSize(CUTSCENE_CONSOLE_TEXT).y*2+((cursorX==28)?16:0)},{4*2,8*2},olc::Pixel(100, 10, 255,(0.5*sin(frameCount*4/60.0)+0.5)*256)); | ||||
| 					FillRectDecal({(float)(48+(cursorX)*16%(WIDTH-32)),(float)(GetTextSize(CUTSCENE_CONSOLE_TEXT).y*2+((cursorX==28)?16:0))},{4*2,8*2},olc::Pixel(100, 10, 255,(0.5*sin(frameCount*4/60.0)+0.5)*256)); | ||||
| 				} | ||||
| 				GradientFillRectDecal({0,0},{WIDTH/2,HEIGHT/2},{100, 10, 255,ALPHA_SCREEN1},{100, 10, 255,ALPHA_SCREEN1},{100, 10, 255,ALPHA_SCREEN2},{100, 10, 255,ALPHA_SCREEN1}); | ||||
| 				GradientFillRectDecal({WIDTH/2,0},{WIDTH/2,HEIGHT/2},{100, 10, 255,ALPHA_SCREEN1},{100, 10, 255,ALPHA_SCREEN2},{100, 10, 255,ALPHA_SCREEN1},{100, 10, 255,ALPHA_SCREEN1}); | ||||
|  | ||||
							
								
								
									
										
											BIN
										
									
								
								Seasons_of_Loneliness.data
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								Seasons_of_Loneliness.data
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| After Width: | Height: | Size: 24 KiB | 
							
								
								
									
										75
									
								
								Seasons_of_Loneliness.html
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										75
									
								
								Seasons_of_Loneliness.html
									
									
									
									
									
										Normal file
									
								
							| @ -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="Seasons_of_Loneliness.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> | ||||
							
								
								
									
										1
									
								
								Seasons_of_Loneliness.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								Seasons_of_Loneliness.js
									
									
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								Seasons_of_Loneliness.wasm
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								Seasons_of_Loneliness.wasm
									
									
									
									
									
										Executable file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										35
									
								
								data.h
									
									
									
									
									
								
							
							
						
						
									
										35
									
								
								data.h
									
									
									
									
									
								
							| @ -16,6 +16,41 @@ std::string STORY_TEXT2=R"(  SEASONS | ||||
|    -of- | ||||
| LONELINESS)"; | ||||
| 
 | ||||
| std::string STORY_DIALOG[]={R"( | ||||
| ??? | ||||
| RAIN CYCLE COMMENCING)", //0 | ||||
| R"( | ||||
| $PLAYER | ||||
| Phew, thank goodness these came up just in time!)", //1 | ||||
| R"( | ||||
| CompU-16770 | ||||
| RAIN CYCLE ENDING. NEXT RAIN CYCLE DUE IN 17 TERRESTIAL CYCLES.)", //2 | ||||
| R"( | ||||
| $PLAYER | ||||
| I wonder how the air is today..)", //3 | ||||
| R"( | ||||
| CompU-16770 | ||||
| RAIN CYCLE ENDING. NEXT RAIN CYCLE DUE IN 17 TERRESTIAL CYCLES.)",//4 | ||||
| R"( | ||||
| $PLAYER | ||||
| Hmm, an actual good day!)",//5 | ||||
| R"( | ||||
| $PLAYER | ||||
| The winds must have kicked in early. Better go out and work on R.O.V.E.R..)",//6 | ||||
| R"( | ||||
| $PLAYER | ||||
| I almost have the receiving unit repaired, I just need another good vein of silicon and we can finish this.)",//7 | ||||
| R"( | ||||
| $PLAYER | ||||
| Hmmm...)",//8 | ||||
| R"( | ||||
| $PLAYER | ||||
| So those dust columns only form around large hole deposits. This is usually where volcanic activity subsides, and usually dense rich in minerals!)",//9 | ||||
| R"( | ||||
| $PLAYER | ||||
| We'll head there.)",//10 | ||||
| };  | ||||
| 
 | ||||
| olc::Pixel TILE_COLORS[3]={ | ||||
|     olc::Pixel(112, 88, 64), | ||||
|     olc::Pixel(60, 97, 49), | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user