Author Topic: SGDK2 through WinRT Issues  (Read 8609 times)

v6v

  • Clever
  • Fanatic
  • ***
  • Posts: 500
  • Has renamed his project to Galaxy!
    • View Profile
    • My Developer Page!
    • Email
SGDK2 through WinRT Issues
« on: 2013-02-05, 09:25:10 PM »
Made a game for a class project for SGDK2 (I've been so busy working on graded games that I can't even work my own), ported it to windows 8 as a metro application running with html5 under winrt and it ran great.

The problem is, it didn't fill the entire screen. There was a portion of the map that wasn't drawn to, despite the resolution.


So I've been looking into the SGDK2 code for html5 projects, how exactly is the screen size handled?

I've set the canvas that html5 draws to into a viewbox container div, http://msdn.microsoft.com/en-us/library/windows/apps/br229771.aspx

The viewbox scales the entire game, but doesn't remove the undrawn space, and scales that too. This leads me to believe it may be SGDK2 related.

Is there a better way to scale the canvas by a preset factor? Resolutions don't seem to mean much in HTML5 Export.

Has anyone here touched Windows 8? It's remarkably easy to convert a SGDK2 game to a metro app, inside of VS 11 or VS Blend.

Added to that, Scrilla (Typo?) Construct has an export to Windows 8 Metro feature. This could be added easily to SGDK2, right?
« Last Edit: 2013-02-05, 09:34:07 PM by #Sharp »

bluemonkmn

  • SGDK Author
  • Administrator
  • Fanatic
  • *****
  • Posts: 2761
    • ICQ Messenger - 2678251
    • MSN Messenger - BlueMonkMN@gmail.com
    • View Profile
    • http://sgdk2.sf.net/
    • Email
Re: SGDK2 through WinRT Issues
« Reply #1 on: 2013-02-06, 05:46:09 AM »
Wow, that's great to hear for the most part. The size of the game display is controlled by the resolution that you specify in the project settings, and the HTML5 output uses the following code to enforce it.
Near the top of the HTML content:
Code: [Select]
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no"/>
At the canvas tag in the HTML content:
Code: [Select]
<canvas id="gameView" width="640" height="480" unselectable="on" class="unselectable">
In the template.html file in the project's SourceCode folder, they appear similarly, but the second one looks like:
Code: [Select]
<canvas id="gameView" width="<!--#echo var="Width" -->" height="<!--#echo var="Height" -->" unselectable="on" class="unselectable">
With that information can you take control of the aspects you need to by editing the HTML file in your project's SourceCode folder (maybe remove the meta tag)? Or is that essentially the same as what you've already tried?

What does/would the "Export to Windows 8 Metro" do?
Also, can you figure out how to post a screenshot of what you're seeing? It's a little hard to understand.
« Last Edit: 2013-02-06, 06:07:40 AM by bluemonkmn »

v6v

  • Clever
  • Fanatic
  • ***
  • Posts: 500
  • Has renamed his project to Galaxy!
    • View Profile
    • My Developer Page!
    • Email
Re: SGDK2 through WinRT Issues
« Reply #2 on: 2013-02-06, 10:50:00 AM »
http://www.youtube.com/watch?v=aaijqsCym6c

Those are the lines of code that I tried, as well.

Look at the side of the screen, where the cursor repeats, that's what I mean.

As for export to metro, the main difference between a regular SGDK2 HTML5 application and a Win 8 HTML5 application from what I see seem to be an additional external css file and references to WinRT JS in the HTML header, as well as an Xaml file with a unique application ID and other application properties, more resembling Android's application config XML file than DotNet's app.config .

I believe Game Maker and Construct's Export buttons export a project directly to consideration by Microsoft in an html5 windows store format, prompting you for a developer license ID, but this is unnecessary, because they both assume that you've debugged the games under PC before exporting. SGDK2 could just export it for debugging on the user's system as a Windows app without submitting.

If the user was running SGDK2 in Win8, it could be done, the only part I don't get is how you would tell SGDK2 to deploy it- or where the user would search for it to deploy it themselves. I can't seem to find a single Metro app  in the filesystem, and the are usually installed for me when I press F5 in Blend or Visual Studio 11.. I'm not sure if SGDK2 would be able to allow you to build for Windows Store/Metro seeing as I had to obtain a developer license from them just to run my own games (Only licensed developers can run Metro applications that aren't pre approved by Microsoft, thanks to their new security model - whatever this means..)

It would probably take a large amount of hacking and Microsoft could file a cease and desist, so thinking about it now, it doesn't seem as good of an idea as it seemed yesterday..

Of course it could just be integrated, if a person already has VS 11 or Blend, SGDK2 could just generate an html file with appropriate html header in the same directory with a Windows Store project overwriting the default html file generated for a windows store html app, there would be no conflicts there.

I like that option, actually.
« Last Edit: 2013-02-06, 02:21:49 PM by #Sharp »

bluemonkmn

  • SGDK Author
  • Administrator
  • Fanatic
  • *****
  • Posts: 2761
    • ICQ Messenger - 2678251
    • MSN Messenger - BlueMonkMN@gmail.com
    • View Profile
    • http://sgdk2.sf.net/
    • Email
Re: SGDK2 through WinRT Issues
« Reply #3 on: 2013-02-06, 05:37:15 PM »
It looks like you just didn't make your graphic large enough to fill the map/layer. Have you tried just using a larger image/layer to fill the blank space?

v6v

  • Clever
  • Fanatic
  • ***
  • Posts: 500
  • Has renamed his project to Galaxy!
    • View Profile
    • My Developer Page!
    • Email
Re: SGDK2 through WinRT Issues
« Reply #4 on: 2013-02-06, 06:41:15 PM »
That's just it, the graphic is 1024 by 768, the same size as the resolution I set...

It should be filling the screen entirely, shouldn't it?

bluemonkmn

  • SGDK Author
  • Administrator
  • Fanatic
  • *****
  • Posts: 2761
    • ICQ Messenger - 2678251
    • MSN Messenger - BlueMonkMN@gmail.com
    • View Profile
    • http://sgdk2.sf.net/
    • Email
Re: SGDK2 through WinRT Issues
« Reply #5 on: 2013-02-07, 05:49:23 AM »
It would only fill the screen if that resolution (1024x768) is also the resolution of the device you're using.

Have you checked the behavior with everything back to its normal setting, except remove the following piece from the meta tag?
Code: [Select]
, initial-scale=1.0, user-scalable=no
Or changing the viewport tag to match the width of the game:
Code: [Select]
<meta name="viewport" content="width=1024"/>
But I think the viewport tag only affects mobile devices. If you are expecting content to stretch on a desktop, something else will be required.
« Last Edit: 2013-02-07, 06:08:49 AM by bluemonkmn »

v6v

  • Clever
  • Fanatic
  • ***
  • Posts: 500
  • Has renamed his project to Galaxy!
    • View Profile
    • My Developer Page!
    • Email
Re: SGDK2 through WinRT Issues
« Reply #6 on: 2013-02-07, 11:39:10 AM »
I remember using the viewport property back when I was designing small hobby websites for the Nintendo DSi in 2009, and it restricted the view well on the Opera Mini browsers, but on desktop browsers, although it kept everything in the area designated by the viewport value (If that value was an int instead of device-width) it would fill the unused space with the html background image/background color.

The entire meta tag seems to be ignored..

I know this has to be SGDK2 because my css file was instructed to fill the background with a non black color- SGDK2 seems to fill the entire screen and is responsible for the black space I'm stuck with..

I wish there was a way to scale the <canvas> directly..
« Last Edit: 2013-02-07, 11:45:04 AM by #Sharp »

bluemonkmn

  • SGDK Author
  • Administrator
  • Fanatic
  • *****
  • Posts: 2761
    • ICQ Messenger - 2678251
    • MSN Messenger - BlueMonkMN@gmail.com
    • View Profile
    • http://sgdk2.sf.net/
    • Email
Re: SGDK2 through WinRT Issues
« Reply #7 on: 2013-02-07, 06:50:48 PM »
Actually, I've found if you want to stretch the canvas in an SGDK2 game, it works surprisingly well in Chrome to change the resizeView function as follows:

Code: [Select]
function resizeView() {
   var xScale = 1.5;
   var yScale = 1.5;
   viewWidth = window.innerWidth / xScale;
   viewHeight = window.innerHeight / yScale;
   var gameView = document.getElementById('gameView');
   gameView.width = window.innerWidth;
   gameView.height = window.innerHeight;
   if ((gameViewContext != null) && (currentMap != null))
   {
      currentMap.draw(gameViewContext);
      gameViewContext.scale(xScale, yScale);
   }
}

and then add a call to resizeView after the line that initially sets the value of gameViewContext;

v6v

  • Clever
  • Fanatic
  • ***
  • Posts: 500
  • Has renamed his project to Galaxy!
    • View Profile
    • My Developer Page!
    • Email
Re: SGDK2 through WinRT Issues
« Reply #8 on: 2013-02-07, 07:18:25 PM »
Glorious. It fixed it! Thanks for the homework help.

So SGDK2 is officially a Windows 8 game maker... in a way.

HTML5 is showing remarkable use for game development.
« Last Edit: 2013-02-07, 07:23:08 PM by #Sharp »

v6v

  • Clever
  • Fanatic
  • ***
  • Posts: 500
  • Has renamed his project to Galaxy!
    • View Profile
    • My Developer Page!
    • Email
Re: SGDK2 through WinRT Issues
« Reply #9 on: 2013-02-09, 03:22:44 PM »
It looks like ismousebuttonpressed isn't supported in HTML5?

I need a function that checks if the left mouse button (Or touch input) is being held down, and "clicked" only seems to return true only once..

Why exactly isn't mouse input handled well in HTML5?

https://docs.google.com/spreadsheet/pub?hl=en_US&key=0AuyO-2scTVuRdFBpTUZoM0NNRzhXVXdud1E5a3A4cFE&hl=en_US&gid=0

It also says SetInputState is untested, mind if I test it out a bit?

bluemonkmn

  • SGDK Author
  • Administrator
  • Fanatic
  • *****
  • Posts: 2761
    • ICQ Messenger - 2678251
    • MSN Messenger - BlueMonkMN@gmail.com
    • View Profile
    • http://sgdk2.sf.net/
    • Email
Re: SGDK2 through WinRT Issues
« Reply #10 on: 2013-02-19, 06:21:11 AM »
I suspect it's because there is no equivalent of a mouse button on a tablet -- there is just touching. So instead of that, I think the "Clicked" and "DragMap" functions were provided. Will something similar to either of those functions work for you?

v6v

  • Clever
  • Fanatic
  • ***
  • Posts: 500
  • Has renamed his project to Galaxy!
    • View Profile
    • My Developer Page!
    • Email
Re: SGDK2 through WinRT Issues
« Reply #11 on: 2013-03-01, 03:15:16 PM »
Clicked only returns true for one frame, then returns false. (There's the issue)

My project is over anyways. Instead, I'd like to continue this as portfolio filler.

I have one entire week to finish my games now, college spring break.

bluemonkmn

  • SGDK Author
  • Administrator
  • Fanatic
  • *****
  • Posts: 2761
    • ICQ Messenger - 2678251
    • MSN Messenger - BlueMonkMN@gmail.com
    • View Profile
    • http://sgdk2.sf.net/
    • Email
Re: SGDK2 through WinRT Issues
« Reply #12 on: 2013-03-04, 06:12:13 AM »
the MapMouseToSprite function will set a sprite's button1 to be pressed for as as long as the mouse button is down. Then you can use IsInputPressed. HTML5 uses mouseInfo.pressed to track the state of the mouse button. For future reference.