HTML5 (Solved) Multiple views not working (1.4 HTML5)

Discussion in 'Programming' started by GamemakerFreak123, Mar 23, 2018.

Tags:
  1. GamemakerFreak123

    GamemakerFreak123 Member

    Joined:
    Jun 25, 2016
    Posts:
    18
    Hi

    Version of GM: v.1.4.1804

    I've been having this problem with showing multiple views at the same time. The concept is simple. Two players walk around in the same world, with their own respective view. This is how it's supposed to look and how it looks when compiling for windows:
    [​IMG]

    However when i compile for HTML it only shows the second view, which is stretched to fill the entire canvas.
    [​IMG]

    I have been trying all kinds of things to fix it, but nothing seems to work. Does anyone have a clue, on what is going on? Please ask if you need more information to understand the issue. I should also mention that I've tried google, but without any help.

    Thanks in advance
     
  2. Alex_Beach

    Alex_Beach Member

    Joined:
    Jan 9, 2018
    Posts:
    217
  3. GamemakerFreak123

    GamemakerFreak123 Member

    Joined:
    Jun 25, 2016
    Posts:
    18
    Hi Alex_Beach and thank you for taking time to answer my question.

    I'm not scaling, so I don't think that's the issue. I've read the article, but couldn't find any solution to the problem. I'll try to give some more information about what I'm doing. It's actually fairly simple. I have these two views:

    View 1:
    [​IMG]

    View 2:
    [​IMG]

    And then I run this code to make the views follow their separate players:
    [​IMG]

    Again, everything work on Windows, just not when compiling for HTML5.
     
  4. Roa

    Roa Member

    Joined:
    Jun 20, 2016
    Posts:
    540
    views in html5 are busted as ****.
    For all intents and purposes, the last view drawn is your final image, and they don't exist outside the first primitive view setup.

    I hope you are ready for a very tedious work around, because as far as I'm aware, you basically have to re-invent the camera system by drawing everything in the game to your own surfaces, and having your own surfaces be drawn in part over top the main draw surface.

    You can't even copy views or manually take control of the application surface, so re-rendering the game manually isn't optional. I don't know why this is the alternative to simply fixing it to run like every platform, but you are going to have to do some leg work if you want multiple views in HTML5. It took me hours to figure out what would and wouldn't work, and what I could get away with in the sense of speed.

    • view x/y kinda worked
    • view enable doesn't work as expected
    • view_width I believe worked
    • view ports don't work as expected,
    • surface from view doesn't work as expected
    • and application_surface functions don't work as expected.
     
    Last edited: Mar 24, 2018
  5. GamemakerFreak123

    GamemakerFreak123 Member

    Joined:
    Jun 25, 2016
    Posts:
    18
    Thank you for your answer Roa. I really appreciate it.

    That's what I was afraid of. Really frustrating that HTML5 for Gamemaker is always such a nightmare. I'm willing to do some leg work, as long as it's efficient enough to run on HTML5. But I must also admit that my experience with surfaces' are limited, so unless you can point me in the right direction, I'm not sure it would be something I can handle.
     
  6. Roa

    Roa Member

    Joined:
    Jun 20, 2016
    Posts:
    540
    just look them up in the manual, they are pretty simple.

    They are basically reserved memory for you to store dynamic images on. So you can draw graphics, effects, and sprites to them, and then you simply call the one surface vs having all those graphics that called over and over again.

    What you are going to want to do, is take all your game objects that need to be drawn and give them a common parent object, then call the draw event of that parent when you go to draw the graphics to the surface. From there, you can make copies of small sections from that first surface to 2 more that will act as your views into the world. You can specify the x/y and width/height of those sub surfaces to match what you need to see the world. Then, you simply draw those 2 sub surfaces to the main application surface in draw GUI begin.
     
  7. GamemakerFreak123

    GamemakerFreak123 Member

    Joined:
    Jun 25, 2016
    Posts:
    18
    I think I understand. I'll have a look in the manual and see if I can figure it out. One question though. The world is fairly big, so I use tiles for the ground, and not objects. So how do I draw the tiles to this surface, and not only the objects?

    Thanks again.
     
  8. Roa

    Roa Member

    Joined:
    Jun 20, 2016
    Posts:
    540
    Eesh, Im not entirely sure of the tile drawing functions, but you would have to draw the layer or loop through each tile and draw it.

    The cool thing is, you only have to draw those tiles once to a surface too, then call the tile surface to draw on the same one you have the objects. That would probably be the only surface in your game that would actually be saving you logic and render time lol
     
  9. GamemakerFreak123

    GamemakerFreak123 Member

    Joined:
    Jun 25, 2016
    Posts:
    18
    Oh, I see. That should work. I'll try to make it work.

    Once again. Thank you very much for your assistance. Appreciate it.
     
  10. GamemakerFreak123

    GamemakerFreak123 Member

    Joined:
    Jun 25, 2016
    Posts:
    18
    Just got it working. Wasn't even that hard. Thank you again. You saved me hours of frustrations :)
     
    Roa likes this.
  11. GamemakerFreak123

    GamemakerFreak123 Member

    Joined:
    Jun 25, 2016
    Posts:
    18
    If anyone has the same problem in the future, here is a simple project I created to illustrate the workaround, I came up with:
    https://felix-paulsen.itch.io/html-split-screen-asset

    Don't hesitate to email me, should you have any questions about this asset / project.
     
  12. GamemakerFreak123

    GamemakerFreak123 Member

    Joined:
    Jun 25, 2016
    Posts:
    18
    Recently realized that this is actually much easier to do than we thought. You actually don't need to draw every single object to a surface in order to get this working. All you need to do is basically draw the view to the surface with view_surface_id. I've updated the project which you can find at the link in my previous comment. Wish I found out about this earlier, since this is a much much more simple solution and a better working one.
     

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