VB .net scale images wrongly!

Started by
0 comments, last by Srekel 20 years, 8 months ago
I've made the beginning of a game where you see a guy from a top-down perspective. So far the map is a matrix that consists of either Floor or Obstacle. I have made two 32x32 bitmaps for those tiles, and for the character too, of course. I load the character into a PictureBox, and he looks alright after I set the AutoSize property. But I draw the map directly from file to the form. Screenshot: http://forum.sweclockers.com/attachment.php?s=&postid=2007862 The code for randomizing the map and drawing it:


	Private Sub Form1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint
		randomize
		dim generator as Double
		dim i,j, MAPSIZE, hasPlayerPos as Integer
		MAPSIZE = 7
		dim map2(MAPSIZE, MAPSIZE) as String
		for j = 0 to MAPSIZE
			for i = 0 to MAPSIZE
				generator = Rnd()
				if generator < 0.3
					map2(i,j)="Obstacle"
				else
					if hasPlayerPos = 1
						map2(i,j)="Floor"
					else
						map2(i,j)="Player"
						hasPlayerPos = 1
					end if
				End If
				label1.Text += map2(i,j)
			next
			label1.Text += "|"
		next
		' --- START DRAWING MAP ---
		'Dim g1 As Graphics										
		'g1 = Me.CreateGraphics									
		'Dim beam As New Pen(Color.Red)							
		'g1.DrawLine(beam,1,1,34,24)
		Dim MyImage1 As Image
		Dim x as Int16
		for j = 0 to MAPSIZE
			for i = 0 to MAPSIZE
				if map2(i,j) <> "Player"
					myimage1 = Image.FromFile("C:\Documents and Settings\Anders\Mina dokument\anders\Visual Studio Projects\Tactics\" & map2(i,j) & ".bmp")
						
						e.Graphics.DrawImage(myimage1, new Point(i*myimage1.Width,j*myimage1.Height))
				end if
			Next
		Next
	End Sub


 
Obviously VB knows that the images are 32x32, since that is how far it "jumps" when drawing the tiles. However, for some reason it draws them too big so that they don't fit! ------------------ "Kaka e gott" - Me Current project: An RPG with tactical, real-time combat with a realistic damage system, and randomly generated world and dialogue. [edited by - Srekel on August 5, 2003 2:24:55 PM] [edited by - Srekel on August 5, 2003 2:26:34 PM]
------------------"Kaka e gott" - Me
Advertisement
Nevermind, I solved it

There was an overloaded function that took four integers, where the last two were the height and width of the image.

I don''t know why I had to do it thought, I mean VB should''ve taken care of that by itself?
------------------"Kaka e gott" - Me

This topic is closed to new replies.

Advertisement