full screen - web
This commit is contained in:
parent
e1287b5005
commit
e0836bb7fa
|
|
@ -1,3 +1,5 @@
|
|||
|
||||
/target
|
||||
*.log
|
||||
executor-wasm/assets
|
||||
executor-wasm/data
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<meta name="viewport" content="user-scalable=no, height=device-height, width=device-width, initial-scale=1.0">
|
||||
<title>My Game</title>
|
||||
|
||||
<link rel="stylesheet" href="styles.css" />
|
||||
|
|
@ -17,4 +17,26 @@
|
|||
</button>
|
||||
</main>
|
||||
</body>
|
||||
<script>
|
||||
const intervalId = setInterval(function() {
|
||||
if (document.querySelector('canvas') !== null) {
|
||||
document.querySelector('canvas');
|
||||
clearInterval(intervalId);
|
||||
resize(document.querySelector('canvas'));
|
||||
}
|
||||
}, 1000);
|
||||
new ResizeObserver(() => {
|
||||
const canvasObj = document.querySelector('canvas')
|
||||
if (canvasObj == null) {
|
||||
return;
|
||||
}
|
||||
resize(canvasObj);
|
||||
}).observe(document.body);
|
||||
|
||||
function resize(canvasObj) {
|
||||
canvasObj.style = null;
|
||||
canvasObj.width = window.screen.width;
|
||||
canvasObj.height = window.screen.height;
|
||||
}
|
||||
</script>
|
||||
</html>
|
||||
|
|
|
|||
|
|
@ -1599,68 +1599,68 @@ function __wbg_get_imports() {
|
|||
const ret = wasm.memory;
|
||||
return addHeapObject(ret);
|
||||
};
|
||||
imports.wbg.__wbindgen_closure_wrapper10072 = function(arg0, arg1, arg2) {
|
||||
const ret = makeMutClosure(arg0, arg1, 9474, __wbg_adapter_32);
|
||||
imports.wbg.__wbindgen_closure_wrapper10083 = function(arg0, arg1, arg2) {
|
||||
const ret = makeMutClosure(arg0, arg1, 9481, __wbg_adapter_32);
|
||||
return addHeapObject(ret);
|
||||
};
|
||||
imports.wbg.__wbindgen_closure_wrapper10073 = function(arg0, arg1, arg2) {
|
||||
const ret = makeMutClosure(arg0, arg1, 9474, __wbg_adapter_32);
|
||||
imports.wbg.__wbindgen_closure_wrapper10084 = function(arg0, arg1, arg2) {
|
||||
const ret = makeMutClosure(arg0, arg1, 9481, __wbg_adapter_32);
|
||||
return addHeapObject(ret);
|
||||
};
|
||||
imports.wbg.__wbindgen_closure_wrapper10074 = function(arg0, arg1, arg2) {
|
||||
const ret = makeMutClosure(arg0, arg1, 9474, __wbg_adapter_37);
|
||||
imports.wbg.__wbindgen_closure_wrapper10085 = function(arg0, arg1, arg2) {
|
||||
const ret = makeMutClosure(arg0, arg1, 9481, __wbg_adapter_37);
|
||||
return addHeapObject(ret);
|
||||
};
|
||||
imports.wbg.__wbindgen_closure_wrapper10075 = function(arg0, arg1, arg2) {
|
||||
const ret = makeMutClosure(arg0, arg1, 9474, __wbg_adapter_32);
|
||||
imports.wbg.__wbindgen_closure_wrapper10086 = function(arg0, arg1, arg2) {
|
||||
const ret = makeMutClosure(arg0, arg1, 9481, __wbg_adapter_32);
|
||||
return addHeapObject(ret);
|
||||
};
|
||||
imports.wbg.__wbindgen_closure_wrapper10076 = function(arg0, arg1, arg2) {
|
||||
const ret = makeMutClosure(arg0, arg1, 9474, __wbg_adapter_32);
|
||||
imports.wbg.__wbindgen_closure_wrapper10087 = function(arg0, arg1, arg2) {
|
||||
const ret = makeMutClosure(arg0, arg1, 9481, __wbg_adapter_32);
|
||||
return addHeapObject(ret);
|
||||
};
|
||||
imports.wbg.__wbindgen_closure_wrapper10077 = function(arg0, arg1, arg2) {
|
||||
const ret = makeMutClosure(arg0, arg1, 9474, __wbg_adapter_44);
|
||||
imports.wbg.__wbindgen_closure_wrapper10088 = function(arg0, arg1, arg2) {
|
||||
const ret = makeMutClosure(arg0, arg1, 9481, __wbg_adapter_44);
|
||||
return addHeapObject(ret);
|
||||
};
|
||||
imports.wbg.__wbindgen_closure_wrapper10078 = function(arg0, arg1, arg2) {
|
||||
const ret = makeMutClosure(arg0, arg1, 9474, __wbg_adapter_32);
|
||||
imports.wbg.__wbindgen_closure_wrapper10089 = function(arg0, arg1, arg2) {
|
||||
const ret = makeMutClosure(arg0, arg1, 9481, __wbg_adapter_32);
|
||||
return addHeapObject(ret);
|
||||
};
|
||||
imports.wbg.__wbindgen_closure_wrapper17891 = function(arg0, arg1, arg2) {
|
||||
const ret = makeMutClosure(arg0, arg1, 13684, __wbg_adapter_49);
|
||||
imports.wbg.__wbindgen_closure_wrapper17902 = function(arg0, arg1, arg2) {
|
||||
const ret = makeMutClosure(arg0, arg1, 13691, __wbg_adapter_49);
|
||||
return addHeapObject(ret);
|
||||
};
|
||||
imports.wbg.__wbindgen_closure_wrapper19740 = function(arg0, arg1, arg2) {
|
||||
const ret = makeMutClosure(arg0, arg1, 14498, __wbg_adapter_52);
|
||||
imports.wbg.__wbindgen_closure_wrapper19751 = function(arg0, arg1, arg2) {
|
||||
const ret = makeMutClosure(arg0, arg1, 14505, __wbg_adapter_52);
|
||||
return addHeapObject(ret);
|
||||
};
|
||||
imports.wbg.__wbindgen_closure_wrapper19741 = function(arg0, arg1, arg2) {
|
||||
const ret = makeMutClosure(arg0, arg1, 14498, __wbg_adapter_52);
|
||||
imports.wbg.__wbindgen_closure_wrapper19752 = function(arg0, arg1, arg2) {
|
||||
const ret = makeMutClosure(arg0, arg1, 14505, __wbg_adapter_52);
|
||||
return addHeapObject(ret);
|
||||
};
|
||||
imports.wbg.__wbindgen_closure_wrapper19742 = function(arg0, arg1, arg2) {
|
||||
const ret = makeMutClosure(arg0, arg1, 14498, __wbg_adapter_52);
|
||||
imports.wbg.__wbindgen_closure_wrapper19753 = function(arg0, arg1, arg2) {
|
||||
const ret = makeMutClosure(arg0, arg1, 14505, __wbg_adapter_52);
|
||||
return addHeapObject(ret);
|
||||
};
|
||||
imports.wbg.__wbindgen_closure_wrapper19743 = function(arg0, arg1, arg2) {
|
||||
const ret = makeMutClosure(arg0, arg1, 14498, __wbg_adapter_59);
|
||||
imports.wbg.__wbindgen_closure_wrapper19754 = function(arg0, arg1, arg2) {
|
||||
const ret = makeMutClosure(arg0, arg1, 14505, __wbg_adapter_59);
|
||||
return addHeapObject(ret);
|
||||
};
|
||||
imports.wbg.__wbindgen_closure_wrapper19744 = function(arg0, arg1, arg2) {
|
||||
const ret = makeMutClosure(arg0, arg1, 14498, __wbg_adapter_52);
|
||||
imports.wbg.__wbindgen_closure_wrapper19755 = function(arg0, arg1, arg2) {
|
||||
const ret = makeMutClosure(arg0, arg1, 14505, __wbg_adapter_52);
|
||||
return addHeapObject(ret);
|
||||
};
|
||||
imports.wbg.__wbindgen_closure_wrapper19745 = function(arg0, arg1, arg2) {
|
||||
const ret = makeMutClosure(arg0, arg1, 14498, __wbg_adapter_52);
|
||||
imports.wbg.__wbindgen_closure_wrapper19756 = function(arg0, arg1, arg2) {
|
||||
const ret = makeMutClosure(arg0, arg1, 14505, __wbg_adapter_52);
|
||||
return addHeapObject(ret);
|
||||
};
|
||||
imports.wbg.__wbindgen_closure_wrapper19746 = function(arg0, arg1, arg2) {
|
||||
const ret = makeMutClosure(arg0, arg1, 14498, __wbg_adapter_52);
|
||||
imports.wbg.__wbindgen_closure_wrapper19757 = function(arg0, arg1, arg2) {
|
||||
const ret = makeMutClosure(arg0, arg1, 14505, __wbg_adapter_52);
|
||||
return addHeapObject(ret);
|
||||
};
|
||||
imports.wbg.__wbindgen_closure_wrapper19874 = function(arg0, arg1, arg2) {
|
||||
const ret = makeMutClosure(arg0, arg1, 14569, __wbg_adapter_68);
|
||||
imports.wbg.__wbindgen_closure_wrapper19885 = function(arg0, arg1, arg2) {
|
||||
const ret = makeMutClosure(arg0, arg1, 14576, __wbg_adapter_68);
|
||||
return addHeapObject(ret);
|
||||
};
|
||||
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -15,6 +15,7 @@ body {
|
|||
position: relative;
|
||||
/* Need to exclude the scrollbar */
|
||||
min-width: calc(100vw - (100vw - 100%));
|
||||
min-height: calc(100vh - (100vh - 100%));
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
|
|
@ -27,6 +28,7 @@ body {
|
|||
flex-direction: column;
|
||||
}
|
||||
|
||||
|
||||
.button-3d {
|
||||
display: block;
|
||||
position: relative;
|
||||
|
|
|
|||
|
|
@ -29,6 +29,8 @@ impl ScriptTrait for Player {
|
|||
// Called once at initialization.
|
||||
fn on_init(&mut self, context: &mut ScriptContext) {
|
||||
self.init(context);
|
||||
self.window_height = 600;
|
||||
self.window_height = 800;
|
||||
}
|
||||
|
||||
// Put start logic - it is called when every other script is already initialized.
|
||||
|
|
@ -46,34 +48,38 @@ impl ScriptTrait for Player {
|
|||
if let WindowEvent::Touch(touch) = event {
|
||||
match touch.phase {
|
||||
TouchPhase::Started => {
|
||||
if touch.location.x > 400.0 {
|
||||
if touch.location.x > (self.window_width / 2) as f64 {
|
||||
self.key_checker(KeyCode::ArrowRight, true);
|
||||
self.key_checker(KeyCode::ArrowLeft, false);
|
||||
} else {
|
||||
self.key_checker(KeyCode::ArrowLeft, true);
|
||||
self.key_checker(KeyCode::ArrowRight, false);
|
||||
}
|
||||
if touch.location.y < 200.0 {
|
||||
if touch.location.y < (self.window_height / 2) as f64 {
|
||||
self.key_checker(KeyCode::ArrowUp, true);
|
||||
}
|
||||
if touch.location.y > 200.0 {
|
||||
if touch.location.y > (self.window_height / 2) as f64 {
|
||||
self.key_checker(KeyCode::ArrowUp, false);
|
||||
}
|
||||
},
|
||||
TouchPhase::Ended => {
|
||||
if touch.location.x > 400.0 {
|
||||
if touch.location.x > (self.window_width / 2) as f64 {
|
||||
self.key_checker(KeyCode::ArrowRight, false);
|
||||
} else {
|
||||
self.key_checker(KeyCode::ArrowLeft, false);
|
||||
}
|
||||
if touch.location.y < 200.0 {
|
||||
if touch.location.y < (self.window_height / 2) as f64 {
|
||||
self.key_checker(KeyCode::ArrowUp, false);
|
||||
}
|
||||
|
||||
},
|
||||
_ => {},
|
||||
}
|
||||
//Log::err(format!("{:?}", touch.location))
|
||||
}
|
||||
|
||||
if let WindowEvent::Resized(size) = event {
|
||||
self.window_height = size.height;
|
||||
self.window_width = size.width;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,6 +26,9 @@ pub struct Player {
|
|||
|
||||
start_y_position: f32,
|
||||
prev_y_velosity: f32,
|
||||
|
||||
pub window_height: u32, // TODO: need change place
|
||||
pub window_width: u32,
|
||||
}
|
||||
|
||||
impl TypeUuidProvider for Player {
|
||||
|
|
|
|||
Loading…
Reference in New Issue