Author Topic: editing trans layer  (Read 5751 times)

basementbiker

  • Visitor
  • *
  • Posts: 14
    • View Profile
    • Email
editing trans layer
« on: 2006-10-11, 02:54:33 PM »
I need to edit a transparent layer from script.
I can see it might be possible with oMap.ShiftLayer.
But I cant seem to get it right , and Im not sure if any of the
map edit methods work on layers above playersprite.
I made tiles the size of the viewable area , and made a layer above all other layers with a zero scroll rate.
If I can shift this top layer 256 pixels left or right I can make it appear as if there was day and night sequences. :)
 

cbass

  • Expert
  • Regular
  • *****
  • Posts: 97
  • script this
    • View Profile
    • Squest RPG
Re: editing trans layer
« Reply #1 on: 2006-10-11, 06:35:16 PM »
So let me get this straight.  You want to edit a layer at runtime with script, this is possible.  You can't move a layer left or right, or even up and down.  all layers are aligned to the top left corner of the map and scroll from there. (The top left pixel of every layer are always stacked on each other perfectly)  If you make the scroll rate zero then the layer covers the whole screen and doesn't scroll ever.  (remember use Map and not MapEdit since MapEdit is only for when you open the map editor in the SGDK design environment.)

As far as doing a day and night sequence, I don't think it is possible, since there is no alpha transparency supported.  The only way I could see doing something remotly like making a darker tint would be to make a tiles set with 2 tiles each 640x480 one transparent, one darker (or dithered darker/transparent), and then make a tile animation that switches between them once/frame.  Then, make the top layer of your map scroll rate=0 and use this tileset.  Then with script, change the value of that tile depending on if it is day or night.

It would probably look pretty bad, but could work (would probably look a lot better if you made the tileset 3 tiles, and had two of them dithered opposite and cycled between them at night)

basementbiker

  • Visitor
  • *
  • Posts: 14
    • View Profile
    • Email
Re: editing trans layer
« Reply #2 on: 2006-10-11, 09:17:55 PM »
Hmm , I see.
 ???
I think I have another way around this that dosent use script.
Ill try makeing a realy big inert sprite that sits on that none scrolling layer.

cbass

  • Expert
  • Regular
  • *****
  • Posts: 97
  • script this
    • View Profile
    • Squest RPG
Re: editing trans layer
« Reply #3 on: 2006-10-11, 09:35:18 PM »
Can't quite visualize what your planning.  But to help you with some info:  Sprites can be drawn partially off the map if they hang off the right or bottom edge of the map, but not the top or left edge  (x,y positions can't be negative as far as I know)

bluemonkmn

  • SGDK Author
  • Administrator
  • Fanatic
  • *****
  • Posts: 2761
    • ICQ Messenger - 2678251
    • MSN Messenger - BlueMonkMN@gmail.com
    • View Profile
    • http://sgdk2.sf.net/
    • Email
Re: editing trans layer
« Reply #4 on: 2006-10-12, 06:17:20 AM »
So many answers, so little time.  I'll go with these two:
ProjectObj.GamePlayer.rMap.MapLayer(1).Data.TileValue
ProjectObj.GamePlayer.rMap.MapLayer(1).Data.TileMapping

These two properties are documented in BMDXCtls.hlp in the BMDXCtls source code package.
TileValue takes an X and a Y parameter and you can either read the value or assign a new tile value to an individual tile that way.

TileMapping takes a tile index (0 through 255) as a parameter and you can set it to any new value.  That will cause all tiles with the parameter value to be drawn as the new value.  This is how tile animation is accomplished, but you can use it for other things too.

Either one of these properties could be used to solve your challenge.

basementbiker

  • Visitor
  • *
  • Posts: 14
    • View Profile
    • Email
Re: editing trans layer
« Reply #5 on: 2006-10-12, 12:31:46 PM »
So many answers, so little time.  I'll go with these two:
ProjectObj.GamePlayer.rMap.MapLayer(1).Data.TileValue
ProjectObj.GamePlayer.rMap.MapLayer(1).Data.TileMapping

This is very interesting.
Using a big sprite works , I even have it timed based on how far the player has traveld
to appear and then at another time to disappear with a collision from another smaller sprite.
I would like to experiment with .Data.TileValue and .Data.TileMapping , but first which layer is (1) top down or bottom up?
 ;D

bluemonkmn

  • SGDK Author
  • Administrator
  • Fanatic
  • *****
  • Posts: 2761
    • ICQ Messenger - 2678251
    • MSN Messenger - BlueMonkMN@gmail.com
    • View Profile
    • http://sgdk2.sf.net/
    • Email
Re: editing trans layer
« Reply #6 on: 2006-10-12, 02:33:28 PM »
I think layer 0 is the layer farthest in the backgound and layer 1 would be in front of that.
Oh, and here's another idea -- have you considered an "Alter Map" special function?

cbass

  • Expert
  • Regular
  • *****
  • Posts: 97
  • script this
    • View Profile
    • Squest RPG
Re: editing trans layer
« Reply #7 on: 2006-10-12, 07:02:08 PM »
I can independantly confirm that 0 is the furthest background layer, and the highest number is the foreground layer.

I dont think "Alter Map" will work on anything but the player sprite's layer.

cbass

  • Expert
  • Regular
  • *****
  • Posts: 97
  • script this
    • View Profile
    • Squest RPG
Re: editing trans layer
« Reply #8 on: 2006-10-12, 07:12:07 PM »
Off topic. ;D

ProjectObj.GamePlayer.rMap.MapLayer(1).Data.TileMapping

This could be really useful in some situations, to avoid mass tile changes on a map.

Cool, I wonder why I never noticed this one before, I do a lot of work with TileValue(X, Y) and alway assumed it was the absolute byte stored in map file.  But reading the peice on TileMapping, Tilevalue can change for a given X,Y if the cell is animated.  How do you determine what is stored in map file (RealTileValue) for a particular X,Y if you are reading TileValue on an animated tile?  Don't have a problem at the moment, was just wondering for future reference. ;)


bluemonkmn

  • SGDK Author
  • Administrator
  • Fanatic
  • *****
  • Posts: 2761
    • ICQ Messenger - 2678251
    • MSN Messenger - BlueMonkMN@gmail.com
    • View Profile
    • http://sgdk2.sf.net/
    • Email
Re: editing trans layer
« Reply #9 on: 2006-10-13, 08:41:48 AM »
I don't think there is an easy way to read the real tile value.  The round-about ways I can think of are:
1) Reset all the tile mappings to their identity values and then read the tile
or
2) Retrieve the MapData array and read the appropriate byte from there.

Neither of these is very optimal so I wouldn't recommend doing it too frequently.