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: GM Background/Tile change  (Read 3701 times)

0 Members and 1 Guest are viewing this topic.

Sinkin

Team Dekunutz
GM Background/Tile change
« on: January 25, 2010, 01:31:55 pm »
  • Idk
  • *
  • Reputation: +5/-0
  • Offline Offline
  • Gender: Male
  • Posts: 564
I need some help in Game Maker when it comes to background and tiles. There is a certain commando in GM where at a certain moment turn the existing tiles in a room to other or the same in a diffrent color. How do I need to code it so the tiles will change in one easy button push?
« Last Edit: January 25, 2010, 01:59:29 pm by SinkinDevil »
Logged
Re: GM Background/Tile change
« Reply #1 on: January 25, 2010, 07:51:16 pm »
  • *
  • Reputation: +9/-0
  • Offline Offline
  • Gender: Male
  • Posts: 3725
I have never done it before, but I just browsed the gamemaker help files just browsing does help a lot and I think I would try the function:

background_replace(ind,fname,transparent,smooth,preload) Same as above but in this case the background with index ind is replaced. The function returns whether it is successful. When the background is currently visible in the room it wil be replaced also.


It came from:
Quote
Backgrounds
The following routines can be used to create new backgrounds and to remove them.

background_duplicate(ind) Creates a duplicate of the background with the given index. It returns the index of the new background. When an error occurs -1 is returned.
background_assign(ind,back) Assigns the indicated background to background ind. So this makes a copy of the background.
background_add(fname,transparent,smooth,preload) Adds the image stored in the file fname to the set of background resources. Many different types of images can be dealt with. transparent indicates whether the image is partially transparent. smooth indicates whether to smooth the edges. preload indicates whether to preload the image into texture memory. The function returns the index of the new background that you can then use to draw it or to assign it to the variable background_index[0] to make it visible in the current room. When an error occurs -1 is returned.
background_add_alpha(fname,preload) Adds the image stored in the file fname to the set of background resources, but this time the file has an alpha channel to indicate transparency (as for example in .png files). The arguments are the same as above (but two are missing as they are not relevant in this case). When an error occurs -1 is returned.
background_replace(ind,fname,transparent,smooth,preload) Same as above but in this case the background with index ind is replaced. The function returns whether it is successful. When the background is currently visible in the room it wil be replaced also.
background_replace_alpha(ind,fname,preload) Same as above but in this case the file has an alpha channel.
background_create_color(w,h,col,preload) Creates a background of the given size and with the given color. It returns the index of the new background. When an error occurs -1 is returned.
background_create_gradient(w,h,col1,col2,kind,preload) Creates a gradient filled background of the given size. col1 and col2 indicate the two colors. kind is a number between 0 and 5 indicating the kind of gradient: 0=horizontal 1=vertical, 2= rectangle, 3=ellipse, 4=double horizontal, 5=double vertical. It returns the index of the new background. When an error occurs -1 is returned.
background_create_from_screen(x,y,w,h,transparent,smooth,preload) Creates a background by copying the given area from the screen. This makes it possible to create any background you want. Draw the image on the screen using the drawing functions and next create a background from it. (If you don't do this in the drawing event you can even do it in such a way that it is not visible on the screen by not refreshing the screen.) The other parameters are as above. The function returns the index of the new background. A work of caution is required here. Even though we speak about the screen, it is actually the drawing region that matters. The fact that there is a window on the screen and that the image might be scaled in this window does not matter.
background_create_from_surface(id,x,y,w,h,transparent,smooth,preload) Creates a background by copying the given area from the surface with the given id. This makes it possible to create any background you want. Draw the image on the surface using the drawing functions and next create a background from it. Note that alpha values are maintained the background.
background_delete(ind) Deletes the background from memory, freeing the memory used.

The following routine exists to change the appearance of a background.


background_set_alpha_from_background(ind,back) Changes the alpha (transparancy) values in the background with index ind using the intensity values in the background back. This cannot be undone.
Logged

Sinkin

Team Dekunutz
Re: GM Background/Tile change
« Reply #2 on: January 25, 2010, 09:26:40 pm »
  • Idk
  • *
  • Reputation: +5/-0
  • Offline Offline
  • Gender: Male
  • Posts: 564
Could it work with the background_assign command? I'm trying to code a day and night cycle similar to the one in The Shadowgazer where the tiles are changing at a certain moment. I need a little help to code it.  :P
Logged
Re: GM Background/Tile change
« Reply #3 on: January 25, 2010, 09:40:16 pm »
  • *
  • Reputation: +9/-0
  • Offline Offline
  • Gender: Male
  • Posts: 3725
Don't know. Like I said, I have never done it before nor looked into it. But I suggest you just experiment with a number of combinations.

Make a room and have a control object change the background tiles after certain intervals. And then just experiment with settings and even the other functions. 9 out 10 you will fail to get the desired result but when you do, you have learned a lot.
Logged
Re: GM Background/Tile change
« Reply #4 on: January 26, 2010, 08:43:18 pm »
  • *
  • Reputation: +8/-0
  • Offline Offline
  • Gender: Male
  • Posts: 6604
http://www.kousougames.com/data/downloads/counter.php?file=RodOfSeasonsExample

dlbrooks33 had an example of what you're thinking about doing.
Logged

Sinkin

Team Dekunutz
Re: GM Background/Tile change
« Reply #5 on: January 27, 2010, 09:39:47 am »
  • Idk
  • *
  • Reputation: +5/-0
  • Offline Offline
  • Gender: Male
  • Posts: 564
Logged
Pages: [1]   Go Up

 


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



Page created in 0.023 seconds with 46 queries.