Resources > Coding

Coding in Music Zones

<< < (2/4) > >>

Kami:
Alright that map is splittible into a sort of grid, I'm working on a quick example that will actively check the imaginary map "grid" it'll check if it changes different types and if so it will then transition the music. I'll prob have the example done in a bit. The grid size would be fully modifiable with a simple variable change.

OniShounen:
You can have a few object around all of your map (mainly areas where the terrain changes) like this as well:


--- Code: ---if(!sound_isplaying(yourBGM))
{
    sound_stop(otherBGM);
    sound_loop(yourBGM);
}
--- End code ---

Whitay:

--- Quote from: Kami on October 25, 2014, 12:39:27 am ---Alright that map is splittible into a sort of grid, I'm working on a quick example that will actively check the imaginary map "grid" it'll check if it changes different types and if so it will then transition the music. I'll prob have the example done in a bit. The grid size would be fully modifiable with a simple variable change.

--- End quote ---
This is similar to an idea i had to basically break up the zone into rectangles and check collisions, but i knew someone had an efficient/not badly-rigged together idea. This helps a lot more than just lots of objects checking music(it would not be a few, you would need lots and the collisions would be weird.) because if i ever need to add anything else based on biomes, such as titles or weather effects or enemy spawns or something this sort of is a check one check all.

Thank you much in advance for your help.

OniShounen:
How about deactivating the objects while outside the view?
That way it wouldn't be a collision based event, moreso just a if I'm on the same screen as Link kinda deal.

Also, you'd really only need two objects for every "doorway" between two zones.

Or you guys are suggesting the following:
I don't know if you can use ds_grid with GM8.1 Lite, but you could use that to break down your map into chunks.  After that, you can assign them ids, then check the ID of the location where Link is located and play music accordingly.


--- Code: ---//Create the grid
musicGrid=ds_grid_create(room_width,room_height)
//This part will require some thought.
for(iX=0;iX<=room_width;iX+=1)
  {
  for(iY=0;iY<=room_height;iY+=1)
    {
    ds_grid_set(musicGrid,iX,iY,"bgmForest");
    }
  }

//In Link's step event.
//This bottom part should work in theory, if not some IF THEN ELSE will do, that may give you more control over the fading.
sound_play(ds_grid_get(musicGrid,Link.x,Link.y));


--- End code ---

Whitay:
The issues im trying to see with collisions is just the overuse of random objects and werid shaped sprites because everything is weirdly shaped. and hm. ive never heard about the ds_grid commands, but like Kami above me said about breaking it into grids may be a good idea. that was(depending on how small the grid is) i could get some pretty weird shapes in without creating a single object.

Navigation

[0] Message Index

[#] Next page

[*] Previous page


Contact Us | Legal | Advertise Here
2013 © ZFGC, All Rights Reserved



Go to full version