Sprites and MakeTransparent() Questions



  • seancampbellseancampbell Pennsylvania, USA
    Very nice! Looks like you figured it out.

    So, in summary,

    1. You create an Image object (in our code its a Bitmap called BMP)
    2. You draw all of the images you want onto that Image object in the order in which you want them, starting with the backmost img and ending with the foremost img.
    3. Lastly, You assign that Image object to PictureBox.Image


    Did that solve your original question?
  • Yeah. I have the "multiple levels of transparency" I wanted, and now understand why that question was so hard for most people to answer, the functionality was built in, I was just messing up the code pretty badly ;)

    The problems I'm having now are related to z-ordering the sprites (character, NPCs, and foreground tiles).

    I'm deciding which I'd prefer: to have a z-order attribute for each of my map objects, or to have the code generate the z-order on the fly based on the height of the object I'm drawing.

    This is the Map object I'm using (read from a text file).

    Public Class Map
    Public Name As String
    Public Tileset As Integer
    Public TileSize As Integer = 32
    Public NumTiles As Integer 'how many tiles to keep in memory
    Public FromMap As Integer 'where did the user come from
    Public ToMap As Integer ' where is the user headed
    Public CanExitFromStart As Integer
    Public Size As Integer ' width and height of map in "tilewidth"s
    Public BorderStyle As Integer '0 = clear, 1 = barriers,
    Public StartPointX As Integer ' x-coord of entry point
    Public StartPointY As Integer ' y-coord of entry point
    Public bmpTile(99) As Bitmap '100 foreground tiles
    Public bmpFloor As Bitmap ' base/floor tile
    ' visible mapset
    Public visible(99, 99) As Integer ' actual maximum Map.Size = 90 (0-4 and 95-99 are buffers)
    ' barriers mapset
    Public barriers(99, 99) As Integer ' actual maximum Map.Size = 90 (0-4 and 95-99 are buffers)
    Public OffsetX As Integer = 0 ' offset for drawing the map during character movement
    Public OffsetY As Integer = 0 ' offset for drawing the map during character movement

    I'd like to do something like:

    Public Class Map
    Public Name As String
    Public bmpTile(99) As Bitmap
    .height as Integer 'number of tiles high (normally 1)
    .width as Integer 'number of tiles wide (normally 1)

    The reason I'm worried about this is that my map files' data looks like this:

    01,01,01,01 'barrier data
    01,00,99,01 '00 = walkable, 02 = start point
    01,02,00,01 '99 = exit point
    01,01,01,01 '01 = blocked

    01,01,01,01 'visible map data
    01,00,11,01 '01 = bush (32,32)
    01,00,18,01 '11 = warp (32,32)
    01,01,19,01 '18 = tree top (32,32), 19 = tree bottom (32,32)

    If I can implement the above changes to my object I might be able to make the visible map look like this instead:

    01,01,01,01 'visible map data
    01,00,11,01 '01 = bush (32,32)
    01,00,00,01 '11 = warp (32,32)
    01,01,19,01 '19 = tree (64,32)

    This could potentially fix my z-order problems, as the program will draw the entire object when it gets down to the last line of the map, thus always drawing it in the right place.

    What do you think? Is there an easier way to implement this?

    The reason I want to take an object-oriented approach to solving this is that after I finish with the mapping I'll be moving on to the battle system where I don't expect any of my objects to conform to the confines of a "regularly" shaped tile.

  • seancampbellseancampbell Pennsylvania, USA
    I'm not entirely sure what you are asking. Are you saying that you want to create a ZOrder property which will tell the program what order to draw the sprites in? and have that based on the Height of the objects in the game?

    The only problem I see you running into with that is losing a lot of processing power doing the analysis each time it draws to check the Zorder of objects. I would suggest having an Entity layer that holds anything that is going to be outside of the Tile constraints and showup overtop of the player (like a tree only clocks 1 or 4 squares, but the leaves extend out for many squares). This entity layer would get drawn last in the order of drawing stuff.

    Clarify your request for me in a new post, and we'll take it from there!
  • Here are the layers it looks like I'll need:

    Floor (drawn first, everything covers it)
    Barrier Layer (tells us where the character can and cannot go)
    Standard 32x32 foreground objects
    Irregular objects (houses, player, NPCs)
    Overhead layer (alpha layer of clouds)

    The reason I want a separate barrier layer is so I can add secret tunnels through solid looking objects.
    Right now, however, my code is handling simple 32x32 tiles improperly :( so I need to tackle that.

    I can send you my code if you'd like, but this forum wouldn't brthe best place for that kind of sharing ;)

  • seancampbellseancampbell Pennsylvania, USA
    There are nearly limitless possible solutions to tackle what you are trying to do. The approach I would take may not be similar to the one you would.

    I wouldn't mind helping you solve specific problems, but it's really up to you to do the rest.

    That said, if you're still having problems with some specific code, start a new thread and write out a description of your problem and provide som sample code and I'll gladly help you
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!