Author Topic: inventory transparency  (Read 7293 times)

dutch_619

  • Regular
  • **
  • Posts: 90
    • View Profile
    • Email
inventory transparency
« on: 2007-02-05, 02:41:29 PM »
I have a small problem with drawing the inventory items transparently. The surrounding colour shows during game-play. It gives an ugly look to the game and I was wondering how to fix this. The tileset used for inventory items uses the same transparent colour as the other layers, and the layers other than the background are set transparent as well.

Any ideas would be welcomed.
Thanks

durnurd

  • Lead Lemming
  • Expert
  • Fanatic
  • *****
  • Posts: 1234
  • Games completed so far: 0
    • MSN Messenger - durnurd@hotmail.com
    • View Profile
    • Find My Ed
Re: inventory transparency
« Reply #1 on: 2007-02-05, 03:03:04 PM »
The built-in method for drawing inventory does not support transparency.  You can either resize the map so that the inventory is displayed outside of the map, or you can try doing something like what the Super Happy Funland sample project does, and use sprites or tiles to draw inventory on a layer with a scroll-rate of 0, based on use of special functions or scripts.
Edward Dassmesser

dutch_619

  • Regular
  • **
  • Posts: 90
    • View Profile
    • Email
Re: inventory transparency
« Reply #2 on: 2007-02-05, 05:25:57 PM »
I was afraid that was the case. Thanks for the quick response though.

On a completely different subject...

I was looking into the method used to map tilesets to maps and was wondering if this could be scripted. Possibly use a onetime script to map a tileset of the same size directly into a layer. Duplicate the 2nd tile for both 0,0 and 0,1 in the layer and then have an x,x to x,x rule table from there. My current efforts leave much to be desired as I get exceptions from out of array calls.

VB is not really my thing it seems.

bluemonkmn

  • SGDK Author
  • Administrator
  • Fanatic
  • *****
  • Posts: 2736
    • ICQ Messenger - 2678251
    • MSN Messenger - BlueMonkMN@gmail.com
    • View Profile
    • http://sgdk2.sf.net/
    • Email
Re: inventory transparency
« Reply #3 on: 2007-02-05, 05:52:16 PM »
The Data property of the Layer has a "TileMapping" property you can use to re-map tile values to different tiles in the TileSet.  Would this help?  For example:
Code: [Select]
ProjectObj.GamePlayer.rMap.Layer(0).Data.TileMapping(5) = 10
ProjectObj.GamePlayer.rMap.Layer(0).Data.TileMapping(6) = 14
This causes every tile 5 in the first layer of the player's map to be displayed (and act like) tile number 10 instead, and every tile number 6 will act like tile number 14.  You can do this for all tile values 0 through 255 at once if you like.  This won't work for animated tiles because they already use TileMapping internally to accomplish the animation.  But otherwise, you could use it.

dutch_619

  • Regular
  • **
  • Posts: 90
    • View Profile
    • Email
Re: inventory transparency
« Reply #4 on: 2007-02-05, 07:13:01 PM »
Actually thats a big help. Is the tile numbering run left to right, top to bottom? i.e. the tile at 0,0 (top left) is tile 0 while 2,0 is tile number 8 in a 4 column tile-set?

The limitation of 256  (0-255) seems to be inherent in the game code however. I was hoping to use a 1024 by 4086 .bmp image with the first 128*128 block set for transparent and then load the tiles sequentially.

While this results in an arbitrarily large number of tiles it does allow for a seamless and non repetitive sky layer for background. I could of course use a larger tile size but the game core seems to dislike that. I tried using One tile of 1024 by 4086 but the game ran at a very low frame rate.

I must admit to enjoying the speed and quality of answers to my questions. Thank you much.

bat

  • Fanatic
  • ***
  • Posts: 234
  • Cheak out the B*t project
    • MSN Messenger - ethanbatmay@hotmail.com
    • Yahoo Instant Messenger - ethanbatmay
    • View Profile
    • The B*t project
    • Email
Re: inventory transparency
« Reply #5 on: 2007-02-05, 09:01:47 PM »
VB is not really my thing it seems.

it's nobody's thing first off... practice, practice, practice!!!
i'm finally getting the hang of it!
there's some tutorials on the main website you should read.
i know programming seems so "unimportant", (that's wut i thought of it), but now im realizing how wrong i was....  ;)
~bat

durnurd

  • Lead Lemming
  • Expert
  • Fanatic
  • *****
  • Posts: 1234
  • Games completed so far: 0
    • MSN Messenger - durnurd@hotmail.com
    • View Profile
    • Find My Ed
Re: inventory transparency
« Reply #6 on: 2007-02-05, 10:24:08 PM »
What exactly are you putting into your 1024x4096 pixel tileset?  You could make one that's just for the background that could be the size of the map, (1024 x 768) and import the graphic from outside the graphics editor, and don't edit it within the editor, then place it within the map on its own layer.  Then use a different tileset for other graphics.
Edward Dassmesser

dutch_619

  • Regular
  • **
  • Posts: 90
    • View Profile
    • Email
Re: inventory transparency
« Reply #7 on: 2007-02-05, 11:49:03 PM »
The overall map size is 8192*1024. The sky layer is 5184*576 due to a lower than 1 to 1 scroll rate. I was hoping to automate the task of arranging tiles within a layer, without having to use the editing screen. The editor will only show a 2*2 block of tiles when the tile size is greater than 256*256, whatever the column and row count actually is. This makes it necessary to assign tiles without using the editor.

It turns out to be pretty easy to use the tile-mapping function in the data layer to do so. This particular problem seems to be solved.

Now I need to write a script for the playable sprite(s) to set a constant velocity that is modified by the left and right arrows. I want it to slow down on a left arrow and speed up on a right. I would like to slow the rate of change in direction as well; open up the turning radius.

bluemonkmn

  • SGDK Author
  • Administrator
  • Fanatic
  • *****
  • Posts: 2736
    • ICQ Messenger - 2678251
    • MSN Messenger - BlueMonkMN@gmail.com
    • View Profile
    • http://sgdk2.sf.net/
    • Email
Re: inventory transparency
« Reply #8 on: 2007-02-06, 07:21:43 AM »
Actually thats a big help. Is the tile numbering run left to right, top to bottom? i.e. the tile at 0,0 (top left) is tile 0 while 2,0 is tile number 8 in a 4 column tile-set?
2,0 to me means the third column in the first row, which would be tile number 2.  0,2 would be the first tile in the third row, which would be tile number 8 in a 4-column tileset.  (I almost always put the horizontal coordinate first -- x,y)

The limitation of 256  (0-255) seems to be inherent in the game code however.
Yes, version 1.x does limit you to 256 tiles per tileset.  Although you can get around it in some ways.  I think you can have more than 256 graphics in a tileset (by editing the GDP file directly in notepad if nothing else) and then use the extra tiles in a sprite template.  You can't, however, use more than 256 tile types in a layer because each tile only has one byte.

I was hoping to use a 1024 by 4086 .bmp image with the first 128*128 block set for transparent and then load the tiles sequentially.
That comes out to exactly 256 tiles (if you mean 4096, not 4086)... did that not work?

While this results in an arbitrarily large number of tiles it does allow for a seamless and non repetitive sky layer for background. I could of course use a larger tile size but the game core seems to dislike that. I tried using One tile of 1024 by 4086 but the game ran at a very low frame rate.
I think a lot of graphics cards/drivers limit you to "textures" no larger than a certain size, like 2048 or 1024.  Although that probably doesn't have anything to do with it because the "texture" is the whole tileset, and the size of that isn't changing -- just the size of the tile you're picking from it.  But if you're drawing 1024x4086 pixels every frame, that's a lot more than what you can see on the screen.  But I suppose the clipping should have made it only copy what it needed to.  So I'm not sure why it was slow.  If you think it was the tile size, why not try a happy medium tile size like 512x512?

The overall map size is 8192*1024. The sky layer is 5184*576 due to a lower than 1 to 1 scroll rate. I was hoping to automate the task of arranging tiles within a layer, without having to use the editing screen. The editor will only show a 2*2 block of tiles when the tile size is greater than 256*256
Are you talking about the map editor and the ability to select which tile you're drawing?  That will scroll vertically if your tileset doesn't fit on the screen, but not horizontally.  So you just have to make sure your tileset is not wider than your full screen map editor display.

Now I need to write a script for the playable sprite(s) to set a constant velocity that is modified by the left and right arrows. I want it to slow down on a left arrow and speed up on a right. I would like to slow the rate of change in direction as well; open up the turning radius.
So you will probably be setting the player sprite to be an "Inert" or "Scripted" sprite, then, so it is not directly affected by the keyboard?  "Inert" will still allow the sprite to automatically participate in collision detection and animation and inertia.  "Scripted" will leave most of that up to you in the script.
« Last Edit: 2007-02-06, 07:27:55 AM by bluemonkmn »

dutch_619

  • Regular
  • **
  • Posts: 90
    • View Profile
    • Email
Re: inventory transparency
« Reply #9 on: 2007-02-06, 02:46:44 PM »
I just found that the transparency question was asked earlier. I apologize for asking a repetitive question.

2,0 to me means the third column in the first row, which would be tile number 2.  0,2 would be the first tile in the third row, which would be tile number 8 in a 4-column tileset.  (I almost always put the horizontal coordinate first -- x,y)
Oops, I tend to use a z,y,x system personally. Gotta be different and all that. I find Maya is easier to use when set up this way. I see shapes more than images and its easier to manipulate simples.
That comes out to exactly 256 tiles (if you mean 4096, not 4086)... did that not work?
You are correct, The size was 4096, the 4086 was a typo. The 4086 is an array size I use on a project from work. The number is stuck in my head.
I think a lot of graphics cards/drivers limit you to "textures" no larger than a certain size, like 2048 or 1024.  Although that probably doesn't have anything to do with it because the "texture" is the whole tileset, and the size of that isn't changing -- just the size of the tile you're picking from it.  But if you're drawing 1024x4086 pixels every frame, that's a lot more than what you can see on the screen.  But I suppose the clipping should have made it only copy what it needed to.  So I'm not sure why it was slow.  If you think it was the tile size, why not try a happy medium tile size like 512x512?
In the end that is what I ended up using.  Anything over 512x512 is too unwieldy.
Are you talking about the map editor and the ability to select which tile you're drawing?  That will scroll vertically if your tileset doesn't fit on the screen, but not horizontally.  So you just have to make sure your tileset is not wider than your full screen map editor display.
In this instance I am refering to the layer editing screen. With a large tile size It will not scroll to the right to show the rest of the tiles. I can only pick the first 4 tiles. (0,0  0,1  1,0 and 1,1)
So you will probably be setting the player sprite to be an "Inert" or "Scripted" sprite, then, so it is not directly affected by the keyboard?  "Inert" will still allow the sprite to automatically participate in collision detection and animation and inertia.  "Scripted" will leave most of that up to you in the script.
Inert, definitely Inert. There will be quite enough scripting required to get the sprite to act the way I want as it is. Adding collision detection will be that much more to do. I think this has been addressed elsewhere in the forum as well. It seems possible to do this all within the source code, but that would mean the game is unplayable without using the installer. It woul make others games unplayable on their system as well. Scripts it is then.

bluemonkmn

  • SGDK Author
  • Administrator
  • Fanatic
  • *****
  • Posts: 2736
    • ICQ Messenger - 2678251
    • MSN Messenger - BlueMonkMN@gmail.com
    • View Profile
    • http://sgdk2.sf.net/
    • Email
Re: inventory transparency
« Reply #10 on: 2007-02-06, 06:21:20 PM »
In this instance I am refering to the layer editing screen. With a large tile size It will not scroll to the right to show the rest of the tiles. I can only pick the first 4 tiles. (0,0  0,1  1,0 and 1,1)
It won't scroll to the right, but it will scroll down, so you just have to re-arrange your tiles in fewer columns and more rows if you want to be able to select all the tiles.

dutch_619

  • Regular
  • **
  • Posts: 90
    • View Profile
    • Email
Re: inventory transparency
« Reply #11 on: 2007-02-06, 08:10:33 PM »
Thats what the tile slicer, assembler's for I guess.

Thanks for all the help.