How to blt an image on top of another?
How to blt an image on top of another?
How to blt an image on top of another?
How to blt an image on top of another?
How to blt an image on top of another?
How to blt an image on top of another? How to blt an image on top of another? How to blt an image on top of another? How to blt an image on top of another? How to blt an image on top of another? How to blt an image on top of another? How to blt an image on top of another? How to blt an image on top of another?
How to blt an image on top of another? How to blt an image on top of another?
How to blt an image on top of another?
Go Back  Xtreme Visual Basic Talk > > > How to blt an image on top of another?


Reply
 
Thread Tools Display Modes
  #1  
Old 12-17-2009, 09:23 PM
Chorcho Chorcho is offline
Newcomer
 
Join Date: Dec 2009
Posts: 8
Default How to blt an image on top of another?


Hello all! Im new here Anyway, i was making a Zelda style game in VB6 and everything was going fine 'till i ran into a problem. So i got the Hearts (you know like in Zelda) to blt once your HP drops, etc, i got past the logical part and i got it to blt in the screen too but the problem is that once a Heart is blt on screen it can't be replaced by another heart. Lets say i got a half of a heart and when i die the half heart remains there because it seems the empty heart is being rendered beneath it. So my question is: is there a way to get it blt in top of it, or speaking like a vulgar, to "unblt" the half heart when the empty heart is being rendered? Since the player can regenrate health and loose it, it would be convinient that each one can be on top of the other and vice versa. Sorry if im not being clear or confusing, im not english so its a bit hard .

Again, thanks.
Reply With Quote
  #2  
Old 12-18-2009, 05:52 AM
Iceplug's Avatar
IceplugHow to blt an image on top of another? Iceplug is offline
MetaCenturion

Retired Moderator
* Guru *
 
Join Date: Aug 2001
Location: Iowa, USA
Posts: 16,583
Default

Assuming you are talking about the heart meter in Legend of Zelda.
I recommend that you have three different images of hearts:
One of an empty heart - if you have no pic, just use a blank image
One of a half of a heart
One of a full heart

So, when you take damage or gain health, you examine what you use to store Link's HP to determine what hearts to draw...
then you blt all of the hearts. So, when you draw the empty heart it will be drawn over the half of a heart so that you have none of the half of a heart visible afterwards.

Do not think of anything in BitBlt to be like a control on the form that you can just make invisible or move it around without having to actually draw over the image that used to be there.
__________________

Iceplug, USN
Quadrill 1 Quadrill 2 (full) Quadrill 3 JumpCross .NET Website is ALIVE! - DL Platform Tour for VB.NET! Posting Guidelines Hint: Specify your location in your user cp profile if you want compassion!
Reply With Quote
  #3  
Old 12-18-2009, 06:01 AM
vb5prgrmrHow to blt an image on top of another? vb5prgrmr is offline
Senior Contributor

* Expert *
 
Join Date: Mar 2009
Posts: 1,087
Default

Iceplug beat me to it!!!!


Good Luck
Reply With Quote
  #4  
Old 12-18-2009, 07:48 AM
Chorcho Chorcho is offline
Newcomer
 
Join Date: Dec 2009
Posts: 8
Default

@Iceplug: I have all pics and am loading them correctly. Anyway: Yeah, thats exactly what im doing but for some reason they draw one under the other. What i am doing is calculate the players health and if the player's health is between X and Y it will blt the specified hearts, there are several checks and it takes care of each heart. However, contrary to what you said, i can't blt all of the hearts available, since like the original game, the player gets more heart meters as his/her health increases.

For example:

Code:
        If Player(MyIndex).MaxHp <= 60 And Player(MyIndex).HP > 45 Then
        Call BltHEART0
        Call BltHEART1
        ElseIf Player(MyIndex).MaxHp <= 60 And Player(MyIndex).HP <= 45 Then
        Call BltHEART0
        Call BltHHEART1
        ElseIf Player(MyIndex).MaxHp <= 60 And Player(MyIndex).HP <= 30 Then
        Call BltHEART0
        Call BltEHEART1
        ElseIf Player(MyIndex).MaxHp <= 60 And Player(MyIndex).HP <= 15 Then
        Call BltHHEART0
        Call BltEHEART1
        ElseIf Player(MyIndex).MaxHp <= 90 And Player(MyIndex).HP > 75 Then
        Call BltHEART0
        Call BltHEART1
        Call BltHEART2
        ElseIf Player(MyIndex).MaxHp <= 90 And Player(MyIndex).HP <= 75 Then
        Call BltHEART0
        Call BltHEART1
        Call BltHHEART2
        ElseIf Player(MyIndex).MaxHp <= 90 And Player(MyIndex).HP <= 60 Then
        Call BltHEART0
        Call BltHEART1
        Call BltEHEART2
etc.
etc.
As you can see i use predifined HP values to balance things and i make that loop so it's always checking. Oh, i also forgot to mention: As you can see in the code above, every 30HP (a heart container) the player gains is 1 more heart added to their meter and there are 20 Heart slots available each of them has 1 FullHeart a half one and an empty one in that slot. But, still, i can't get them to blt one on top of the other. Sorry again if im being confusing or unclear. Thanks.
Reply With Quote
  #5  
Old 12-18-2009, 08:55 AM
Iceplug's Avatar
IceplugHow to blt an image on top of another? Iceplug is offline
MetaCenturion

Retired Moderator
* Guru *
 
Join Date: Aug 2001
Location: Iowa, USA
Posts: 16,583
Default

What I mean is that you need to draw the hearts necessary.
i.e. if the player has a maximum of 5 full hearts, then you draw 5 empty heart containers.
If the player then has only three and a half hearts, you then draw, in addition to the 5 empty containers already drawn, three full hearts and one half heart on top of the empty hearts.
Don't just draw all 20 empty heart containers. Look at the maximum number of hearts you can hold and draw the containers accordingly.
__________________

Iceplug, USN
Quadrill 1 Quadrill 2 (full) Quadrill 3 JumpCross .NET Website is ALIVE! - DL Platform Tour for VB.NET! Posting Guidelines Hint: Specify your location in your user cp profile if you want compassion!
Reply With Quote
  #6  
Old 12-18-2009, 12:10 PM
Chorcho Chorcho is offline
Newcomer
 
Join Date: Dec 2009
Posts: 8
Default

Yeah i tried that. But the empty hearts always stay on top. Because every heart that is being blt into the screen will be under the one that was drawn first. Thats why im asking if there is a way to make them "stackable" so one can be on top of the other when told so. For example: I have the an empty heart, i tell it to draw a half heart, then the half heart is placed on top of the empty heart, the player looses HP and the game is told to redraw the empty heart, but this time on top of the half heart. Thanks.
Reply With Quote
  #7  
Old 12-18-2009, 01:10 PM
Iceplug's Avatar
IceplugHow to blt an image on top of another? Iceplug is offline
MetaCenturion

Retired Moderator
* Guru *
 
Join Date: Aug 2001
Location: Iowa, USA
Posts: 16,583
Default

If you are drawing the empty hearts first and then draw in the full hearts immediately afterward, you should not be seeing the empty hearts. Unless you pause between drawing the empty hearts and full hearts to end the subroutine or wait for a timer?

As I said earlier, you can't 'stack' things with BitBlt so that you can make some drawing disappear. You have to draw it only if it needs to be drawn and draw over it if you want something to appear in its place.
__________________

Iceplug, USN
Quadrill 1 Quadrill 2 (full) Quadrill 3 JumpCross .NET Website is ALIVE! - DL Platform Tour for VB.NET! Posting Guidelines Hint: Specify your location in your user cp profile if you want compassion!
Reply With Quote
  #8  
Old 12-18-2009, 04:13 PM
Chorcho Chorcho is offline
Newcomer
 
Join Date: Dec 2009
Posts: 8
Default

Yeah, i got around that. I got the other hearts to blt in top of the empty hearts, but now when the player looses health the half or full heart will still be on top of the empty heart. Is there a way to stop drawing the full or half heart? Thanks.
Reply With Quote
  #9  
Old 12-19-2009, 06:21 AM
Iceplug's Avatar
IceplugHow to blt an image on top of another? Iceplug is offline
MetaCenturion

Retired Moderator
* Guru *
 
Join Date: Aug 2001
Location: Iowa, USA
Posts: 16,583
Default

Yeah, use an If statement ...?
How are you drawing them now?
__________________

Iceplug, USN
Quadrill 1 Quadrill 2 (full) Quadrill 3 JumpCross .NET Website is ALIVE! - DL Platform Tour for VB.NET! Posting Guidelines Hint: Specify your location in your user cp profile if you want compassion!
Reply With Quote
  #10  
Old 12-19-2009, 01:28 PM
Chorcho Chorcho is offline
Newcomer
 
Join Date: Dec 2009
Posts: 8
Default

Look above where i posted some code: Thats how i am drawing them now: caluclate HP and draw the indicated hearts.
Reply With Quote
  #11  
Old 12-19-2009, 02:31 PM
Iceplug's Avatar
IceplugHow to blt an image on top of another? Iceplug is offline
MetaCenturion

Retired Moderator
* Guru *
 
Join Date: Aug 2001
Location: Iowa, USA
Posts: 16,583
Default

Well, what is in all of those subroutines that you are calling? I don't know what you are drawing when you say
Call BltHHEART0
Call BltEHEART1

At any rate, it doesn't seem like you say anywhere that you draw all of the empty heart containers. If you don't draw the empty heart containers, you will not have the hearts disappear.
And you want to draw all of the empty heart containers before you draw the full hearts.
__________________

Iceplug, USN
Quadrill 1 Quadrill 2 (full) Quadrill 3 JumpCross .NET Website is ALIVE! - DL Platform Tour for VB.NET! Posting Guidelines Hint: Specify your location in your user cp profile if you want compassion!
Reply With Quote
  #12  
Old 12-19-2009, 02:46 PM
Chorcho Chorcho is offline
Newcomer
 
Join Date: Dec 2009
Posts: 8
Default

Yes, i draw the empty hearts before drawing the other hearts. After drawing the empty hearts i calculate the HP and draw the hearts over them.
Like i said above:
This is the subroutine (they all look the same, but in total there are 20 for each empty heart, half heart and full hearts to change the position)
Code:
Sub BltHEART0()
    rec.Top = 0
    rec.Bottom = 16
    rec.Left = 0
    rec.Right = 16
    
    Call DD_BackBuffer.BltFast(50, 60, DD_HEARTSurf, rec, DDBLTFAST_WAIT Or DDBLTFAST_SRCCOLORKEY)
End Sub
And heres how i init DX7

Code:
'onscreen hearts
Public DD_HEARTSurf As DirectDrawSurface7
Public DDSD_HEART As DDSURFACEDESC2

'onscreen half hearts
Public DD_HHEARTSurf As DirectDrawSurface7
Public DDSD_HHEART As DDSURFACEDESC2

'onscreen empty hearts
Public DD_EHEARTSurf As DirectDrawSurface7
Public DDSD_EHEART As DDSURFACEDESC2

    ' Init HEARTs ddsd types and load the bitmaps
    DDSD_HEART.lFlags = DDSD_CAPS
    DDSD_HEART.ddsCaps.lCaps = DDSCAPS_OFFSCREENPLAIN Or DDSCAPS_SYSTEMMEMORY
    Set DD_HEARTSurf = DD.CreateSurfaceFromFile(App.path & "\data\HF.bmp", DDSD_HEART)
    SetMaskColorFromPixel DD_HEARTSurf, 0, 0
    
    ' Init Half HEARTs ddsd types and load the bitmaps
    DDSD_HHEART.lFlags = DDSD_CAPS
    DDSD_HHEART.ddsCaps.lCaps = DDSCAPS_OFFSCREENPLAIN Or DDSCAPS_SYSTEMMEMORY
    Set DD_HHEARTSurf = DD.CreateSurfaceFromFile(App.path & "\data\HHF.bmp", DDSD_HHEART)
    SetMaskColorFromPixel DD_HHEARTSurf, 0, 0
    
    ' Init Empty HEARTs ddsd types and load the bitmaps
    DDSD_EHEART.lFlags = DDSD_CAPS
    DDSD_EHEART.ddsCaps.lCaps = DDSCAPS_OFFSCREENPLAIN Or DDSCAPS_SYSTEMMEMORY
    Set DD_EHEARTSurf = DD.CreateSurfaceFromFile(App.path & "\Data\HE.bmp", DDSD_EHEART)
    SetMaskColorFromPixel DD_EHEARTSurf, 0, 0
Reply With Quote
  #13  
Old 12-19-2009, 03:35 PM
Iceplug's Avatar
IceplugHow to blt an image on top of another? Iceplug is offline
MetaCenturion

Retired Moderator
* Guru *
 
Join Date: Aug 2001
Location: Iowa, USA
Posts: 16,583
Default

Hmm... and all this time, I thought we were using BitBlt... ooops and I don't have DirectX 7 available on this computer.
Anyway, looking back over it, you *should* be fine without drawing all of the empty hearts... as long as you are drawing the applicable background every frame.

Also, now that I look at your HP numbers a bit closer, I hope those checks aren't actually in that order.

Code:
If Player(MyIndex).MaxHp <= 60 And Player(MyIndex).HP > 45 Then
        Call BltHEART0
        Call BltHEART1
        ElseIf Player(MyIndex).MaxHp <= 60 And Player(MyIndex).HP <= 45 Then
        Call BltHEART0
        Call BltHHEART1
        ElseIf Player(MyIndex).MaxHp <= 60 And Player(MyIndex).HP <= 30 Then
        Call BltHEART0
        Call BltEHEART1
        ElseIf Player(MyIndex).MaxHp <= 60 And Player(MyIndex).HP <= 15 Then
        Call BltHHEART0
        Call BltEHEART1
For instance, if your player .HP is 24, the first block that runs is the second one:
Code:
        ElseIf Player(MyIndex).MaxHp <= 60 And Player(MyIndex).HP <= 45 Then
        Call BltHEART0
        Call BltHHEART1
But you probably want to run the next one:
Code:
        ElseIf Player(MyIndex).MaxHp <= 60 And Player(MyIndex).HP <= 30 Then
        Call BltHEART0
        Call BltEHEART1
Let me know if you still have a problem.
__________________

Iceplug, USN
Quadrill 1 Quadrill 2 (full) Quadrill 3 JumpCross .NET Website is ALIVE! - DL Platform Tour for VB.NET! Posting Guidelines Hint: Specify your location in your user cp profile if you want compassion!
Reply With Quote
  #14  
Old 12-19-2009, 10:09 PM
Chorcho Chorcho is offline
Newcomer
 
Join Date: Dec 2009
Posts: 8
Default

Yeah, im starting to think its a problem with the algorithm. I might change the whole way it works. Thanks. Ill let you know how it goes.
Reply With Quote
  #15  
Old 12-20-2009, 06:54 AM
Iceplug's Avatar
IceplugHow to blt an image on top of another? Iceplug is offline
MetaCenturion

Retired Moderator
* Guru *
 
Join Date: Aug 2001
Location: Iowa, USA
Posts: 16,583
Default

Well, something that I would do to help streamline the process is to have the heart subroutine to accept an integer so that it draws the heart for that location.
Then, you could do something like

EHeartNum = .MaxHP \ 30
That will tell you how many empty hearts to draw
HeartNum = .HP \ 30
How many full hearts to draw.
HalfHeart = .HP Mod 30
.HP Mod 30 will return a non-zero number (15), indicating that you need to draw a half heart.

Then, you could do a For Loop, drawing hearts in accordance with the above values. The loop value could be passed in to the heart drawing subroutine to draw the heart at that particular location.
__________________

Iceplug, USN
Quadrill 1 Quadrill 2 (full) Quadrill 3 JumpCross .NET Website is ALIVE! - DL Platform Tour for VB.NET! Posting Guidelines Hint: Specify your location in your user cp profile if you want compassion!
Reply With Quote
  #16  
Old 12-20-2009, 06:08 PM
Chorcho Chorcho is offline
Newcomer
 
Join Date: Dec 2009
Posts: 8
Default

Yeah, i made a somewhat similar approach but keep the order like the past one. Got it to work. Thanks, you've been a great help

Last edited by Chorcho; 12-20-2009 at 07:48 PM. Reason: Resolved.
Reply With Quote
  #17  
Old 12-20-2009, 07:41 PM
Iceplug's Avatar
IceplugHow to blt an image on top of another? Iceplug is offline
MetaCenturion

Retired Moderator
* Guru *
 
Join Date: Aug 2001
Location: Iowa, USA
Posts: 16,583
Default

For HeartNum = 1 To HeartNum
Not a good idea to have your loop variable in your ending criteria.
Also
GetPlayerHP(MyIndex) Mod 30
is either 0 or 15... looping from 1 to 15 is pointless.
__________________

Iceplug, USN
Quadrill 1 Quadrill 2 (full) Quadrill 3 JumpCross .NET Website is ALIVE! - DL Platform Tour for VB.NET! Posting Guidelines Hint: Specify your location in your user cp profile if you want compassion!
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
How to blt an image on top of another?
How to blt an image on top of another?
How to blt an image on top of another? How to blt an image on top of another?
How to blt an image on top of another?
How to blt an image on top of another?
How to blt an image on top of another? How to blt an image on top of another? How to blt an image on top of another? How to blt an image on top of another? How to blt an image on top of another? How to blt an image on top of another? How to blt an image on top of another?
How to blt an image on top of another?
How to blt an image on top of another?
 
How to blt an image on top of another?
How to blt an image on top of another?
 
-->