LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 06-23-2012, 01:03 PM   #1
errigour
Member
 
Registered: May 2009
Posts: 366

Rep: Reputation: 6
My Visual basics program isn't running properly, Why?


It's a form project pretty easy to test it. You can comment out the lines In DoGraphics and comment out the other ones and it works fine. One note, on my computer i'm running Visual Basics 2010 and the project program runs in the backround and I can't end the process I have to close Visual Basics, I think it's because of DrawGraphics().

It's just two files. I'll post the source code for the main file and some instructions on helping.

The first file Zelda Build.vb has a Form I Named ZeldaBuild that is 750 X 550 and Has the Text Zelda Build.

The Second file is called GFX.vb named pbGFX I made the text GFX atm but that's not to important. Anyways just make sure to add a picture box and size the window and the picture box to 640 X 480 Then you can sample it, I used a tileset bmp 640 X 480.

There's no code for GFX I'm just using it for the image at the moment but there will be. Ok here's the code for Zelda Build.vb
this is where the problem is.

I would be much oblidged if someone would shine some light on this subject.

filename: Zelda Build.vb
Code:
Imports System.Drawing

Public Class ZeldaBuild

    ' Grid Integers
    Dim ResWidth As Integer = 750
    Dim ResHeight As Integer = 550
    Dim TileSize As Integer = 32

    ' Graphics Variables
    Dim G As Graphics
    Dim G2 As Graphics
    Dim BBG As Graphics
    Dim BB As Bitmap
    Dim bmpTile As Bitmap
    Dim sRect As Rectangle
    Dim dRect As Rectangle

    ' FPS Counter
    Dim tSec As Integer = TimeOfDay.Second
    Dim tTicks As Integer = 0
    Dim MaxTicks As Integer = 0

    ' Map Variables
    Dim Map(100, 100, 10) As Integer
    Dim MapX As Integer = 20
    Dim MapY As Integer = 20

    ' Mouse integers
    Dim mouseX As Integer
    Dim mouseY As Integer
    Dim mMapX As Integer
    Dim mMapY As Integer

    Dim PaintBrush As Integer = 0

    ' Game Running?
    Dim IsRunning As Boolean = True

    Private Sub ZeldaBuild_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Me.Show()
        Me.Focus()

        'Initialize Graphics Objects
        G = Me.CreateGraphics
        BB = New Bitmap(ResWidth, ResHeight)
        bmpTile = New Bitmap(GFX.pbGFX.Image)

        StartGameLoop()
    End Sub

    Private Sub StartGameLoop()
        Do While IsRunning = True
            ' Keep Application Responsive
            Application.DoEvents()

            '1.) Check User Input
            '2.) Run AI
            '3.) Update Object Data (Object Position, Status, etc.)
            '4.) Check Triggers And Conditions
            'TileSize.) Draw Graphics
            DrawGraphics()
            '6.) Play Sound Effects & Music
            '7.) Update Tick Counter
            TickCounter()
        Loop
    End Sub

    Private Sub DrawGraphics()
        ' Fill The Backbuffer
        ' Draw Tiles
        For x = 0 To 19
            For y = 0 To 14
                'sRect = New Rectangle(x * TileSize, y * TileSize, TileSize, TileSize)

                'Select Case Map(MapX + x, MapY + y, 0)
                '    Case 0
                '        G.FillRectangle(Brushes.White, sRect)
                '    Case 1 ' Red
                '        G.FillRectangle(Brushes.Red, sRect)
                '    Case 2 ' Blue
                '        G.FillRectangle(Brushes.Blue, sRect)
                'End Select

                'G.DrawRectangle(Pens.Black, sRect)
                GetSourceRect(MapX + x, MapY + y, TileSize, TileSize)
                dRect = New Rectangle(x * TileSize, y * TileSize, TileSize, TileSize)
                G.DrawImage(bmpTile, dRect, sRect, GraphicsUnit.Pixel)
            Next
        Next

        ' Highlight mouse sqaure
        G.FillRectangle(Brushes.Red, 21 * TileSize, 4 * TileSize, TileSize, TileSize)
        G.FillRectangle(Brushes.Blue, 21 * TileSize, 6 * TileSize, TileSize, TileSize)
        G.DrawRectangle(Pens.Black, 21 * TileSize, 8 * TileSize, TileSize, TileSize)

        G.DrawRectangle(Pens.Red, mouseX * TileSize, mouseY * TileSize, TileSize, TileSize)

        ' Draw Final Layers
        ' Guys, Menus, ETC.
        ' Draw TIcks And Ticks Per Second
        G.DrawString("Ticks: " & tTicks & vbCrLf & _
                     "TPS: " & MaxTicks & vbCrLf & _
                     "Mouse X pos: " & mouseX & vbCrLf & _
                     "Mouse Y pos: " & mouseY & vbCrLf & _
                     "M Mouse X: " & mMapX & vbCrLf & _
                     "M Mouse Y: " & mMapY & vbCrLf & _
                     "", Me.Font, Brushes.Black, 19 * TileSize + TileSize, 0)

        G = Graphics.FromImage(BB)

        ' Draw Backbuffer To Screen
        BBG = Me.CreateGraphics

        ' Copy Backbuffer To Graphics Object
        BBG.DrawImage(BB, 0, 0, ResWidth, ResHeight)

        ' Fix OverDraw
        G.Clear(Color.White)
    End Sub

    Private Sub TickCounter()
        If tSec = TimeOfDay.Second And IsRunning = True Then
            tTicks = tTicks + 1
        Else
            MaxTicks = tTicks
            tTicks = 0
            tSec = TimeOfDay.Second
        End If
    End Sub

    Private Sub ZeldaBuild_MouseClick() Handles Me.MouseClick
        If mouseX = 21 And mouseY = 8 Then
            PaintBrush = 0
        ElseIf mouseX = 21 And mouseY = 4 Then
            PaintBrush = 1
        ElseIf mouseX = 21 And mouseY = 6 Then
            PaintBrush = 2
        End If

        Select Case PaintBrush
            Case 0
                Map(mMapX, mMapY, 0) = 0
            Case 1 ' Red
                Map(mMapX, mMapY, 0) = 1
            Case 2 ' Blue
                Map(mMapX, mMapY, 0) = 2
        End Select

    End Sub

    Private Sub ZeldaBuild_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseMove
        mouseX = Math.Floor(e.X / TileSize)
        mouseY = Math.Floor(e.Y / TileSize)

        mMapX = MapX + mouseX
        mMapY = MapY + mouseY
    End Sub

    Private Sub GetSourceRect(ByVal x As Integer, ByVal y As Integer, ByVal w As Integer, ByVal h As Integer)
        Select Case Map(x, y, 0)
            Case 0 ' Grass
                sRect = New Rectangle(32, 0, TileSize, TileSize)
            Case 1 ' Tree
                sRect = New Rectangle(32, 128, TileSize, TileSize)
            Case 2 ' Mountain
                sRect = New Rectangle(160, 128, TileSize, TileSize)
        End Select
    End Sub
End Class
 
Old 06-25-2012, 02:48 AM   #2
John VV
LQ Muse
 
Registered: Aug 2005
Location: A2 area Mi.
Posts: 17,624

Rep: Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651
well as far as i know Microsoft's VB dose not run well in any version of wine on any version of linux

wine lists VB 2005 as bronze
i would use MS's Visual Basic on a Microsoft operating system

Last edited by John VV; 06-25-2012 at 02:51 AM.
 
Old 06-25-2012, 11:43 AM   #3
errigour
Member
 
Registered: May 2009
Posts: 366

Original Poster
Rep: Reputation: 6
I am I was just asking a programming question here.
 
Old 06-25-2012, 02:38 PM   #4
whizje
Member
 
Registered: Sep 2008
Location: The Netherlands
Distribution: Slackware64 current
Posts: 594

Rep: Reputation: 141Reputation: 141
Try http://www.vbforums.com/
 
  


Reply



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



Similar Threads
Thread Thread Starter Forum Replies Last Post
how to build front end using visual basics malwadprakash Linux - Newbie 3 06-13-2011 03:43 AM
Ubuntu 9.10 isn't loading properly. Ninja Raccoon Linux - Newbie 4 02-27-2010 03:32 AM
Check if program is running, if not start it and enter a password... easy, isn't it? darkrad Linux - Server 11 07-17-2008 12:35 PM
running Visual Basic/Visual Fox Pro in Linux? depam Linux - Software 9 02-11-2006 03:42 PM
Visual Basics crosspy Programming 1 08-26-2003 11:42 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 04:06 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration