Help with tiling a form isometrically(pic)

nem33

Member
Joined
Mar 17, 2003
Messages
23
I can turn a 32x32 square tile 45degrees and then paint that tile to the form in one straight - top to bottom - line.. The code below does that..But how exactly would I tile the entire form? I have not seen any good tutorials in vb.NET for doing this sort of thing. I could make a For Next loop to tile each line from top to bottom - but obviously that is not going to cut it. There are so many more questions I have with graphics, VB.NET, and the isometric perspective. Any help on this is appreciated. Thank you.
Code:
    Dim G As Graphics
    initiate an object for our bitmap
    Dim bmap As Bitmap
   

  Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        assign value to G
        G = Me.CreateGraphics()
        load our bitmap
       bmap = New Bitmap("C:\graphics\grass32x32.bmp")
    End Sub

    Private Sub Form1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles MyBase.KeyPress
        
        Dim I As Integer
        Dim y As Integer
        Dim x As Integer
        
        G.RotateTransform(45) Turn graphic 45 degrees
        If e.KeyChar = "u" Then
            For I = 1 To 25 Draw tile 25 times
                x = x + 40
                y = y + 40
                G.DrawImage(bmap, x, y)
            Next
        End If
    End Sub
This is what it looks like..
[Broken External Image]:http://home.centurytel.net/ancientfaces/tile.jpg
 
Also I want to point out that in my code - after I rotate the graphics object 45 degrees, the x,y positions seem to rotate as well..
.[Broken External Image]:http://home.centurytel.net/ancientfaces/isorotate.jpg



So I would add +40 pixels to both the x and y coordinates every draw to achieve a top to bottom image of rotated tiles. Kind of interesting it rotates the x and y coords when you rotate the graphic.
 
Last edited by a moderator:
First off, dont rotate your graphics in code. Its inefficient, and if youre entire game is going to be pseudo-isometric, it doesnt make any sense. Draw them as diamonds. :)

Second, youre going to end up with a nasty UO-looking game using a full rotated square. If you want a true iso perspective (a la Diablo), youll have to use a 2:1 ratio tile, which is half the height.

Im looking for a great isometric game tutorial (it was in C++, but it taught you everything you need to know) I found many moons ago. Until then, there are plenty of others which will suit your needs:

http://www.google.com/search?hl=en&lr=&ie=UTF-8&oe=utf-8&q=visual+basic+isometric+game+tutorial&btnG=Google+Search

Good luck!
 
Back
Top