Jump to content


Photo

I say 1.0.163, "End tghe Game"


  • Please log in to reply
24 replies to this topic

#1 epilobello

epilobello

    GMC Member

  • New Member
  • 162 posts

Posted 06 November 2011 - 04:47 AM

In Windows, the game ends and closes. No problem!

In HTML, a screenshot is left on an open browser window.

Is there a way to close the browser window as well?

Obviously the player can click/close the tab or the entire browser. But why not have GM HTML5 do it?
  • 0

#2 Dangerous_Dave

Dangerous_Dave

    GMC Member

  • Global Moderators
  • 9276 posts
  • Version:Unknown

Posted 06 November 2011 - 07:53 AM

Every time javascript tries to close my browser window, I get a message "The current page is trying to close the window, continue?". That's almost more annoying than the fact that the game is trying to close the window.

General practice is that you don't include that option in the game. If they want to close the window, they will close the window.

But if you insist, just make your own extension. There's a few good tutorials around on making the extension, the javascript code you want is window.close().
  • 0

#3 NakedPaulToast

NakedPaulToast

    GM Studio/Mac/Win

  • GMC Member
  • 7198 posts
  • Version:GM:Studio

Posted 06 November 2011 - 03:04 PM

HTML5 games should absolutely never "game_end()".

Go to some flash portals, do what virtualy every flash games does; restart the game.
  • 3

#4 epilobello

epilobello

    GMC Member

  • New Member
  • 162 posts

Posted 07 November 2011 - 04:35 AM

HTML5 games should absolutely never "game_end()".

Go to some flash portals, do what virtualy every flash games does; restart the game.

That's good! I'll go with restarting the game.

Sheesh, I fat fingered "tghe"! Sorry about that.
Can't blame it on the winter glove because I had to take it off to use the touch screen keyboard.
  • 0

#5

  • Guests

Posted 07 November 2011 - 08:24 AM

End_Game simply stops the code, and is there for compatibility. It should never really be used, as if a user wants to quit, they'll simply change web page to somewhere else. This function is really there to shut down executables where the user can't easily kill the app.

#6 epilobello

epilobello

    GMC Member

  • New Member
  • 162 posts

Posted 07 November 2011 - 04:06 PM

End_Game simply stops the code, and is there for compatibility. It should never really be used, as if a user wants to quit, they'll simply change web page to somewhere else. This function is really there to shut down executables where the user can't easily kill the app.


Call this episode, "Stumbling into best practices." I have not delved in Flash or Browser games. GM HTML5 is my intro to these things.

Now that I've learned this, I will include it in my lecture notes.

And wouldn't you know it, I just tried to check the documentation and could not pop it up. Oh well! Might I suggest that the documentation say something about how to treat End_Game in HTML? Not that I read it, of course...but sometimes I do...after the fact, of course.

Now I have to figure out how to deal with an End_Game that restarts. The sequence of the learning activity was to have
1. watched a video,
2. work some exercises on paper and/or a game (this is where GM HTML5 comes in), then
3. fire up an evaluation session (a written quiz or a special game challenge)

Later on, I'd like to try using the interactive Smart Board ® for some in class gaming activity.
  • 0

#7 NakedPaulToast

NakedPaulToast

    GM Studio/Mac/Win

  • GMC Member
  • 7198 posts
  • Version:GM:Studio

Posted 07 November 2011 - 04:13 PM

Now I have to figure out how to deal with an End_Game that restarts. The sequence of the learning activity was to have


The simplest way is to just have a room display a menu, something that displays:
  • Play Game
  • Options
  • Instructions
  • Credits
What ever is appropriate for your game.

Then where you normally would have done an end_game(), just do a room_goto to the room that displays the menu.
  • 0

#8 benetonmovie

benetonmovie

    GMC Member

  • GMC Member
  • 1368 posts
  • Version:GM:Studio

Posted 07 November 2011 - 05:45 PM

Ok, everyone in this topic says end_game(), but isn't it game_end()?
  • 1

#9 Dark Matter

Dark Matter

    RPG Expert

  • GMC Member
  • 3196 posts
  • Version:GM:Studio

Posted 07 November 2011 - 05:48 PM

Ok, everyone in this topic says end_game(), but isn't it game_end()?

Yes.
  • 0

#10 Camman

Camman

    UnReal Software CEO

  • GMC Member
  • 634 posts
  • Version:GM:Studio

Posted 07 November 2011 - 05:50 PM

Ok, everyone in this topic says end_game(), but isn't it game_end()?


Yes, it is game_end();
  • 0

#11 Smarty

Smarty

    GMC Member

  • Retired Staff
  • 7218 posts
  • Version:GM:Studio

Posted 08 November 2011 - 06:27 PM

Now I have to figure out how to deal with an End_Game that restarts. The sequence of the learning activity was to have


The simplest way is to just have a room display a menu, something that displays:
  • Play Game
  • Options
  • Instructions
  • Credits
What ever is appropriate for your game.

Then where you normally would have done an end_game(), just do a room_goto to the room that displays the menu.

I think you'd have to solve this in a different spot than where the game_end() is, because the problem is not in the command itself, but in the reason why it is executed.

What you'd normally have, in a Windows game, is a menu with a Quit button. And that's a typical button to call game_end() when pressed. Since such a button makes no sense in an HTML5 environment, you should make sure it doesn't appear, or disappears, in a browser environment. If you want to make your game compatible with both Windows and HTML5, the solution would be to simply remove the Quit button at run time if the game runs in a browser. One could put this in its create event:

if (os_browser!=browser_not_a_browser) instance_destroy();

  • 0

#12 epilobello

epilobello

    GMC Member

  • New Member
  • 162 posts

Posted 08 November 2011 - 09:06 PM

One could put this in its create event:

if (os_browser!=browser_not_a_browser) instance_destroy();


Not familiar with os_browser. Is it an extension?
  • 0

#13 Smarty

Smarty

    GMC Member

  • Retired Staff
  • 7218 posts
  • Version:GM:Studio

Posted 08 November 2011 - 09:19 PM

Not familiar with os_browser. Is it an extension?

No, it's a new system variable under GM4HTML5 which tells you the type of browser the game is being run in, if any. The check above tells you that it is running in a browser.

Edit: correction.

Edited by Smarty, 08 November 2011 - 09:44 PM.

  • 0

#14 epilobello

epilobello

    GMC Member

  • New Member
  • 162 posts

Posted 09 November 2011 - 03:44 AM


Not familiar with os_browser. Is it an extension?

No, it's a new system variable under GM4HTML5 which tells you the type of browser the game is being run in, if any. The check above tells you that it is running in a browser.

Edit: correction.


Sweet! By looking it up under YoYo Functions, I found the answer to another post I put up on launching with Opera on an Android tablet.

At least now, I can test if it's Opera and if not, then give a nice user friendly prompt to switch browsers or die with "Your browser doesn't support HTML5 canvas."

Thank you!
  • 0

#15 Smarty

Smarty

    GMC Member

  • Retired Staff
  • 7218 posts
  • Version:GM:Studio

Posted 09 November 2011 - 06:46 AM

But Opera does support HTML5...?
  • 0

#16 Dangerous_Dave

Dangerous_Dave

    GMC Member

  • Global Moderators
  • 9276 posts
  • Version:Unknown

Posted 09 November 2011 - 07:09 AM

But Opera does support HTML5...?

It appears he wants to show the "Canvas not supported" message if it is *not* Opera. Not sure why <canvas>Canvas not supported!</canvas> isn't a better catchall solution...
  • 0

#17 Smarty

Smarty

    GMC Member

  • Retired Staff
  • 7218 posts
  • Version:GM:Studio

Posted 09 November 2011 - 09:13 AM

It appears he wants to show the "Canvas not supported" message if it is *not* Opera. Not sure why <canvas>Canvas not supported!</canvas> isn't a better catchall solution...

Ah, I misread it.

Let alone that to be able to actually display a message using from within the game requires canvas support... :whistle:
  • 0

#18 epilobello

epilobello

    GMC Member

  • New Member
  • 162 posts

Posted 09 November 2011 - 11:53 AM


It appears he wants to show the "Canvas not supported" message if it is *not* Opera. Not sure why <canvas>Canvas not supported!</canvas> isn't a better catchall solution...

Ah, I misread it.

Let alone that to be able to actually display a message using from within the game requires canvas support... :whistle:


I have been trying to find a way around "Canvas not supported". I realize it's going to pop up before GM HTML5 jscript launches. Nonetheless, because os_browser is there, I'm hoping to use it.

I tabled the issue of testing for a compatible browser last week. Although, proceeding in other areas of the project, has always been tempered by the lack of a compatibility test/re-route.
  • 0

#19 BorisE

BorisE

    GMC Member

  • New Member
  • 200 posts

Posted 09 November 2011 - 12:07 PM

I have been trying to find a way around "Canvas not supported". I realize it's going to pop up before GM HTML5 jscript launches. Nonetheless, because os_browser is there, I'm hoping to use it.

I think all that's needed is the CSS-fu to make the text show up white and maybe changing the text to something more helpfull. Also is it permissible to include markup between the canvas tags?
  • 0

#20 Smarty

Smarty

    GMC Member

  • Retired Staff
  • 7218 posts
  • Version:GM:Studio

Posted 09 November 2011 - 12:15 PM

I have been trying to find a way around "Canvas not supported". I realize it's going to pop up before GM HTML5 jscript launches. Nonetheless, because os_browser is there, I'm hoping to use it.

Well, look no further. Simply change the index.html file, because that's where the message is coming from:

<canvas id="canvas" width="www" height="hhh">
<p>Your browser doesn't support HTML5 canvas.</p>
</canvas>

You could put an alternate text, an image, an animation, a piece of Javascript and what have you in there.

I tabled the issue of testing for a compatible browser last week. Although, proceeding in other areas of the project, has always been tempered by the lack of a compatibility test/re-route.

Look, don't bother to worry about that. GM4HTML5 should be taking care to support all HTML5-capable browsers regardless of what's in your game, as long as the game keeps in line with the general limitations of running in a browser. If you sometimes find out that it doesn't, you can report that, because it will need to be fixed - typically a report of the "it works in browser A but not in browser B" kind. That's why the software is in beta, after all. Don't let that take away from your efforts to develop a game.

Eventually, your supported browser list message will be easy:

"HTML5 canvas not supported. Be sure to play this game in the latest versions of Internet Explorer, Chrome, FireFox, Opera or Safari."
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users