?
Solved

Visual basic tile map

Posted on 2003-03-14
5
Medium Priority
?
527 Views
Last Modified: 2009-07-29
I am just wondering what is the best way of doing this for smoothest operation.  I will be making a tile map that they can right click on the map and move map up and down in the form.  The form will take up about a 4th of the screen and by clicking on castles on the map other forms pop up to give them choices to do things.  I was wondering what would be the smoothest for the map scrolling around, they will be pretty large maps so I cant draw whole map at once.  Things I have seen are api calls and direct x just wondering if anyone out there knows much about this?  If so i will be asking more questions in direct relation to your answer and will keep feeding you points for each question.
Thanks in advance.
0
Comment
Question by:Hook333
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 1

Expert Comment

by:Hermetic
ID: 8138138
You should definitely use a double-buffer technique.  I have used two offscreen PictureBoxes and used the GDI BitBlt function to paint only the required section of the screen from the pb used as the source map to the pb used as the back buffer.  Then I use BltFast to move the image from the back buffer pb to the visible picture box.  I could probably post some example code if necessary.
0
 

Author Comment

by:Hook333
ID: 8139746
the example code would be awesome I will up the points to 350 for the sample code.  Also is there a way to direct you to my future questions as I will have more but want to give all points to one person who is helping me with them?
Thanks for the help.
0
 
LVL 1

Accepted Solution

by:
Hermetic earned 1400 total points
ID: 8140210
Three PictureBoxes.
In the original source, there were a couple of scroll bars
and alot of code to get them positioned just right.  I have omitted it to make the example more clear.
The Picture Boxes are all set to scalemode vbPixel.
The Backbuffer and Source are set to AutoRedraw.
====================================
Public Declare Function BitBlt Lib "gdi32" (ByVal hDestDC As Long, ByVal x As Long, ByBal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC as Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal dwRop As Long) As Long

Public Sub RefreshMap()
   'picSrc = Invisible Picture Box containing whole map
   'picBack = Invisible Picture Box for back buffer and work.
   'picDest = Picture Box for displaying to user.

   Dim picSrc As PictureBox
   Dim picBack As PictureBox
   Dim picDest As PictureBox

   Dim StartX As Long
   Dim StartY As Long

   Set picSrc = MainForm.pbSource
   Set picBack = MainForm.pbBack
   Set picDest = MainForm.pbMap

   StartX = -MainForm.HScrollMap.Value
   StartY = -MainForm.VScrollMap.Value

   BitBlt picBack.hDC, 0, 0, _
        picBack.ScaleWidth, picDest.ScaleHeight, _
        picSrc.hDC, StartX, StartY, vbSrcCopy

   'Do other things to picBack here like draw
   'on map text messages, sprites, etc.

   BitBlt picDest.hDC, 0, 0, _
        picDest.ScaleHeight, picDest.ScaleWidth, _
        picDest.hDC, 0, 0, vbSrcCopy

End Sub
======================================

As for directing questions directly to me, that is not the
typical format of this forum.  I think people typically
use the subject line to say "Question for:" but I wouldn't
recommend it.  There are quite a few experts in here and
it pays to hedge your bets.
0
 

Author Comment

by:Hook333
ID: 8140559
ok I will keep them open then I was just going to let you know when I posted new ones so you could look at them.  thanks for the help I will award you the points for this one.
0
 

Author Comment

by:Hook333
ID: 8140565
did you get the 350 points?
0

Featured Post

Enroll in August's Course of the Month

August's CompTIA IT Fundamentals course includes 19 hours of basic computer principle modules and prepares you for the certification exam. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

What is RenderMan: RenderMan is a not any particular piece of software. RenderMan is an industry standard, defining set of rules that any rendering software should use, to be RenderMan-compliant. Pixar's RenderMan is a flagship implementation of …
Recently, in one of the tech-blogs I usually read, I saw a post about the best-selling video games through history. The first place in the list is for the classic, extremely addictive Tetris. Well, a long time ago, in a galaxy far far away, I was…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Suggested Courses

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question