• 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!

How do I make my game work from windows to HTML5

C

Cmi

Guest
I was reading and article it said this "These differences will also vary depending on whether you have WebGL enabled for the target or not. In general, with WebGL enabled, your game should run almost exactly the same as it would for the other target modules like Windows."

I want to know if there is other ways to make your game run exactly the same as it would if the target was windows, because my game has been playing different (which I don't like).

Link to article I was reading: http://help.yoyogames.com/hc/en-us/articles/216754018-HTML5-Issues-And-Differences
 

jo-thijs

Member
I don't think so.

It is better to ask of specific things that work in windows how you would work around it in the HTML5 module.

What's not working?
 
C

Cmi

Guest
I don't think so.

It is better to ask of specific things that work in windows how you would work around it in the HTML5 module.

What's not working?
My enemy movements aren't working when I switch the target to HTML5. Like they are laggy. But when I change the target to Windows everything works normal.
 
C

Cmi

Guest
What's the object information of the enemy objects?
Code for my spawner

execute code:

// Wait 2 seconds and than trigger the alarm
alarm [1] = 60;
// Randomize the spawn
randomize();

Alarm Event for alarm 1:
execute code:

// Spawns the pie
instance_create(irandom_range(0,608),irandom_range(0,-32),obj_apple1)
// Repeat this code
alarm[1] = 60;

Step Event:
execute code:

// Check if the score is 5 to destory it
if (global.lvl1score == 5){
instance_destroy();
}

and now code for my object that spawns

execute code:

//set the enemy vspeed
obj_apple1.vspeed = 12;

Collision Event with object obj_player:
destroy the instance
Collision Event with object obj_groundborder:
execute code:

// Destory instance
instance_destroy();

set the number of lives relative to -1

That's my code for my spawner and object that spawns
 

jo-thijs

Member
Hm, I don't see any code that should be different in the 2 modules.

Could some other code be causing this?

Can you show us what's going wrong in the HTML5 module?
 
C

Cmi

Guest
Hm, I don't see any code that should be different in the 2 modules.

Could some other code be causing this?

Can you show us what's going wrong in the HTML5 module?
Here is a link to the site I upload the game on
http://gamejolt.com/games
So as you can see when u get to score level 15 and over the apples start to freeze in the air but in the target windows they fall and work fine. Why is that happening
 
Last edited by a moderator:

FrostyCat

Redemption Seeker
I can see some problematic chunks off the bat.

Code:
irandom_range(0, -32)
The Manual clearly specifies that the first number should be the lower range the second number the higher range. 0 is obviously not lower than -32. Native runners might have checks to fudge it back (don't count on it, though), but HTML5 probably won't.

Code:
obj_apple1.vspeed = 12;
Once again we see attempts to use object.variable with multiple instances of the object at the same time. This is an awful rookie habit that lies behind a lot of unexpected variable behaviour, and HTML5 is particularly unforgiving of it.

When you start exporting to HTML5, you need to be far stricter with scope handling, parameter values and type handling. In an interpreted, strictly sandboxed environment, the runner simply cannot afford the computational juice to forgive improper code.
 
C

Cmi

Guest
I can see some problematic chunks off the bat.

Code:
irandom_range(0, -32)
The Manual clearly specifies that the first number should be the lower range the second number the higher range. 0 is obviously not lower than -32. Native runners might have checks to fudge it back (don't count on it, though), but HTML5 probably won't.

Code:
obj_apple1.vspeed = 12;
Once again we see attempts to use object.variable with multiple instances of the object at the same time. This is an awful rookie habit that lies behind a lot of unexpected variable behaviour, and HTML5 is particularly unforgiving of it.

When you start exporting to HTML5, you need to be far stricter with scope handling, parameter values and type handling. In an interpreted, strictly sandboxed environment, the runner simply cannot afford the computational juice to forgive improper code.
I changed the 0,-32 around and the obj_apple1.vspeed = 12; how should it be written. Also the apples still stay at the top of the screen. Not sure why
 

jo-thijs

Member
@FrostyCat,
I missed the irandom thing, but I just tested it and it seems to work just fine.
The object.variable thing I did notice, but I thought it worked as well in HTML5.
Just did some tests, it's indeed like you say it is and this will very likely be (one of) the issue(s) Cmi is having.

@Cmi, I take it the object that is executing obj_apple1.vspeed = 12; is obj_apple1 itself?
Then you should just use vspeed = 12; instead.

EDIT: Ok, it is documented it behaves like that, don't know why I thought it would work the same.
 
  • Like
Reactions: Cmi
C

Cmi

Guest
@jo-thijs I think that was the problem I was executing the vspeed in the object itself. How come that works in windows and not HTML5. Also so far it's looking good, I haven't seen any that have frozen yet.
 

jo-thijs

Member
As FrostyCat said and as is documented in the GM manual:
https://docs.yoyogames.com/source/dadiospice/002_reference/001_gml language overview/401_05_addressing.html
One of the most common methods for accessing or changing a variable in another instance is to use its object name as an identifier and then use a point "." to tell GameMaker that the variable used after is to be assigned or changed in that object. In practice it would look like this:


obj_ball.speed = 0;


With the above code you are setting the speed of an instance of "obj_ball". However if you have more than one instance of the given object in the room, then it will apply to ALL of them equally - unless you are using one of the JS targets or HTML5, in which case it will affect only one, but you have no way of knowing which one it will affect - so if you need to access all instances of an object, you should be using with, as that is 100% cross platform compatible. In general, this format should only be used when you have a single instance of the object in the room, or (as you will see in the next part) when you have a specific instance ID.
In HTML5, obj_apple1.vspeed = 12; will search for 1 instance of type obj_apple1 and will change its vspeed to 12.
In any other module, it will set the vspeed of every instance of type obj_apple1 to 12.

You don't want any of those 2, you want to set the vspeed of the executing instance, which you do by not putting anything in front of vspeed.[/QUOTE]
 
C

Cmi

Guest
As FrostyCat said and as is documented in the GM manual:
https://docs.yoyogames.com/source/dadiospice/002_reference/001_gml language overview/401_05_addressing.html


In HTML5, obj_apple1.vspeed = 12; will search for 1 instance of type obj_apple1 and will change its vspeed to 12.
In any other module, it will set the vspeed of every instance of type obj_apple1 to 12.

You don't want any of those 2, you want to set the vspeed of the executing instance, which you do by not putting anything in front of vspeed.
[/QUOTE]
Okay I see, thanks @jo-thijs and @FrostyCat .
 
Top