Skip to content

Commit 37ad2fc

Browse files
committed
Adjust canvas position when on desktop
1 parent 668558d commit 37ad2fc

File tree

5 files changed

+28
-20
lines changed

5 files changed

+28
-20
lines changed

Gruntfile.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ module.exports = function (grunt) {
173173
},
174174
nwjs: {
175175
options: {
176-
version: 'v0.14.0',
176+
version: 'v0.14.5',
177177
platforms: ['osx64'],
178178
buildDir: './webkitbuilds',
179179
},

css/main.css

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@
1515
padding: 0;
1616
cursor: default;
1717
}
18-
body, html {
19-
margin:0;
20-
padding: 0;
21-
overflow:hidden;
22-
height: 100%;
23-
font-family: 'Jura', Arial, sans-serif;
24-
font-size:20px
18+
body, html {
19+
margin:0;
20+
padding: 0;
21+
overflow:hidden;
22+
height: 100%;
23+
font-family: 'Jura', Arial, sans-serif;
24+
font-size: 20px
2525
}
2626
body, html {
2727
background: rgb(224,226,228); /* Old browsers */
@@ -32,7 +32,7 @@ body, html {
3232
background: -ms-linear-gradient(top, rgba(224,226,228,1) 0%,rgba(185,187,189,1) 100%); /* IE10+ */
3333
background: linear-gradient(to bottom, rgba(224,226,228,1) 0%,rgba(185,187,189,1) 100%); /* W3C */
3434
}
35-
#game {
35+
#game {
3636
position: absolute;
3737
top: 0;
3838
left: 50%;
@@ -43,14 +43,17 @@ body, html {
4343
transform: translate(-50%, 0%);
4444
width: 400px;
4545
height: 640px;
46-
border: 1px solid #999;
47-
color:white;
46+
border: 1px solid #999;
47+
color:white;
4848
-webkit-box-shadow: 0px 0px 32px 0px rgba(0, 0, 0, .5);
4949
box-shadow: 0px 0px 32px 0px rgba(0, 0, 0, .5);
5050
}
51+
.canvas-pos {
52+
top: 15% !important;
53+
}
5154
p.sorry {
5255
margin: 0 auto;
5356
text-align: center;
5457
font-size: 12px;
5558
visibility: hidden;
56-
}
59+
}

index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
<% } else if (environment !== 'crx') { %>
1919
<script src="lib/gj-js-api.js"></script>
2020
<% } %>
21-
/build -->
21+
/build -->
2222
<!-- build:js:dist,crx lib/crafty-min.js -->
2323
<script src="lib/crafty.js"></script>
2424
<!-- /build -->
@@ -28,4 +28,4 @@
2828
<!-- build:include:dist urch -->
2929
<!-- /build -->
3030
</body>
31-
</html>
31+
</html>

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "Strider",
2+
"name": "nw-demo",
33
"description": "Strider is a 2D sci-fi platformer game.",
44
"version": "1.0.6",
55
"private": true,

src/loader.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@
1010
(function(Crafty) {
1111
document.addEventListener('DOMContentLoaded', function () {
1212

13+
if (typeof require !== 'undefined') {
14+
var el = document.getElementById('game');
15+
el.className = 'canvas-pos';
16+
}
17+
1318
var isSafari = !!navigator.userAgent.match(/Version\/[\d\.]+.*Safari/);
1419
var STAGE_WIDTH = 400,
1520
STAGE_HEIGHT = 640,
@@ -19,9 +24,9 @@
1924
Crafty.init(STAGE_WIDTH, STAGE_HEIGHT, screen);
2025
// Crafty.canvas.init();
2126
Crafty.viewport.init(STAGE_WIDTH, STAGE_HEIGHT, screen);
22-
Crafty.viewport.bounds = {
23-
min: { x:-100, y: -Infinity },
24-
max: { x: STAGE_WIDTH + 50, y: STAGE_HEIGHT }
27+
Crafty.viewport.bounds = {
28+
min: { x:-100, y: -Infinity },
29+
max: { x: STAGE_WIDTH + 50, y: STAGE_HEIGHT }
2530
};
2631
// Crafty.viewport.clampToEntities = true;
2732
Crafty.settings.modify('autoPause', true);
@@ -75,7 +80,7 @@
7580

7681
Crafty.paths({ audio: "assets/sfx/", images: "assets/images/" });
7782
var assets = {
78-
images: ['splash_screen.jpg', 'splash_screen_blurred.jpg', 'cratfy_logo.png', 'gameoff.jpg', 'wall01.png',
83+
images: ['splash_screen.jpg', 'splash_screen_blurred.jpg', 'cratfy_logo.png', 'gameoff.jpg', 'wall01.png',
7984
'backgrounds.png', 'starsky.png', 'audioOn.png', 'audioOff.png', 'musicOn.png', 'musicOff.png'],
8085
sprites: {
8186
'ui_energy.png': {
@@ -240,4 +245,4 @@
240245
});
241246

242247
}); //eof-ready
243-
}(Crafty));
248+
}(Crafty));

0 commit comments

Comments
 (0)