Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

[EO 2.0] Blting Images on the picScreen


Dennys
 Share

Recommended Posts

The Last couple of days i have been trying to make an image appear on the picScreen, after receiving an idea from Skillzalot i followed the BltBlood Sub and successfully Blted an Image on the picScreen. Here is what ive learned.

Image width and height must be 32x32 for it to work.

It is all Client Side:
**modDirectDraw7**
You may change "Image" on the following codes to anything

First you need to declare a new Direct Draw Surface.
After Option Explicit add something similiar to this. You may change "Image" at your discretion:
```
Public DDS_Image As DirectDrawSurface7
Public DDSD_Image As DDSURFACEDESC2
```
In Private Sub InitSurfaces() add:
```
If FileExist(App.Path & "\data files\graphics\image.bmp", True) Then Call InitDDSurf("image", DDSD_Image, DDS_Image)
```In this code you need to change "\data files\graphics\image.bmp" to the path where your image is located (for it to work it must be somewhere inside of your graphics folder) and the "image" in InitDDSurf has to be changed to the name of the folder\image name without bmp, For Example if image is named "arrow" and it is in the folder called animations the code woudl look like this:
```
If FileExist(App.Path & "\data files\graphics\animations\arrow.bmp", True) Then Call InitDDSurf("animations\arrow", DDSD_Image, DDS_Image)
```
At the bottom add the following sub:
```
Public Sub BltImage(ByVal Index As Long)
Dim rec As DxVBLib.RECT
  ' If debug mode, handle error then exit out
    If Options.Debug = 1 Then On Error GoTo errorhandler

    With Image(Index)
        rec.top = 0
        rec.Bottom = PIC_Y
        rec.Left = (.Sprite - 1) * PIC_X
        rec.Right = rec.Left + PIC_X
        Engine_BltFast ConvertMapX(.x * PIC_X), ConvertMapY(.y * PIC_Y), DDS_Image, rec, DDBLTFAST_WAIT Or DDBLTFAST_SRCCOLORKEY
    End With

    ' Error handler
    Exit Sub
errorhandler:
    HandleError "BltImage", "modDirectDraw7", Err.Number, Err.Description, Err.Source, Err.HelpContext
    Err.Clear
    Exit Sub
End Sub
```
In the Sub DestroyDirectDraw add the following code before Exit Sub:
```
Set DDS_Image = Nothing
ZeroMemory ByVal VarPtr(DDSD_Image), LenB(DDSD_Image)
```
In the Sub Called Render_Graphics() Search for
```
' render the decals
```And under it add
```
For i = 1 To MAX_BYTE
    Call BltImage(i)
Next
```
**modTypes**

I added in their appropriate locations:

```
Public Image(1 To MAX_BYTE) As ImageRec
```
```
Private Type ImageRec
    Sprite As Long
    x As Long
    y As Long
End Type
```
**modDatabase**

Add the following at the bottom:
```
Sub Image(ByVal Index As Long, ByVal x As Long, ByVal y As Long)
    With Image(Index)
        .x = x
        .y = y
        .Sprite = 1
    End With
    Call BltImage(Index)
End Sub
Sub ClearImage(ByVal Index As Long)
    Call ZeroMemory(ByVal VarPtr(Image(Index)), LenB(Image(Index)))
    ' Error handler
    Exit Sub
errorhandler:
    HandleError "ClearAnimation", "modDatabase", Err.Number, Err.Description, Err.Source, Err.HelpContext
    Err.Clear
    Exit Sub
End Sub
```
And that is it. You may call it by using
```
Call Projectile(Index, X, Y)
```Changing X to the X Coordinate and Y to the Y Coordinate that you want your image to appear in. And Index to a Number under which the image will be store.

And to get rid of the image call:
```
Call ClearProjectile(Index)
```Index beign the same number you used to call it.

If anyone has any improvements upon this code please post it and i will add.
Link to comment
Share on other sites

Thanks Zesh, its not complete though, i still need to figure out how to be able to choose dynamic image sizes and how to be able to use different pictures with one Sub instead of making a sub for each picture. If anyone is willign to help please do.

And Banana what does it look similiar to?
Link to comment
Share on other sites

This is a manual way of drawing images on the map. You can choose what image to display the position in the map (X, Y coordinate) and you can also remove it by a simple command. I dont really know what it would be usefull for, what iam trying to use it from is simply learning how blting works so that i can create a projectile system. But you can use it for any number of things such as displaying temporary tiles on the map, it really depends on what your game needs. Right no with only display images on the client that sends the command but that can be fixed by a simple packet.
Link to comment
Share on other sites

i will add this on my game but i have some questions.
on a click command like a button or the "/" command, when i clicked the button the image will appear in the picsreen then it will disappeared in like 3 secs. like blood it appeared when npc is killed then disappeared in sec.

** im not a coder  :mad:
Link to comment
Share on other sites

@Kris:

> I have seen this somewhere before :O I can't put my finger on it though.

Why do people keep posting this, everything on here is code written in EO 2 that has been modified slightly. Ofcourse you could have seen this somewhere before, stop writing useless posts.
Link to comment
Share on other sites

@Bloodmyst:

> I didnt leave any timers in the script so this shoulnt be happening. I tested it out in my client and it lasts aslong as you dont call Sub ClearImage.

because i am planing putting an image with a command. example i write the command /open then an image will pop-up then will be close in 3 secs. how will i do that?
Link to comment
Share on other sites

Oh you want it to do that i thought you where saying that it was doing that. Let me see. That is simple. But you got to change a few things:

First in ModTypes Look for:
```
Private Type ImageRec   
    Sprite As Long   
    x As Long   
    y As LongEnd Type

```and replace it with:
```
Private Type ImageRec
    Sprite As Long
    Timer As Long
    X As Long
    Y As Long
End Type
```
Now in modDirectDraw7 Go to the Sub BltImage()
Under The line:
```
With Image(Index)
```Place the following:
```
If .Timer + 3000 < GetTickCount Then Exit Sub
```The 3000 in this^ code controls the time before it dissapears. It is the amount of miliseconds so after 3000 ms which equals 3 seconds it will dissapear.

Lastly in modDatabase look for Sub Image() and replace it with this:
```
Sub Image(ByVal Index As Long, ByVal X As Long, ByVal Y As Long)
    With Image(Index)
        .X = X
        .Y = Y
        .Sprite = 1
        .Timer = GetTickCount
    End With
    Call BltImage(Index)
    ' Error handler
    Exit Sub
errorhandler:
    HandleError "Image", "modDatabase", Err.Number, Err.Description, Err.Source, Err.HelpContext
    Err.Clear
    Exit Sub
End Sub
```
Link to comment
Share on other sites

Here go to modInput in the client and search for "Select Case Command(0)" without the quotation signs.
and under that line add:

Case "/CallImage"
    Call Projectile(Index, X, Y)

Change "/CallImage" to the text command you would like to make the image appear with.
Change Index to a number not higher than 254.
Change X to the X coordinate.
Change Y to the Y coordinate.
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...