• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

HTML5

T

ThePropagation

Guest
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.
 
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.
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:
T

ThePropagation

Guest
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
 
T

ThePropagation

Guest
So I just added the .00 to try to make it more compatible, should I just do string_format(alpha, 1 , 1)?
 
T

ThePropagation

Guest
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.
 
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?
 
T

ThePropagation

Guest
alpha = real(string_format(alpha, 1, 3));
This made the game worse ^

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

ThePropagation

Guest
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 ==
 
T

ThePropagation

Guest
ARG, I spent $100 on the Web module they should have support for this
 

FrostyCat

Redemption Seeker
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.
 
T

ThePropagation

Guest
upload_2019-8-13_17-12-4.png

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

FrostyCat

Redemption Seeker
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.
 
T

ThePropagation

Guest
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.
 
T

ThePropagation

Guest
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?
 
Top