Better map than a lot of pictureboxes?
Better map than a lot of pictureboxes?
Better map than a lot of pictureboxes?
Better map than a lot of pictureboxes?
Better map than a lot of pictureboxes?
Better map than a lot of pictureboxes? Better map than a lot of pictureboxes? Better map than a lot of pictureboxes? Better map than a lot of pictureboxes? Better map than a lot of pictureboxes? Better map than a lot of pictureboxes? Better map than a lot of pictureboxes? Better map than a lot of pictureboxes?
Better map than a lot of pictureboxes? Better map than a lot of pictureboxes?
Better map than a lot of pictureboxes?
Go Back  Xtreme Visual Basic Talk > > > Better map than a lot of pictureboxes?


Reply
 
Thread Tools Display Modes
  #1  
Old 08-08-2011, 10:36 PM
-LOC- -LOC- is offline
Centurion
 
Join Date: Aug 2005
Location: South Carolina, USA
Posts: 153
Default Better map than a lot of pictureboxes?


Right I need to make a map that can hold one of 6 options: 0 empty space 1 a home planet 2 conquered planets 3 enemy conquered planets 4 the enemy home world and 5 unoccupied worlds all of which needs to be clickable by the user.

The first (and so far the only) thing I thought up was a picutrebox with a lot of little pictureboxes setting inside in rows and columns. Then I'd fire up ye olde 2d array and Bobs-your-uncle-Baggies-your-aunt we have a map.

The scope of that above, though, proved to be a major pain. The maximum number of pictureboxes a picturebox can hold is 25*14 or 350 total. I did a simple trial to set this up. This is when I got to thinking that there might actually be a better way to do this. Err... and 350 pictureboxes are a lot really. But it does give me what I need: a map with intractable planets.

But even this gives me problems: I might need more than 350 pictureboxes (or rather more than 350 planets).

AND it is worth noting that I'd really like to not use APIs on this.

So can you all think up a better way or is this it!?
__________________
H. G. Wells and Jules Verne knew the future, too bad no one today remembers the past.

To truely write a program without a variable of any kind would be to not write a program at all.

Last edited by -LOC-; 08-09-2011 at 01:40 PM. Reason: To fix some gramar mistakes... Yes, I'm just that vain.
Reply With Quote
  #2  
Old 08-09-2011, 11:19 AM
passel's Avatar
passelBetter map than a lot of pictureboxes? passel is offline
Sinecure Expert

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

If you don't want to use APIs, then I would suggest using PaintPicture to paint your "tiles" to the map.
You keep track of what tile is at each point using a two dimensional (doesn't have to be two dimensional, but since you're probably in that mindset may as well continue) array.
You convert clicks on the map into X,Y coordinates to access your array, eg.
If your tiles were 32x32 pixels, and your array is 25 (0 to 24), by 14 (0 to 13) and your scalemode is set to pixels then:
TileX = X \ 32
TileY = Y \ 32
(where X,Y are the coordinates from your MouseDown or MouseUp event).

I don't know if the "simpleblt4.zip" example in post #6 of this thread would be of any use to you.
It doesn't use clicking on the background for tile selection, but it does draw a "map" background using four different "tiles".
In this case, the tiles and the map were just generated by random methods to provide a background for the car to simulate motion across a gaming area.
You can easily change the dimensions of the array to have a much larger map to "drive" on (default is 80 tiles by 240). For instance change the MaxXtile and MaxYTile constants by multiplying by 10 (800 x 2400), and you now have 100 times the area to drive around in. (Note changing the constants will cause an integer overflow, so change the constants to be Singles like this.
Const MaxXTile As Single = 800
Const MaxYTile As Single = 2400
)

Now the code uses the API to get access to BitBlt, but using the API in this manner is not a big deal since it is part of Windows and is easily used from VB.
But, if you really don't want to use the API (BitBlt), those calls can be replaced with PaintPicture. If you do, you will see how much slower it runs.
BitBlt is only used three places, once to draw the tiles, and twice to draw the car and mask. So, to replace those three instances with PaintPicture, make the following changes. Comment out the BitBlt calls, and replace with the PaintPicture.
I think you will be astonished by the difference in update speed.
Code:
'
    '  BitBlt Me.hDC, xt, yt, 32, 32, Picture1.hDC, t, 0, vbSrcCopy 'blit the tile
      Me.PaintPicture Picture1.Image, xt, yt, 32, 32, t, 0, 32, 32

'  BitBlt Me.hDC, CarMapX - mapL, CarMapY - mapT, CarWidth, CarLength, CarBmp.hDC, xo, yo, vbSrcPaint
'  BitBlt Me.hDC, CarMapX - mapL, CarMapY - mapT, CarWidth, CarLength, CarBmp.hDC, xo, yo + 288, vbSrcAnd
  Me.PaintPicture CarBmp.Image, CarMapX - mapL, CarMapY - mapT, CarWidth, CarLength, xo, yo, CarWidth, CarLength, vbSrcPaint
  Me.PaintPicture CarBmp.Image, CarMapX - mapL, CarMapY - mapT, CarWidth, CarLength, xo, yo + 288, CarWidth, CarLength, vbSrcAnd
The car is controlled by:
Up Arrow: move forward, toward the nose of the car.
Down Arrow: move backward, toward the rear of the car.
Left Arrow: Point front wheels to the left, turns left (counter-clockwise if moving forward, clockwise if moving backward)
Right Arrow: Turn right.
__________________
There Is An Island Of Opportunity In The Middle of Every Difficulty.
Miss That, Though, And You're Pretty Much Doomed.
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
Better map than a lot of pictureboxes?
Better map than a lot of pictureboxes?
Better map than a lot of pictureboxes? Better map than a lot of pictureboxes?
Better map than a lot of pictureboxes?
Better map than a lot of pictureboxes?
Better map than a lot of pictureboxes? Better map than a lot of pictureboxes? Better map than a lot of pictureboxes? Better map than a lot of pictureboxes? Better map than a lot of pictureboxes? Better map than a lot of pictureboxes? Better map than a lot of pictureboxes?
Better map than a lot of pictureboxes?
Better map than a lot of pictureboxes?
 
Better map than a lot of pictureboxes?
Better map than a lot of pictureboxes?
 
-->