Dennys Posted June 5, 2011 Author Share Posted June 5, 2011 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 anythingFirst 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 DirectDrawSurface7Public 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 Suberrorhandler: HandleError "BltImage", "modDirectDraw7", Err.Number, Err.Description, Err.Source, Err.HelpContext Err.Clear Exit SubEnd Sub```In the Sub DestroyDirectDraw add the following code before Exit Sub:```Set DDS_Image = NothingZeroMemory 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 LongEnd 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 SubSub ClearImage(ByVal Index As Long) Call ZeroMemory(ByVal VarPtr(Image(Index)), LenB(Image(Index))) ' Error handler Exit Suberrorhandler: HandleError "ClearAnimation", "modDatabase", Err.Number, Err.Description, Err.Source, Err.HelpContext Err.Clear Exit SubEnd 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 More sharing options...
PD Posted June 5, 2011 Share Posted June 5, 2011 This should help a few people out. Nice tut ;D Link to comment Share on other sites More sharing options...
Lavos Posted June 5, 2011 Share Posted June 5, 2011 lol this really looks very familier. Link to comment Share on other sites More sharing options...
Dennys Posted June 5, 2011 Author Share Posted June 5, 2011 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 More sharing options...
Link Posted June 5, 2011 Share Posted June 5, 2011 @Bloodmyst:> -post-That's funny my post from earlier disappeared anyway looks like zesh has won anyway. Link to comment Share on other sites More sharing options...
Dennys Posted June 5, 2011 Author Share Posted June 5, 2011 What post? and what did Zesh win? and please dont quote my entire post that takes alot of space. Link to comment Share on other sites More sharing options...
Craselin Posted June 6, 2011 Share Posted June 6, 2011 Sorry I'm not saying this is bad or anything I was just asking:What does it do exactly?(i win a fail for newbiness) Link to comment Share on other sites More sharing options...
Dennys Posted June 6, 2011 Author Share Posted June 6, 2011 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 More sharing options...
BugSICK Posted June 12, 2011 Share Posted June 12, 2011 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 More sharing options...
Dennys Posted June 12, 2011 Author Share Posted June 12, 2011 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. Link to comment Share on other sites More sharing options...
MrKris Posted June 12, 2011 Share Posted June 12, 2011 I have seen this somewhere before :O I can't put my finger on it though. Link to comment Share on other sites More sharing options...
Derryl Posted June 12, 2011 Share Posted June 12, 2011 @Kris:> I have seen this somewhere before :O I can't put my finger on it though.http://www.touchofdeathforums.com/smf/index.php/topic,56700.0.html^ But it's for EE. Link to comment Share on other sites More sharing options...
Dennys Posted June 12, 2011 Author Share Posted June 12, 2011 @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 More sharing options...
BugSICK Posted June 14, 2011 Share Posted June 14, 2011 @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 More sharing options...
Dennys Posted June 14, 2011 Author Share Posted June 14, 2011 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 LongEnd 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 Suberrorhandler: HandleError "Image", "modDatabase", Err.Number, Err.Description, Err.Source, Err.HelpContext Err.Clear Exit SubEnd Sub``` Link to comment Share on other sites More sharing options...
BugSICK Posted June 14, 2011 Share Posted June 14, 2011 wow nice thank you, what command should i click or type in chatbox to make the image appeared because i dont see buttons or commands. thanks i will try this now. Link to comment Share on other sites More sharing options...
Dennys Posted June 14, 2011 Author Share Posted June 14, 2011 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 More sharing options...
BugSICK Posted June 14, 2011 Share Posted June 14, 2011 thanks this is what i need. thanks for the help. i dont test it but its a big help/ +1 credit ^^ Link to comment Share on other sites More sharing options...
gdog12356 Posted June 19, 2011 Share Posted June 19, 2011 how can i blt images over 32x32? Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now