Welcome, guest! Please login or register.

    * Shoutbox

    RefreshHistory
    • ragnoroker: Brand new server! Double EXP is enabled right now aswell as other events! - [link]
      Today at 07:14:43 AM
    • ragnoroker: Brand new server! Double EXP is enabled right now aswell as other events! - [link]
      Today at 07:14:35 AM
    • puppajohn: Come and join us today for amazing content !
      August 16, 2019, 10:26:16 PM
    • puppajohn:[link] come and join us now! you have donator on your server? no problem we restore your donator credits and symbol ! free M box on loggins
      August 16, 2019, 10:26:02 PM
    • PavSwag: autoscape,0rg kill REVS for chance of TWISTED BOW || EP GETS YOU OSRS GP TOKENS
      August 15, 2019, 05:13:07 PM
    • hodford: autoscape,0rg is actually fudgein lit as come check it out
      August 13, 2019, 02:59:58 AM
    • ragnoroker: Brand new server! Hosting Raids Event all day + More! - 20+ online, Join today [link]
      August 11, 2019, 07:45:49 AM
    • ragnoroker: Brand new server! Hosting Raids Event all day + More! - 20+ online, Join today [link]
      August 11, 2019, 07:45:46 AM
    • PavSwag: autoscape,0rg kill REVS for chance of TWISTED BOW
      August 08, 2019, 07:29:43 PM
    • ragnoroker:Brand new server! Endless Content - Mature Players/Staff - 20+ online, Join today [link]
      August 08, 2019, 11:05:53 AM
    • ragnoroker:Brand new server! Endless Content - Mature Players/Staff - 20+ online, Join today [link]
      August 08, 2019, 11:05:46 AM
    • asshole_rule: bernie sanders
      August 06, 2019, 07:54:02 PM
    • PavSwag: #AS 100M OSRS GP GIVEAWAY!! [link] 317 Oldschool RuneScape Private Server emulating core factors of the game with a strong economy and balance of experience to bossing and prestiging -Receive DONATOR Perks by maxing to 99s- Lumbridge remade - Login with a starter set of armour and items - PK District - Preloading sets - Activity points for training - All Skills Working, Skilling Island, Skilling Pets, Skilling Rewards - All Working Max Capes - 25+ Bosses with Pets - Superior Slayer Encounters - Player Owned Shops - Minigames, Construction, Sawmill, Warriors Guild, Pest Control, Barrows (with pets), Fight Caves, Inferno Caves, Chambers of Xeric, Custom Raids - NPC Drop Table, Kills Tracker, Points Tracker, Extra settings. - Doubled Xp & Points Weekends - Vote System - Vote4Donor - Competitive Highscores - Tons of Content - Join us today for bonus giveaways and free ultra mystery box upon login!   Official YouTube Media: [youtube]P5D0eXEmjA4[/youtube] Join NOW Ill personally give you Ultra Mystery Boxes (Twisted Bow??) Im the Developer :smiley: Heres the Discord:  [link] BTW 100m OSRS GP Giveaways WEEKLY!
      August 05, 2019, 01:05:53 PM
    • ragnoroker: Brand new server! Endless Content - Mature Players/Staff - 20+ online, Join today :) - [link]
      August 05, 2019, 12:48:52 PM
    • ragnoroker: Brand new server! Endless Content - Mature Players/Staff - 20+ online, Join today :) - [link]
      August 05, 2019, 12:48:47 PM
    • suelo: does the search not work on here?
      August 05, 2019, 02:12:08 AM
    • PavSwag: #AS 100M OSRS GP GIVEAWAY!! [link] 317 Oldschool RuneScape Private Server emulating core factors of the game with a strong economy and balance of experience to bossing and prestiging -Receive DONATOR Perks by maxing to 99s- Lumbridge remade - Login with a starter set of armour and items - PK District - Preloading sets - Activity points for training - All Skills Working, Skilling Island, Skilling Pets, Skilling Rewards - All Working Max Capes - 25+ Bosses with Pets - Superior Slayer Encounters - Player Owned Shops - Minigames, Construction, Sawmill, Warriors Guild, Pest Control, Barrows (with pets), Fight Caves, Inferno Caves, Chambers of Xeric, Custom Raids - NPC Drop Table, Kills Tracker, Points Tracker, Extra settings. - Doubled Xp & Points Weekends - Vote System - Vote4Donor - Competitive Highscores - Tons of Content - Join us today for bonus giveaways and free ultra mystery box upon login!   Official YouTube Media: [youtube]P5D0eXEmjA4[/youtube] Join NOW Ill personally give you Ultra Mystery Boxes (Twisted Bow??) Im the Developer :smiley: Heres the Discord:  [link] BTW 100m OSRS GP Giveaways WEEKLY!
      August 04, 2019, 11:48:39 PM
    • PavSwag: autoscape,0rg kill REVS for chance of TWISTED BOW?
      August 04, 2019, 11:21:52 PM
    • ragnoroker:Brand new server! - 20+ online, Many events tonight :) come join the fun. [link]!
      August 04, 2019, 12:39:24 PM
    • ragnoroker:Brand new server! - 20+ online, Many events tonight :) come join the fun. [link]!
      August 04, 2019, 12:39:18 PM

    Author Topic: (Array)Html5 Map? Is there any other way?  (Read 2398 times)

    0 Members and 1 Guest are viewing this topic.

    Offline317guy

    • Member
    • ***
    • Posts: 241
    • Thanks: +0/-0
      • View Profile
    (Array)Html5 Map? Is there any other way?
    « on: May 04, 2016, 07:49:11 AM »
    Was just curious is there any other way to program a map in JavaScript
    using a different method besides arrays, below is just a small way of how i am rendering my maps
    however my map is now huge and it is very bothersome to find the area i wish too edit. I am also using the array elements for collision.
    if anyone knows of a different method please share. or you can just flame me for my code.

    (click to show/hide)
    Runescape Gambling

    OfflineBowser jr

    • Member
    • ****
    • Posts: 6,001
    • Thanks: +0/-0
      • View Profile
    Re: (Array)Html5 Map? Is there any other way?
    « Reply #1 on: May 04, 2016, 09:04:39 AM »
    You probably want to generate the map from a mapdata file, and not hardcode stuff like this.
    Runescape Gambling

    Offline317guy

    • Member
    • ***
    • Posts: 241
    • Thanks: +0/-0
      • View Profile
    Re: (Array)Html5 Map? Is there any other way?
    « Reply #2 on: May 04, 2016, 09:20:10 AM »
    You probably want to generate the map from a mapdata file, and not hardcode stuff like this.
    Do you think you could point me in the right direction? any information or website would be great  :)
    Runescape Gambling

    OfflineBowser jr

    • Member
    • ****
    • Posts: 6,001
    • Thanks: +0/-0
      • View Profile
    Re: (Array)Html5 Map? Is there any other way?
    « Reply #3 on: May 04, 2016, 12:55:26 PM »
    Just look how other people implement their maps.

    OfflineDeath Style

    • Member
    • ****
    • Posts: 569
    • Thanks: +0/-0
      • View Profile
    Re: (Array)Html5 Map? Is there any other way?
    « Reply #4 on: May 05, 2016, 10:29:54 AM »
    is this a static image?

    using arrays is your best bet but you can make it easier

    Code: Javascript
    1. var loadImage =(url)=>new Promise((resolve, reject)=>{
    2.   var img =new Image();
    3.   img.onload=()=> resolve(img);
    4.   img.onerror=(err)=> reject(err);
    5.   img.src= url;
    6. });
    7.  
    8. var loadImages =(imgUrls)=> Promise.all(imgUrls.map(loadImage));
    9.  
    10. var drawMap =(tiles, tileImgs, context)=>{
    11.   var tileHeight = tileImgs[0].height;
    12.   var tileWidth = tileImgs[0].width;
    13.   tiles.forEach((row, y)=> row.forEach((tileID, x)=> context.drawImage(tileImgs[tileID], x * tileWidth, y * tileHeight)));
    14. };
    15.  
    16. var imgUrls =[
    17.   'Grass.png',
    18.   'Rock.png',
    19.   'Sand.png'
    20. ];
    21.  
    22. var map =[
    23.   [0,0,0],
    24.   [1,1,1],
    25.   [2,2,2]
    26. ];
    27.  
    28. var context;// something...
    29.  
    30. loadImages(imgUrls).then(tileImgs => drawMap(map, tileImgs, context));
    31.  

    the ID in your 2d map array correlates with the index in imgUrls, so you don't need to check each one individually

    you'll get the first row of grass, then rock, then sand
    « Last Edit: May 05, 2016, 12:02:27 PM by Death Style »

    Offline317guy

    • Member
    • ***
    • Posts: 241
    • Thanks: +0/-0
      • View Profile
    Re: (Array)Html5 Map? Is there any other way?
    « Reply #5 on: May 05, 2016, 12:57:05 PM »
    is this a static image?

    using arrays is your best bet but you can make it easier

    Code: Javascript
    1. var loadImage =(url)=>new Promise((resolve, reject)=>{
    2.   var img =new Image();
    3.   img.onload=()=> resolve(img);
    4.   img.onerror=(err)=> reject(err);
    5.   img.src= url;
    6. });
    7.  
    8. var loadImages =(imgUrls)=> Promise.all(imgUrls.map(loadImage));
    9.  
    10. var drawMap =(tiles, tileImgs, context)=>{
    11.   var tileHeight = tileImgs[0].height;
    12.   var tileWidth = tileImgs[0].width;
    13.   tiles.forEach((row, y)=> row.forEach((tileID, x)=> context.drawImage(tileImgs[tileID], x * tileWidth, y * tileHeight)));
    14. };
    15.  
    16. var imgUrls =[
    17.   'Grass.png',
    18.   'Rock.png',
    19.   'Sand.png'
    20. ];
    21.  
    22. var map =[
    23.   [0,0,0],
    24.   [1,1,1],
    25.   [2,2,2]
    26. ];
    27.  
    28. var context;// something...
    29.  
    30. loadImages(imgUrls).then(tileImgs => drawMap(map, tileImgs, context));
    31.  

    the ID in your 2d map array correlates with the index in imgUrls, so you don't need to check each one individually

    you'll get the first row of grass, then rock, then sand
    Thanks for the upgrade hahaha, Just wondering do you think it is possible to load the data from a image file so instead of  0 = grass, a pixel of green on the image file would represent the grass image?

    OfflineDeath Style

    • Member
    • ****
    • Posts: 569
    • Thanks: +0/-0
      • View Profile
    Re: (Array)Html5 Map? Is there any other way?
    « Reply #6 on: May 06, 2016, 04:48:03 AM »
    you could map the image file of green/brown/tan to an array of 0/1/2 and then run it through that to get grass/rock/sand

    you'd need to list the rgba values in the same order and map them over a Uint32Array view of the imagedata

    Offlinechillwitm888

    • Member
    • ****
    • Posts: 1,721
    • Thanks: +0/-0
      • View Profile
    Re: (Array)Html5 Map? Is there any other way?
    « Reply #7 on: May 19, 2016, 06:09:41 AM »
    if you want to generate a map, why not just use google maps?
    Google has their map Api open and you can use their placepicker API to plot ur points. Its fairly intuitive
    No need to build something thats already been built

    Offlinejustaguy

    • Member
    • ****
    • *
    • Posts: 706
    • Thanks: +0/-0
      • View Profile
    Re: (Array)Html5 Map? Is there any other way?
    « Reply #8 on: May 19, 2016, 09:14:54 AM »
    if you want to generate a map, why not just use google maps?
    Google has their map Api open and you can use their placepicker API to plot ur points. Its fairly intuitive
    No need to build something thats already been built

    He wants to make a game world.
    RIP

    Offline317guy

    • Member
    • ***
    • Posts: 241
    • Thanks: +0/-0
      • View Profile
    Re: (Array)Html5 Map? Is there any other way?
    « Reply #9 on: August 15, 2016, 03:56:37 AM »
    if you want to generate a map, why not just use google maps?
    Google has their map Api open and you can use their placepicker API to plot ur points. Its fairly intuitive
    No need to build something thats already been built

    He wants to make a game world.
    ^
     |

    OfflineKamnarce

    • Member
    • **
    • Posts: 5
    • Thanks: +10/-10
      • View Profile
    Re: (Array)Html5 Map? Is there any other way?
    « Reply #10 on: August 10, 2019, 04:55:54 AM »
    will this copy career stats too, or just ratings?

    and when I create a new league file, there is no free agent pool, so what am I copying over?

     

    Copyright © 2017 MoparScape. All rights reserved.
    Powered by SMFPacks SEO Pro Mod |
    SimplePortal 2.3.5 © 2008-2012, SimplePortal