Hello Guest, please login or register.
Did you miss your activation email?
Login with username, password and session length.

Pages: [1]   Go Down

Author Topic: Coding in Music Zones  (Read 2685 times)

0 Members and 1 Guest are viewing this topic.
Coding in Music Zones
« on: October 24, 2014, 01:48:20 am »
  • *
  • Reputation: +2/-0
  • Offline Offline
  • Gender: Male
  • Posts: 269
Hello all, i have a quick question. Basically, my main overworld is large and has different zones from mountains to forests etc. It is one big room. And now im on the step of implementing music and sound in the world, i want to make more than just one overworld theme. I was hoping to get songs for Mountains and then a different for Forest and a different for Desert, and when you walk into a new zone the old music fades out and the new music fades into play. The fading out and fading in can be done with sound_fade(index,value,time) but im more worried about the sound. The map is a bit more than some square zones, and so the only two solutions for checking if you are in a zone is having tons of if link.x > this and link.y < this and link.x < this and having it be very weird and lots of unnessesary x and y checks, or having a sort of border that you collide with, but this would lead to huge objects.

So, is there an easier way to check this and set music for different zones, or is checking tons of x and y the most simple way to go towards this? My map looks something like this, so you could see all the different zones. This is why i dont want to check x and y, so is there an easier way to do this?


Game maker 8/8.1 here.
« Last Edit: October 24, 2014, 07:33:30 pm by Whitay »
Logged

OniShounen

Nanomachines
Re: Coding in Music Zones
« Reply #1 on: October 24, 2014, 05:07:49 pm »
  • David Hayter
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Male
  • Posts: 48
If you are using Gamemaker 8.1 standard you could use 3D sounds, I don't know if in studio you have to have professional.

Look through the manual for 3D sounds.

-This is all assuming you are using gamemaker-
Logged
Re: Coding in Music Zones
« Reply #2 on: October 24, 2014, 07:34:02 pm »
  • *
  • Reputation: +2/-0
  • Offline Offline
  • Gender: Male
  • Posts: 269
Wow i forgot to specify. Im in game maker 8.1, not studio.
Logged
Re: Coding in Music Zones
« Reply #3 on: October 24, 2014, 07:47:44 pm »
  • Yeah, I don't even...
  • *
  • Reputation: +11/-4
  • Offline Offline
  • Gender: Female
  • Posts: 1008
Well I have a few ideas, but I have a few things I need to ask first.

Is it view based, similar to the zelda or links awakening locked screen, meaning the view stays within a set spot or is it more akin to minish cap views not being locked?

or is it the view just follows link and can overlap the biomes, meaning like for example, forest and lake hylia on the same screen?
Logged
Re: Coding in Music Zones
« Reply #4 on: October 24, 2014, 09:00:34 pm »
  • *
  • Reputation: +2/-0
  • Offline Offline
  • Gender: Male
  • Posts: 269
The view is not locked. Its more like LTTP, where you are in one big area and the camera follows link. The whole overworld is one map, with the view following link. Heres a picture of the level zoomed out from a while ago, as you can see everything is sort of connected and not blocky.
Show content
Logged
Re: Coding in Music Zones
« Reply #5 on: October 25, 2014, 12:39:27 am »
  • Yeah, I don't even...
  • *
  • Reputation: +11/-4
  • Offline Offline
  • Gender: Female
  • Posts: 1008
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.
Logged

OniShounen

Nanomachines
Re: Coding in Music Zones
« Reply #6 on: October 25, 2014, 03:50:08 am »
  • David Hayter
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Male
  • Posts: 48
You can have a few object around all of your map (mainly areas where the terrain changes) like this as well:

Code: [Select]
if(!sound_isplaying(yourBGM))
{
    sound_stop(otherBGM);
    sound_loop(yourBGM);
}
Logged
Re: Coding in Music Zones
« Reply #7 on: October 25, 2014, 04:12:19 am »
  • *
  • Reputation: +2/-0
  • Offline Offline
  • Gender: Male
  • Posts: 269
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.
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.
Logged

OniShounen

Nanomachines
Re: Coding in Music Zones
« Reply #8 on: October 25, 2014, 05:04:22 am »
  • David Hayter
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Male
  • Posts: 48
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: [Select]
//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));

Logged
Re: Coding in Music Zones
« Reply #9 on: October 25, 2014, 05:32:18 pm »
  • *
  • Reputation: +2/-0
  • Offline Offline
  • Gender: Male
  • Posts: 269
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.
Logged

OniShounen

Nanomachines
Re: Coding in Music Zones
« Reply #10 on: October 25, 2014, 05:38:46 pm »
  • David Hayter
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Male
  • Posts: 48
the for loop i gave as an example runs across individual pixels, but you could adjust it to increment any number you wanted say 4,8,12,16,32.

you just have to have link check the same increments on the grid
Logged
Re: Coding in Music Zones
« Reply #11 on: October 25, 2014, 06:01:25 pm »
  • *
  • Reputation: +2/-0
  • Offline Offline
  • Gender: Male
  • Posts: 269
I have yet to try that, as i need to get the coords to seperate some levels first. I will be able to test that in a few though and i will let you know. thank you!
Logged

OniShounen

Nanomachines
Re: Coding in Music Zones
« Reply #12 on: October 26, 2014, 12:34:59 pm »
  • David Hayter
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Male
  • Posts: 48
Don't forget you have the d s _ set _ region function as well
Logged
Re: Coding in Music Zones
« Reply #13 on: October 27, 2014, 12:10:28 am »
  • *
  • Reputation: +2/-0
  • Offline Offline
  • Gender: Male
  • Posts: 269
Thank you all for the suggestions, I was able to figure it out. It was more of a which conceptual way should i go about this - not so much the coding aspect. Cutting the zones into various rectangles to accuratly cover them and then checking with those rectangular zones made this easier than using objects.
Logged

OniShounen

Nanomachines
Re: Coding in Music Zones
« Reply #14 on: October 27, 2014, 12:29:50 am »
  • David Hayter
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Male
  • Posts: 48
No problem, glad you could figure it out.

I just got GM:Studio Professional today; time to go back to making click the clown for a couple days!
Logged
Re: Coding in Music Zones
« Reply #15 on: November 10, 2014, 03:33:23 am »
  • *
  • Reputation: +3/-0
  • Offline Offline
  • Gender: Male
  • Posts: 3371
I believe gamemaker has some kind of timer task type thing that you could probably use too, so it only does the check once per second or something like that.
Logged
Quote from: Jason
Your community is a bunch of stuck up turds.
Pages: [1]   Go Up

 


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



Page created in 0.066 seconds with 49 queries.

anything