HTML5

Discussion in 'Programming' started by ThePropagation, Aug 13, 2019 at 3:36 AM.

Tags:
  1. ThePropagation

    ThePropagation Member

    Joined:
    May 16, 2017
    Posts:
    114
    I made an entire game that I'm putting on Kongregate. The game is finished, and I needed to change it into the HTML5 format in order to put it on the site. The game completely does not work now. I've never done HTML5 before, and I don't know what functions don't work in HTML5 that do in windows, and how to format my stuff and what settings to change in order to make it work. Is there a resource I can look at? I've googled it and looked in the manual and I'm having trouble. I know this isn't really a programming question unless anyone knows replacement code that works for HTML5. Thanks.

    Sorry, right now the splash screen comes up, doesn't play the sound, and clicking makes it fade to black and go to the next screen. It's still black, my fade doesn't alpha out but I hear the title screen music. Then it's frozen.
     
    SilentxxBunny likes this.
  2. SilentxxBunny

    SilentxxBunny Epsilon

    Joined:
    Jun 21, 2016
    Posts:
    62
    This is a vague question - so unfortunately I can only give you a vague answer (to start.) We'll get to the bottom of this. ;)

    https://help.yoyogames.com/hc/en-us/sections/115000309008-Web

    Have you seen this page before? If not - I'd start there.

    It links to several great tutorials (which might help you isolate the problem you're having.)

    Also - There might also be some helpful information in your browser's JavaScript Console (F12.)
     
    Last edited: Aug 13, 2019 at 4:23 AM
  3. ThePropagation

    ThePropagation Member

    Joined:
    May 16, 2017
    Posts:
    114
    So, I have a persistent fade object that works sometimes. The splash screen kind of works, the title screen doesn't show anything except a black screen but I click and it goes to the intro, the intro works fine, then it goes to the game screen and it's a black screen. The fade object works on the splash screen and intro screen, but not on the title or game screen, not sure how to make it work. Here's the code for the fade object.

    CREATE:
    Code:
    alpha = 1.00;
    layer = (layer_get_id("Fade"));
    DRAW:
    Code:
    if round(global.fade) = 0.00
    {
        if alpha > 0.00
        {
            alpha -= 0.025;
            audio_group_set_gain(Music, min(global.music, (1 - alpha)), 0);
        }
        else alpha = 0.00;
    }
    else
    {
        if alpha < 1.00
        {
            alpha += 0.025;
            audio_group_set_gain(Music, min(global.music, (1 - alpha)), 0);       
        }
        else
        {
            global.fade = 0;
            room_goto(global.destination);
        }
    }
    
    draw_set_alpha(alpha);
    draw_set_color(c_black);
    draw_rectangle(0, 0, room_width, room_height, 0);
    draw_set_alpha(1.00);
    WebGL needs to be enabled (I have color blends) and I know in HTML5 all numbers are doubles, is there any way I can force the number to be a whole integer? Round and Floor don't really work the way I want them to
     
  4. chmod777

    chmod777 Member

    Joined:
    Aug 26, 2016
    Posts:
    199
    I suppose the issue is related to float precision.

    Try to add this before draw_set_alpha:
    Code:
    alpha = real(string_format(alpha, 1, 3));
     
    SilentxxBunny likes this.
  5. ThePropagation

    ThePropagation Member

    Joined:
    May 16, 2017
    Posts:
    114
    So I just added the .00 to try to make it more compatible, should I just do string_format(alpha, 1 , 1)?
     
    SilentxxBunny likes this.
  6. ThePropagation

    ThePropagation Member

    Joined:
    May 16, 2017
    Posts:
    114
    But what I don't understand is it fades just fine on every other room. So I have a rmInitialize that creates all global variables for one frame then goes to rmSplash. rmSplash fades just fine. Then it goes to rmTitle, and fade doesn't work, but the music plays and clicking works. I click to go to rmIntro, where rmIntro works perfectly. After that fades to black and goes to the main game room, the game stays as a black screen.
     
    SilentxxBunny likes this.
  7. SilentxxBunny

    SilentxxBunny Epsilon

    Joined:
    Jun 21, 2016
    Posts:
    62
    This may be a stupid question, it's but I'm a stupid person. If it's a persistent object - did you remember to reset your variables?
     
  8. ThePropagation

    ThePropagation Member

    Joined:
    May 16, 2017
    Posts:
    114
    This made the game worse ^

    This is my ROOM START code
    Code:
    alpha = 1.00;
    layer = (layer_get_id("Fade"));
    
     
  9. ThePropagation

    ThePropagation Member

    Joined:
    May 16, 2017
    Posts:
    114
    Is JavaScript more strict about syntax than GML? Like do I need double equals for if statements? GML doesn't seem to care if i do = or ==
     
  10. SilentxxBunny

    SilentxxBunny Epsilon

    Joined:
    Jun 21, 2016
    Posts:
    62
  11. ThePropagation

    ThePropagation Member

    Joined:
    May 16, 2017
    Posts:
    114
    ARG, I spent $100 on the Web module they should have support for this
     
  12. SilentxxBunny

    SilentxxBunny Epsilon

    Joined:
    Jun 21, 2016
    Posts:
    62
    There is the help-desk, but I imagine a techno-wizard will be along shortly with the answers you're seeking. ;) This forum has some really smart folks on it - I'm just not one of them. Sorry.
     
  13. FrostyCat

    FrostyCat Member

    Joined:
    Jun 26, 2016
    Posts:
    4,301
    If you get a black screen on the HTML5 export, that usually means the JS runner is crashing. Run your game under debug with F6 and use the web developer tools that come with your browser to view the stack trace of the error. That should hint at where the problem is starting.
     
    SilentxxBunny likes this.
  14. ThePropagation

    ThePropagation Member

    Joined:
    May 16, 2017
    Posts:
    114
    I don't know how to do that, how do I access the stack trace
     
    SilentxxBunny likes this.
  15. ThePropagation

    ThePropagation Member

    Joined:
    May 16, 2017
    Posts:
    114
    upload_2019-8-13_17-12-4.png

    I guess this is what it shows I don't know what i'm looking for
     
  16. FrostyCat

    FrostyCat Member

    Joined:
    Jun 26, 2016
    Posts:
    4,301
    You can get a stacktrace by clicking on the dropdown caret (next to the red X icon) from any error message in the Console tab. I don't think the one in your screenshot is responsible for it, though.

    As for what's going on, I can see in your screenshot that it's trying to change rooms (not a perfectly black screen). If that's where it's getting stuck, make sure that the room to go to exists (e.g. you didn't put a string in room_goto()) and that there is actually a Fade layer in the room you are going to.

    And what is global.fade doing? If it's just a true-false flag, there is no need to compare to a value. Just if (global.fade) for true or if (!global.fade) for false.
     
    SilentxxBunny likes this.
  17. ThePropagation

    ThePropagation Member

    Joined:
    May 16, 2017
    Posts:
    114
    Everything is running fine but the camera! That's what was freezing my game? I need the camera to follow the player in the actual game though, what camera stuff doesn't work in HTML5? I used shaun spalding's custom smooth camera and camera shake tutorials to make it, I don't know what is wrong with it, here's the code:

    ROOM START
    Code:
    camera = camera_create();
    
    var vm = matrix_build_lookat(x, y, -10, x, y, 0, 0, 1, 0);
    var pm = matrix_build_projection_ortho(1280, 720, 1, 100000);
    
    camera_set_view_mat(camera, vm);
    camera_set_proj_mat(camera, pm);
    
    view_camera[0] = camera;
    
    follow = objFloor;
    
    x = follow.x;
    y = follow.y;
    
    xTo = x;
    yTo = y;
    
    shakeLength = 0;
    shakeMagnitude = 0;
    shakeRemain = 0;
    
    x = 640;
    y = room_height - 360;

    STEP:
    Code:
    xTo = follow.x;
    yTo = follow.y;
    
    x += (xTo - x) / 10;
    y += (yTo - y) / 10;
    
    if x < 640 x = 640;
    if x > (room_width - 640) x = (room_width - 640);
    if y < 360 y = 360;
    if y > (room_height - 360) y = (room_height - 360);
    
    x += random_range(-shakeRemain, shakeRemain);
    y += random_range(-shakeRemain, shakeRemain);
    
    shakeRemain = max(0, shakeRemain - ((1/shakeLength)*shakeMagnitude));
    
    var vm = matrix_build_lookat(x, y, -10, x, y, 0, 0, 1, 0);
    camera_set_view_mat(camera, vm);
    
    global.camLeft = x - 640;
    global.camRight = x + 640;
    global.camUp = y - 360;
    global.camDown = y + 360;

    Something is making it freeze in the Title screen and Game screen. When I set the camera consistent to false, the game runs fine, except it doesn't follow player.
     
    SilentxxBunny likes this.
  18. ThePropagation

    ThePropagation Member

    Joined:
    May 16, 2017
    Posts:
    114
    Are views messed up somehow in HTML5? I commented out

    view_camera[0] = camera;

    and the game works except i need the camera to follow the player. Is there another way to set the camera to view[0] or something?
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice