bitblt default image.
bitblt default image.
bitblt default image.
bitblt default image.
bitblt default image.
bitblt default image. bitblt default image. bitblt default image. bitblt default image. bitblt default image. bitblt default image. bitblt default image. bitblt default image.
bitblt default image. bitblt default image.
bitblt default image.
Go Back  Xtreme Visual Basic Talk > > > bitblt default image.


Reply
 
Thread Tools Display Modes
  #1  
Old 06-06-2011, 11:19 AM
wkk wkk is offline
Newcomer
 
Join Date: Jun 2011
Posts: 3
Default bitblt default image.


Hello.

I'm using bitblt to build a square field like the one bellow.

http://i53.tinypic.com/531x03.png

I want each square to have a default image but i do not know how to do that...
This is the function drawing the field:
Code:
Private Sub DrawField()

    field.Cls
    Dim i As Long, x As Long, y As Long

    field.Width = lSquaresX * 20
    field.Height = lSquaresY * 20
    sWidth = field.ScaleWidth
    sHeight = field.ScaleHeight
    For i = 20 To sHeight Step 20
        field.Line (0, i)-(sWidth, i), &H0   
    Next i
    
    For i = 20 To sWidth Step 20  
        field.Line (i, 0)-(i, sHeight), &H0   
    Next i
    On Error Resume Next
    For x = 0 To lSquaresX
        For y = 0 To lSquaresY
            If Player.Cell(x, y).Used Then
                Call BitBlt(Me.field.hDC, x * 20, y * 20, picPart(Player.Cell(x, y).lPartID).ScaleWidth, _
                picPart(Player.Cell(x, y).lPartID).ScaleHeight, picPart(Player.Cell(x, y).lPartID).hDC, _
                0, 0, SRCAND)
            End If
            
        Next y
    
    Next x
       
End Sub
Any help is greatly appreciated.
Reply With Quote
  #2  
Old 06-06-2011, 04:25 PM
passel's Avatar
passelbitblt default image. passel is offline
Sinecure Expert

Super Moderator
* Guru *
 
Join Date: Jun 2003
Location: Upstate New York, usa
Posts: 8,028
Default

I assume you mean if the field isn't "Used" then display a default, so add an Else case to your If block.
Code:
'...
        For y = 0 To lSquaresY
            If Player.Cell(x, y).Used Then
                Call BitBlt(Me.field.hDC, x * 20, y * 20, picPart(Player.Cell(x, y).lPartID).ScaleWidth, _
                picPart(Player.Cell(x, y).lPartID).ScaleHeight, picPart(Player.Cell(x, y).lPartID).hDC, _
                0, 0, SRCAND)
            Else
              BitBlt Me.field.hDC, x * 20, y * 20,.....default.hDC,....
            End If
            
        Next y
__________________
There Is An Island Of Opportunity In The Middle of Every Difficulty.
Miss That, Though, And You're Pretty Much Doomed.
Reply With Quote
  #3  
Old 06-07-2011, 05:39 AM
surfR2911 surfR2911 is offline
Contributor
 
Join Date: Oct 2009
Posts: 719
Default Further help..

Quote:
Originally Posted by wkk
Any help is greatly appreciated.
An alternative approach is to set up a DrawSquare routine then incorporate it into a DrawMap routine.

There used to be a good tutorial by Mark Butler. Sadly the site is no longer maintained, but is still archived elsewhere:
http://web.archive.org/web/200701010...al/default.htm

The source code for the first part of the tutorial is archived here.

Someone name Breezer also posted a slightly modified version of the code in this thread:
RPG Tutorial Game

Good luck on your game and hope it develops further..
Reply With Quote
  #4  
Old 06-07-2011, 06:49 AM
wkk wkk is offline
Newcomer
 
Join Date: Jun 2011
Posts: 3
Default

Quote:
Originally Posted by passel View Post
I assume you mean if the field isn't "Used" then display a default, so add an Else case to your If block.
Code:
'...
        For y = 0 To lSquaresY
            If Player.Cell(x, y).Used Then
                Call BitBlt(Me.field.hDC, x * 20, y * 20, picPart(Player.Cell(x, y).lPartID).ScaleWidth, _
                picPart(Player.Cell(x, y).lPartID).ScaleHeight, picPart(Player.Cell(x, y).lPartID).hDC, _
                0, 0, SRCAND)
            Else
              BitBlt Me.field.hDC, x * 20, y * 20,.....default.hDC,....
            End If
            
        Next y
Hmm, actually the "Used" is a boolean variable initiated at false. So the check i am making is "if the field is not used", and when it is not used i want it to display a default background for each square.

This image will then be modified in runtime, i can do that part pretty well, i just can not add an image to the bitblt construction, everytime i do so it pops up only on the first square.
Reply With Quote
  #5  
Old 06-08-2011, 02:57 AM
passel's Avatar
passelbitblt default image. passel is offline
Sinecure Expert

Super Moderator
* Guru *
 
Join Date: Jun 2003
Location: Upstate New York, usa
Posts: 8,028
Default

Sounds like you don't understand how "If" works.
If the Used variable is False, your code shouldn't do anything because the code inside the If ... End If block will only execute if .Used is True.
If you want the code to do something when .Used is False, you have to specify that in the Else block, or check for the False case (which will return True if the value is False).
i.e.
If Player.Cell(x,y).Used = False Then 'will return true if .Used is false, so executes the code in the if...end if block.
or
If Not Player.Cell(x,y).Used Then 'will return the opposite of .Used, so if .Used is false, returns True and the code in the If ... End If is executed.

My assumption is that if the cell is used, you want to draw something based on .lPartID, else you want to draw a default image. That is what I intended.
I coded up a quick example, using your DrawField code with minor changes.
In the Form Load I create a default image, and two images selected by .lPartID being equal to 0 or 1.
I added a MouseDown event handler, to change the .Used boolean and set .lPartID when you click on a cell. It then calls the DrawField sub to redraw the field. You'll see it draws the default image in all the cells that are not marked as being used.

The three small pictureboxes that hold the default image and the two "dynamic" images are left visible so you can see the source images for the bitblt, but they do not need to be visible. You can set the visible property to false on those three pictureboxes and the code will still work fine.
Attached Files
File Type: zip defaultblt.zip (2.2 KB, 13 views)
__________________
There Is An Island Of Opportunity In The Middle of Every Difficulty.
Miss That, Though, And You're Pretty Much Doomed.
Reply With Quote
  #6  
Old 06-08-2011, 12:29 PM
wkk wkk is offline
Newcomer
 
Join Date: Jun 2011
Posts: 3
Default

I do understand how if works, i'm just not quite into the bitblt drawing...

That was exactly what i wanted, thanks a lot
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
bitblt default image.
bitblt default image.
bitblt default image. bitblt default image.
bitblt default image.
bitblt default image.
bitblt default image. bitblt default image. bitblt default image. bitblt default image. bitblt default image. bitblt default image. bitblt default image.
bitblt default image.
bitblt default image.
 
bitblt default image.
bitblt default image.
 
-->