none
ideas for console application games in vb.net2008 RRS feed

All replies

  • hi,

    I've entered some thing like a course (vb.net 2008)

    but the head master asks us to create a console application game can any body give some ideas?

    Since you asked then Comanche Gold - In console application.


    La vida loca

    Wednesday, June 11, 2014 4:36 PM
  • hi,

    I've entered some thing like a course (vb.net 2008)

    but the head master asks us to create a console application game can any body give some ideas?

    Othello (Wikipedia link), it is very simple mechanics, easily produced in console form and requires turn-by-turn arguments from user 

    EDIT: 

    @Mr. Monkeyboy: Producing such live action game as you recommend would be extremely difficult for a vb.net course (even more maybe, for a console application), I am not certain why the recommendation is the one you are making 


    ✘ My goal of posting is to make you and I better educated programmers while solving our problems ✘



    • Edited by Cadefia Wednesday, June 11, 2014 5:16 PM
    Wednesday, June 11, 2014 5:14 PM
  • Don't make it yourself to difficult. 

    Just ask to enter a number between 1 and 10 and tell then of the computer took the the same. 

    You can use for that the math.randomizer. 

    Read the documentation, it is easy to make. The purpose of the headmaster to see if you understand coding, not to make a nice game.

    http://msdn.microsoft.com/en-us/library/System.Random(v=vs.110).aspx 


    Success
    Cor

    Wednesday, June 11, 2014 6:29 PM
  • Since you asked then Comanche Gold - In console application.

    Probably not that sort of console ;)

    --
    Andrew

    Wednesday, June 11, 2014 6:46 PM
  • You can use for that the math.randomizer.

    Cor,

    I think you mean VBMath (not the Math class of dotNet).

    Either way though, you showed a link to dotNet's .Random class which is, I'm sure, what you actually meant. :)


    Please call me Frank :)

    Wednesday, June 11, 2014 6:52 PM
  • You can use for that the math.randomizer.

    Cor,

    I think you mean VBMath (not the Math class of dotNet).

    Either way though, you showed a link to dotNet's .Random class which is, I'm sure, what you actually meant. :)


    Please call me Frank :)

    Frank,

    No I meant the Math one. However, it is not important what is taken, with both you can create a simple game which shows the knowledge of a console program.


    Success
    Cor

    Wednesday, June 11, 2014 7:32 PM
  • No I meant the Math one. However, it is not important what is taken, with both you can create a simple game which shows the knowledge of a console program.

    ok...

    • Edited by Frank L. Smith Wednesday, June 11, 2014 7:49 PM ...pointless
    Wednesday, June 11, 2014 7:37 PM
  • hi,

    EDIT: 

    @Mr. Monkeyboy: Producing such live action game as you recommend would be extremely difficult for a vb.net course (even more maybe, for a console application), I am not certain why the recommendation is the one you are making 


    ✘ My goal of posting is to make you and I better educated programmers while solving our problems ✘



    Well then make a SharkNado like game. Like the one in the images below.

    The SharkNado (tornado) starts out spinning on the top left. Moves all the way to the right, then down to the bottom, then up to the top, then all the way to the left, then down to the bottom, then up to the top, then right again. Continuously.

    The U.S.M.C. tactical fighter atmospheric and outerspace craft (SA-43 Hammerhead) is located bottom, center screen and is rotated at 90 degrees to the right. It can be rotated 90 degrees to the left of 0 (270 deg and back to 90. It has two phasers, one on each wingtip. Also a special weapons launcher in the center front that can launch special weapons (a star weapon, orb weapon or space mine). The phasers fire now. The other weapons are not finished.

    Currently a swimming down shark is manually "ejected" from the SharkNado. It swims down until it hits the U.S.M.C. tactical fighter which causes game over if it is not killed first. The game over, kill with weapons, scoring, additional special weapons and additional lifes for fighter have not been implement yet.

    There is also a swimming right shark if the SharkNado is on the left and a swimming left shark if the SharkNado is on the right which have not been implemented yet.

    I'll post the code when done.


    La vida loca



    Saturday, June 14, 2014 9:34 AM
  • I'm assuming the OP is referring to a Console application (using the text screen) NOT a separate device such as the XBox.

    The classic game for beginners is a guessing game using a secret random number between 1 and 100 selected by the computer.  Ask the user to guess the computer's number.  If the guess matches the secret number, then the user got it right.  Otherwise, tell the user to guess again until he gets it right.  You can also tell the user if the guess was too high or too low.  You would use a loop to keep repeating until the guess = the secret number, and you can also keep count of how many guesses the user took.

    Solitaire

    Saturday, June 14, 2014 9:57 PM
  • I'm assuming the OP is referring to a Console application (using the text screen) NOT a separate device such as the XBox.

    The classic game for beginners is a guessing game using a secret random number between 1 and 100 selected by the computer.  Ask the user to guess the computer's number.  If the guess matches the secret number, then the user got it right.  Otherwise, tell the user to guess again until he gets it right.  You can also tell the user if the guess was too high or too low.  You would use a loop to keep repeating until the guess = the secret number, and you can also keep count of how many guesses the user took.

    Solitaire

    My game is just a console application with the backgroundcolor changed to Cyan, resized to fit the screen dimensions, positioned on the desktop and doing some drawing with timers. A bit advanced but maybe the OP can learn from it. Or maybe not. But it's nothing to do with XBox. Nor is Comanche Gold which is a PC game although perhaps there's an XBox version also.


    La vida loca

    Saturday, June 14, 2014 11:16 PM
  • I won't be done with this code for a week or so. When I get done I'll delete this post and place all the code in the final post.

    Anyhow this is SharkNado so far.

    Option Strict On
    
    Imports System.Drawing
    Imports System.Windows.Forms
    Imports System.Runtime.InteropServices
    Imports System.Drawing.Drawing2D
    Imports System.Drawing.Imaging
    
    Module Module1
    
        ' http://social.msdn.microsoft.com/Forums/en-US/c0745bfa-dd63-4303-b5e4-a603930955f0/ideas-for-console-application-games-in-vbnet2008?forum=vbgeneral
    
        ' Arrow keys code loop http://msdn.microsoft.com/en-us/library/system.console.setwindowposition.aspx
    
        <DllImport("user32.dll")> _
        Public Function MoveWindow(ByVal hWnd As IntPtr, ByVal x As Integer, ByVal y As Integer, ByVal nWidth As Integer, _
                                          ByVal nHeight As Integer, ByVal bRepaint As Boolean) As Boolean
        End Function
    
        Private Declare Function ReleaseDC Lib "user32.dll" (ByVal hwnd As IntPtr, ByVal hdc As IntPtr) As IntPtr
    
        WithEvents Timer1 As New System.Timers.Timer
        WithEvents Timer2 As New System.Timers.Timer
        WithEvents Timer3 As New System.Timers.Timer
        WithEvents Timer4 As New System.Timers.Timer
    
        Dim cki As ConsoleKeyInfo
    
        Dim SharkNadoBitMaps As New List(Of Bitmap)
    
        Dim SharkLeftGif As New List(Of Bitmap)
        Dim SharkRightGif As New List(Of Bitmap)
        Dim SharkDownGif As New List(Of Bitmap)
    
        Dim OrbWeapon As New List(Of Bitmap)
        Dim MineWeapon As New List(Of Bitmap)
        Dim StarWeapon As New List(Of Bitmap)
    
        Dim SA43HammerheadsPoints As New List(Of Point)
        Dim PhasersPoint As New List(Of Integer)
    
        Sub Main()
    
            ' This code sets the Consoles "client area" size. The area inside the Consoles borders.
    
            Console.SetBufferSize(Console.LargestWindowWidth - 2, Console.LargestWindowHeight - 1)
            Console.WindowWidth = Console.LargestWindowWidth - 2
            Console.WindowHeight = Console.LargestWindowHeight - 1
    
            ' These integers should be altered to get the screens width and height and remove appropriate amounts from that information.
    
            MaxX = 1340
            MaxY = 670
    
            ' Sets the Consoles back and fore ground colors. For any information to be displayed in the app such as scores, SA43's lives, etc
            ' they will be graphically drawn on the app. Possibly by a separate timer. When I get to that part.
    
            Console.BackgroundColor = ConsoleColor.Cyan
            Console.Clear()
    
            Console.ForegroundColor = ConsoleColor.Cyan
            Console.Clear()
    
            ' Unlike a Form I could not find an ability to move or size a Console app programmatically so I resorted to an API. This moves the console
            ' app to the top left of the desktop (point 0, 0) and sizes it to fill the working area which is everything above the taskbar.
    
            MoveWindow(Process.GetCurrentProcess.MainWindowHandle, 0, 0, Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height, True)
    
            ' Following code is from IronRazerz or tommytwotrain, don't remember which now, that takes all frames from animated .Gifs and stores them
            ' in a List(Of Bitmap) so they can be drawn in order to replicate an animated .Gif using image drawing. I can't find the thread that one of
            ' them originally posted it in. But it works awesome.
    
            Using bm As New Bitmap("C:\Users\John\Documents\Visual Studio 2012\Console App - SharkNado game\Sharks\SharkNado.Gif")
                Dim fd As New FrameDimension(bm.FrameDimensionsList(0))
                Dim framecount As Integer = bm.GetFrameCount(fd)
                If framecount > 1 Then
                    For Each bmp As Bitmap In SharkNadoBitMaps
                        bmp.Dispose()
                    Next
                    SharkNadoBitMaps.Clear()
                    For i As Integer = 0 To framecount - 1
                        bm.SelectActiveFrame(fd, i)
                        SharkNadoBitMaps.Add(New Bitmap(bm))
                    Next
                End If
                fd = Nothing
            End Using
    
            Using bm As New Bitmap("C:\Users\John\Documents\Visual Studio 2012\Console App - SharkNado game\Sharks\SharkLeft.Gif")
                Dim fd As New FrameDimension(bm.FrameDimensionsList(0))
                Dim framecount As Integer = bm.GetFrameCount(fd)
                If framecount > 1 Then
                    For Each bmp As Bitmap In SharkLeftGif
                        bmp.Dispose()
                    Next
                    SharkLeftGif.Clear()
                    For i As Integer = 0 To framecount - 1
                        bm.SelectActiveFrame(fd, i)
                        SharkLeftGif.Add(New Bitmap(bm))
                    Next
                End If
                fd = Nothing
            End Using
    
            Using bm As New Bitmap("C:\Users\John\Documents\Visual Studio 2012\Console App - SharkNado game\Sharks\SharkRight.Gif")
                Dim fd As New FrameDimension(bm.FrameDimensionsList(0))
                Dim framecount As Integer = bm.GetFrameCount(fd)
                If framecount > 1 Then
                    For Each bmp As Bitmap In SharkRightGif
                        bmp.Dispose()
                    Next
                    SharkRightGif.Clear()
                    For i As Integer = 0 To framecount - 1
                        bm.SelectActiveFrame(fd, i)
                        SharkRightGif.Add(New Bitmap(bm))
                    Next
                End If
                fd = Nothing
            End Using
    
            Using bm As New Bitmap("C:\Users\John\Documents\Visual Studio 2012\Console App - SharkNado game\Sharks\SharkDown.Gif")
                Dim fd As New FrameDimension(bm.FrameDimensionsList(0))
                Dim framecount As Integer = bm.GetFrameCount(fd)
                If framecount > 1 Then
                    For Each bmp As Bitmap In SharkDownGif
                        bmp.Dispose()
                    Next
                    SharkDownGif.Clear()
                    For i As Integer = 0 To framecount - 1
                        bm.SelectActiveFrame(fd, i)
                        SharkDownGif.Add(New Bitmap(bm))
                    Next
                End If
                fd = Nothing
            End Using
    
            Using bm As New Bitmap("C:\Users\John\Documents\Visual Studio 2012\Console App - SharkNado game\Sharks\OrbWeapon.Gif")
                Dim fd As New FrameDimension(bm.FrameDimensionsList(0))
                Dim framecount As Integer = bm.GetFrameCount(fd)
                If framecount > 1 Then
                    For Each bmp As Bitmap In OrbWeapon
                        bmp.Dispose()
                    Next
                    OrbWeapon.Clear()
                    For i As Integer = 0 To framecount - 1
                        bm.SelectActiveFrame(fd, i)
                        OrbWeapon.Add(New Bitmap(bm))
                    Next
                End If
                fd = Nothing
            End Using
    
            Using bm As New Bitmap("C:\Users\John\Documents\Visual Studio 2012\Console App - SharkNado game\Sharks\MineWeapon.Gif")
                Dim fd As New FrameDimension(bm.FrameDimensionsList(0))
                Dim framecount As Integer = bm.GetFrameCount(fd)
                If framecount > 1 Then
                    For Each bmp As Bitmap In MineWeapon
                        bmp.Dispose()
                    Next
                    MineWeapon.Clear()
                    For i As Integer = 0 To framecount - 1
                        bm.SelectActiveFrame(fd, i)
                        MineWeapon.Add(New Bitmap(bm))
                    Next
                End If
                fd = Nothing
            End Using
    
            Using bm As New Bitmap("C:\Users\John\Documents\Visual Studio 2012\Console App - SharkNado game\Sharks\StarWeapon.Gif")
                Dim fd As New FrameDimension(bm.FrameDimensionsList(0))
                Dim framecount As Integer = bm.GetFrameCount(fd)
                If framecount > 1 Then
                    For Each bmp As Bitmap In StarWeapon
                        bmp.Dispose()
                    Next
                    StarWeapon.Clear()
                    For i As Integer = 0 To framecount - 1
                        bm.SelectActiveFrame(fd, i)
                        StarWeapon.Add(New Bitmap(bm))
                    Next
                End If
                fd = Nothing
            End Using
    
            ' Following code gets points in 180 degrees around the SA43 Hammerhead. They are a semicircle that extends the height - 7 of the SA43.
            ' Facing due left points at index zero are used and due right points at index 180, or perhaps 179 (since 0 to 179 is 180 count), are
            ' used for the weapons trajectories.
    
            For i = 0 To 180
                SA43HammerheadsPoints.Add(New Point(CInt(Math.Round((Screen.PrimaryScreen.WorkingArea.Width / 2) - 2 * Math.Cos((i) * Math.PI / 180))), CInt(Math.Round(Screen.PrimaryScreen.WorkingArea.Height - My.Resources.SA43Hammerhead.Height) - 7 * Math.Sin((i) * Math.PI / 180))))
            Next
    
            ' Timer1 is used to rotate the SA43 Hammerhead left to right and back using the left and right arrow keys.
    
            AddHandler Timer1.Elapsed, AddressOf Timer1_Elapsed
            Timer1.Interval = 3
            Timer1.Start()
    
            ' Timer2 is for the SharkNado and moves it from the bottom left screen to the top left, top right, bottom right and back along that path.
    
            AddHandler Timer2.Elapsed, AddressOf Timer2_Elapsed
            Timer2.Interval = 80
            Timer2.Start()
    
            ' Timer3 is currently for the SA43 Hammerheads phasers to rotate their start points and end points while the SA43 is rotated. It may
            ' end up being used for all weapons including tracking the Orb, Star and Mine weapons and detecting when any weapon hits a shark.
    
            AddHandler Timer3.Elapsed, AddressOf Timer3_Elapsed
            Timer3.Interval = 40
            Timer3.Start()
    
            ' Timer4 is being used for a Shark ejected from the SharkNado to make it move toward the front, direct center of the SA43 Hammerhead.
            ' It will probably be used to monitor sharks locations so if any intersect with the front center of the SA43 Hammerhead that will
            ' represent a kill in that the shark is eating the SA43 Hammerhead at that point. :)
    
            AddHandler Timer4.Elapsed, AddressOf Timer4_Elapsed
            Timer4.Interval = 100
            Timer4.Start()
    
            ' A loop that monitors the Consol Applcations keyboard keys. Pressing the Esc key causes the app to exit.
    
            Do
                cki = Console.ReadKey(True)
                Select Case cki.Key
                    Case ConsoleKey.LeftArrow
                        Angle -= 5
                        PhaserAngle -= 5
                    Case ConsoleKey.RightArrow
                        Angle += 5
                        PhaserAngle += 5
                    Case ConsoleKey.Z
                        FirePhasers = True
                    Case ConsoleKey.D5
                        LaunchShark = True ' Temporarily used to manually "eject" a shark from the SharkNado when the numeric 5 key is pressed.
                        SharkPoint = New Point(CInt(XCoord + (My.Resources.SharkNado.Width / 2) - (My.Resources.SharkDown.Width / 2)), 10) ' My.Resources.SharkNado.Height)
                End Select
            Loop While cki.Key <> ConsoleKey.Escape
    
        End Sub
    
        Dim Angle As Single = 0
    
        Private Sub Timer1_Elapsed(sender As Object, e As System.Timers.ElapsedEventArgs)
    
            If Angle < -90 Then
                Angle = -90
            ElseIf Angle > 90 Then
                Angle = 90
            End If
    
            Dim Bg As BufferedGraphics
            Dim Bgc As BufferedGraphicsContext
    
            Bgc = BufferedGraphicsManager.Current
            Bg = Bgc.Allocate(Graphics.FromHwnd(Process.GetCurrentProcess.MainWindowHandle), New Rectangle(CInt((Screen.PrimaryScreen.WorkingArea.Width / 2) - (My.Resources.SA43Hammerhead.Width / 2)), CInt(Screen.PrimaryScreen.WorkingArea.Height - My.Resources.SA43Hammerhead.Height - 54), My.Resources.SA43Hammerhead.Width, My.Resources.SA43Hammerhead.Height))
    
            Bg.Graphics.Clear(Color.Cyan)
            Bg.Graphics.RotateTransform(Angle)
            Bg.Graphics.TranslateTransform(CInt(Screen.PrimaryScreen.WorkingArea.Width / 2), CInt(Screen.PrimaryScreen.WorkingArea.Height - My.Resources.SA43Hammerhead.Height), Drawing2D.MatrixOrder.Append)
            Bg.Graphics.DrawImage(My.Resources.SA43Hammerhead, -CInt(My.Resources.SA43Hammerhead.Width / 2), -CInt(My.Resources.SA43Hammerhead.Height / 2))
    
            Bg.Render()
            Bg.Dispose()
    
        End Sub
    
        Dim MovingRight As Boolean = True
        Dim MovingLeft As Boolean = False
        Dim MovingLeftDown As Boolean = False
        Dim MovingLeftUp As Boolean = False
        Dim MovingRightDown As Boolean = False
        Dim MovingRightUp As Boolean = False
    
        Dim XCoord As Integer = 0
        Dim YCoord As Integer = 0
        Dim MaxX As Integer = 0
        Dim MaxY As Integer = 0
    
        Dim T2BMCount As Integer = 0
    
        Private Sub Timer2_Elapsed(sender As Object, e As System.Timers.ElapsedEventArgs)
    
            If MovingRight = True Then
                Dim Bg As BufferedGraphics
                Dim Bgc As BufferedGraphicsContext
    
                Bgc = BufferedGraphicsManager.Current
                Bg = Bgc.Allocate(Graphics.FromHwnd(Process.GetCurrentProcess.MainWindowHandle), New Rectangle(XCoord, YCoord, My.Resources.SharkNado.Width + 10, My.Resources.SharkNado.Height + 40))
                Bg.Graphics.Clear(Color.Cyan)
                Bg.Graphics.DrawImage(SharkNadoBitMaps(T2BMCount), XCoord + 10, YCoord)
                Bg.Render()
                Bg.Dispose()
    
                T2BMCount += 1
                If T2BMCount > SharkNadoBitMaps.Count - 1 Then T2BMCount = 0
                XCoord += 10
                If XCoord >= MaxX - My.Resources.SharkNado.Width Then MovingRight = False : MovingRightDown = True
            End If
    
            If MovingRightDown = True Then
                Dim Bg As BufferedGraphics
                Dim Bgc As BufferedGraphicsContext
    
                Bgc = BufferedGraphicsManager.Current
                Bg = Bgc.Allocate(Graphics.FromHwnd(Process.GetCurrentProcess.MainWindowHandle), New Rectangle(XCoord, YCoord, My.Resources.SharkNado.Width + 10, My.Resources.SharkNado.Height + 40))
                Bg.Graphics.Clear(Color.Cyan)
                Bg.Graphics.DrawImage(SharkNadoBitMaps(T2BMCount), XCoord, YCoord + 20)
                Bg.Render()
                Bg.Dispose()
    
                T2BMCount += 1
                If T2BMCount > SharkNadoBitMaps.Count - 1 Then T2BMCount = 0
                YCoord += 10
                If YCoord >= MaxY - My.Resources.SharkNado.Height Then MovingRightDown = False : MovingRightUp = True
            End If
    
            If MovingRightUp = True Then
                Dim Bg As BufferedGraphics
                Dim Bgc As BufferedGraphicsContext
    
                Bgc = BufferedGraphicsManager.Current
                Bg = Bgc.Allocate(Graphics.FromHwnd(Process.GetCurrentProcess.MainWindowHandle), New Rectangle(XCoord, YCoord, My.Resources.SharkNado.Width + 10, My.Resources.SharkNado.Height + 40))
                Bg.Graphics.Clear(Color.Cyan)
                Bg.Graphics.DrawImage(SharkNadoBitMaps(T2BMCount), XCoord - 10, YCoord)
                Bg.Render()
                Bg.Dispose()
    
                T2BMCount += 1
                If T2BMCount > SharkNadoBitMaps.Count - 1 Then T2BMCount = 0
                YCoord -= 10
                If YCoord <= -1 Then YCoord = 0 : MovingRightUp = False : MovingLeft = True
            End If
    
    
            If MovingLeft = True Then
                Dim Bg As BufferedGraphics
                Dim Bgc As BufferedGraphicsContext
    
                Bgc = BufferedGraphicsManager.Current
                Bg = Bgc.Allocate(Graphics.FromHwnd(Process.GetCurrentProcess.MainWindowHandle), New Rectangle(XCoord, YCoord, My.Resources.SharkNado.Width + 10, My.Resources.SharkNado.Height + 40))
                Bg.Graphics.Clear(Color.Cyan)
                Bg.Graphics.DrawImage(SharkNadoBitMaps(T2BMCount), XCoord, YCoord)
                Bg.Render()
                Bg.Dispose()
    
                T2BMCount += 1
                If T2BMCount > SharkNadoBitMaps.Count - 1 Then T2BMCount = 0
                XCoord -= 10
                If XCoord <= -1 Then XCoord = 0 : MovingLeft = False : MovingLeftDown = True
            End If
    
            If MovingLeftDown = True Then
                Dim Bg As BufferedGraphics
                Dim Bgc As BufferedGraphicsContext
    
                Bgc = BufferedGraphicsManager.Current
                Bg = Bgc.Allocate(Graphics.FromHwnd(Process.GetCurrentProcess.MainWindowHandle), New Rectangle(XCoord, YCoord, My.Resources.SharkNado.Width + 40, My.Resources.SharkNado.Height + 10))
                Bg.Graphics.Clear(Color.Cyan)
                Bg.Graphics.DrawImage(SharkNadoBitMaps(T2BMCount), XCoord, YCoord + 20)
                Bg.Render()
                Bg.Dispose()
    
                T2BMCount += 1
                If T2BMCount > SharkNadoBitMaps.Count - 1 Then T2BMCount = 0
                YCoord += 10
                If YCoord >= MaxY - My.Resources.SharkNado.Height Then MovingLeftDown = False : MovingLeftUp = True
            End If
    
            If MovingLeftUp = True Then
                Dim Bg As BufferedGraphics
                Dim Bgc As BufferedGraphicsContext
    
                Bgc = BufferedGraphicsManager.Current
                Bg = Bgc.Allocate(Graphics.FromHwnd(Process.GetCurrentProcess.MainWindowHandle), New Rectangle(XCoord, YCoord, My.Resources.SharkNado.Width + 10, My.Resources.SharkNado.Height + 40))
                Bg.Graphics.Clear(Color.Cyan)
                Bg.Graphics.DrawImage(SharkNadoBitMaps(T2BMCount), XCoord, YCoord)
                Bg.Render()
                Bg.Dispose()
    
                T2BMCount += 1
                If T2BMCount > SharkNadoBitMaps.Count - 1 Then T2BMCount = 0
                YCoord -= 10
                If YCoord <= -1 Then YCoord = 0 : MovingLeftUp = False : MovingRight = True
            End If
        End Sub
    
    
        ' I spent the last two days altering this code to work again. Originally the SA43 Hammerhead was pointing 90 degrees to the right
        ' when the app launched. I wanted it to point vertically. I couldn't align the phasers again correctly for two days. 
    
        Dim FirePhasers As Boolean = False
    
        Dim PhaserCount As Integer = 1
        Dim PhaserAngle As Integer = 90
    
        Private Sub Timer3_Elapsed(sender As Object, e As System.Timers.ElapsedEventArgs)
            If FirePhasers = True Then
                Using g As Graphics = Graphics.FromHwnd(Process.GetCurrentProcess.MainWindowHandle)
                    g.SmoothingMode = SmoothingMode.HighSpeed
                    If PhaserAngle > 180 Then PhaserAngle = 180
                    If PhaserAngle < 0 Then PhaserAngle = 0
                    g.TranslateTransform(SA43HammerheadsPoints(PhaserAngle).X, SA43HammerheadsPoints(PhaserAngle).Y)
                    g.RotateTransform(Angle)
                    Using Pen1 As New Pen(Brushes.DodgerBlue, 3)
                        g.DrawLine(Pen1, -54, 0, -10, -CInt(Screen.PrimaryScreen.WorkingArea.Height) + 120)
                        g.DrawLine(Pens.Red, -54, 0, -10, -CInt(Screen.PrimaryScreen.WorkingArea.Height) + 120)
                    End Using
                End Using
                Using g As Graphics = Graphics.FromHwnd(Process.GetCurrentProcess.MainWindowHandle)
                    g.SmoothingMode = SmoothingMode.HighSpeed
                    If PhaserAngle > 180 Then PhaserAngle = 180
                    If PhaserAngle < 0 Then PhaserAngle = 0
                    g.TranslateTransform(SA43HammerheadsPoints(PhaserAngle).X, SA43HammerheadsPoints(PhaserAngle).Y)
                    g.RotateTransform(Angle)
                    Using Pen1 As New Pen(Brushes.DodgerBlue, 3)
                        g.DrawLine(Pen1, 52, 0, -10, -CInt(Screen.PrimaryScreen.WorkingArea.Height) + 120)
                        g.DrawLine(Pens.Red, 52, 0, -10, -CInt(Screen.PrimaryScreen.WorkingArea.Height) + 120)
                    End Using
                End Using
                PhaserCount += 1
            End If
            If PhaserCount = 5 Then
                PhaserCount = 1
                FirePhasers = False
                Console.BackgroundColor = ConsoleColor.Blue
                Console.Clear()
                Console.BackgroundColor = ConsoleColor.Cyan
                Console.Clear()
            End If
    
        End Sub
    
    
        Dim LaunchShark As Boolean = False
        Dim SDownBMCount As Integer = 0
        Dim SharkPoint As Point
    
        Private Sub Timer4_Elapsed(sender As Object, e As System.Timers.ElapsedEventArgs)
            If LaunchShark = True Then
                Dim Bg As BufferedGraphics
                Dim Bgc As BufferedGraphicsContext
    
                Bgc = BufferedGraphicsManager.Current
                Bg = Bgc.Allocate(Graphics.FromHwnd(Process.GetCurrentProcess.MainWindowHandle), New Rectangle(SharkPoint.X, SharkPoint.Y, My.Resources.SharkDown.Width + 20, My.Resources.SharkDown.Height + 20))
                Bg.Graphics.Clear(Color.Cyan)
                Bg.Graphics.DrawImage(SharkDownGif(SDownBMCount), SharkPoint.X + 10, SharkPoint.Y + 10)
                Bg.Render()
                Bg.Dispose()
    
                SharkPoint = New Point(MathHelp.GetPointToward(New Point(SharkPoint.X, SharkPoint.Y), New Point(CInt((Screen.PrimaryScreen.WorkingArea.Width / 2) - (My.Resources.SharkDown.Width / 2)), CInt(Screen.PrimaryScreen.WorkingArea.Height - My.Resources.SA43Hammerhead.Height - My.Resources.SharkDown.Height - 55)), 5).X, MathHelp.GetPointToward(New Point(SharkPoint.X, SharkPoint.Y), New Point(CInt((Screen.PrimaryScreen.WorkingArea.Width / 2) - (My.Resources.SharkDown.Width / 2)), CInt(Screen.PrimaryScreen.WorkingArea.Height - My.Resources.SA43Hammerhead.Height - My.Resources.SharkDown.Height - 55)), 5).Y)
    
                SDownBMCount += 1
                If SDownBMCount > SharkDownGif.Count - 1 Then SDownBMCount = 0
            End If
        End Sub
    
    
        ' Code that moderator Reed Kimble used in a Keep Away game post a long time ago. I can't replicate it, at least not to this level of
        ' "ease" so I used it. But I changed it to use Point instead of PointF. Anyhow I use the GetPointToward function in it that returns
        ' a point away from a previous point towards a target point. Using a distance of 5 I get the next 5th point to use to move
        ' towards the target point. You will see that function called in timer4 right now for moving the shark. It will end up being used to
        ' move the Orb, Star and Mine weapons too I think. Maybe even for collision detection of the phasers or other weapons with the moving
        ' sharks. Not sure yet. But currently the shark is moved 5 points towards the target at a time.
    
        Public NotInheritable Class MathHelp
            Public Const TWO_PI As Single = Math.PI * 2
    
            Protected Sub New()
            End Sub
    
            Public Shared Function GetDistance(ByVal source As Point, ByVal target As Point) As Single
                Dim squareX As Double = CDbl(target.X - source.X)
                squareX *= squareX
                Dim squareY As Double = CDbl(target.Y - source.Y)
                squareY *= squareY
                Return CSng(Math.Sqrt(squareX + squareY))
            End Function
    
            Public Shared Function GetRadiansTo(ByVal source As Point, ByVal target As Point) As Single
                Return WrapAngle(CSng(Math.Atan2(target.Y - source.Y, target.X - source.X)))
            End Function
    
            Public Shared Function GetPointToward(ByVal source As Point, ByVal target As Point, ByVal distance As Single) As Point
                Dim angle As Single = GetRadiansTo(source, target)
                Return source + New Size(CInt(CSng(Math.Cos(angle) * distance)), CInt(CSng(Math.Sin(angle) * distance)))
            End Function
    
            Public Shared Function WrapAngle(ByVal radians As Single) As Single
                While radians < -Math.PI
                    radians += TWO_PI
                End While
                While radians > Math.PI
                    radians -= TWO_PI
                End While
                Return radians
            End Function
    
        End Class
    
    End Module
    


    La vida loca

    Monday, June 16, 2014 1:19 PM
  • Sample Console demo, shows how to change colors, relocate the cursor, change size of the console window, & how to use KeyAvailable in a loop.

    Module Module1
    
        Sub Main()
            Dim row, col, count As Integer, dat As String, str As String = ""
            Console.Title = "Console Color, Cursor, Screen size, and Loop Demo"
            Console.BackgroundColor = ConsoleColor.Blue
            Console.ForegroundColor = ConsoleColor.Green
            Console.WriteLine("Single line of color:  green on blue.  Press Enter to clear screen.")
            Console.ReadLine()
            Console.Clear()             'Entire background turns blue
            Console.WriteLine("Press Enter to continue...")
            Console.ReadLine()
            Console.ForegroundColor = ConsoleColor.Green
            Console.BackgroundColor = ConsoleColor.Red
            Console.Clear()             'Entire background turns red
            Console.ForegroundColor = ConsoleColor.Yellow   'Text turns yellow
            Console.WriteLine("Hello yellow on red!")
            Console.CursorTop = 15      'Relocate the cursor to row 15 column 20
            Console.CursorLeft = 20     'Same as Console.SetCursorPosition(15, 20)                  
            Console.WriteLine("Press Enter to continue...")
            Console.ReadLine()
            Console.BackgroundColor = ConsoleColor.Cyan
            Console.Clear()             'Background turns cyan
            Console.ForegroundColor = ConsoleColor.Magenta  'Text turns magenta
            Console.WriteLine("Hello magenta on cyan!")     'Cursor is on top
            Console.SetCursorPosition(20, 5)
            Console.WriteLine("Press Enter to reset default colors and clear screen.")
            Console.ReadLine()
            Console.ResetColor()        'Restore default colors
            Console.Clear()             'Must clear screen to restore
            Console.CursorTop = 5
            Console.WriteLine("Default colors restored")
            Console.SetCursorPosition(0, 24)    'Bottom of screen
            Console.Write("Press Enter to enlarge screen...")
            Console.ReadLine()
            'Console.WindowWidth = 100           'Set width & height separately
            'Console.WindowHeight = 40         
            Console.SetWindowSize(100, 40)      'Set both width & height at once
            Console.CursorTop = Console.CursorTop - 1
            Console.Clear()
            Console.WriteLine("Screen size enlarged" & vbCrLf)
            Console.WriteLine("Press Enter to say ""Come in.""")  'Double quote used to display a quote symbol
            Console.ReadLine()
            Console.CursorTop = 0
            Console.WriteLine(Space(20))    'Blank out top line
            Console.CursorTop = 15          'Move cursor down to row 15
            Console.WriteLine("one two three four five")
            Console.CursorTop = 3           'Return to top left
            Console.WriteLine(vbCrLf & "Come in.  Press Enter to replace ""three"" with ""seven""")
            Console.ReadLine()
            Console.CursorTop = 15
            Console.CursorLeft = 8      'Move cursor in front of "three"
            Console.Write("seven")      'Replaces the text
            Console.ReadLine()
            Console.Clear()
            Console.WriteLine("Hello to everyone!")
            Console.Write(vbCrLf & "I want to come back right here later-->")
            row = Console.CursorTop         'Save row & column location to return to later
            col = Console.CursorLeft
            Console.CursorTop = 7           'Locate cursor to row 7
            Console.CursorLeft = 14         'Locate cursor to column 14:
            Console.Write("Row 7, Column 14.  Press Enter to cover Hello with Goodbye.")
            Console.ReadLine()
            Console.CursorTop = 0
            Console.Write("Goodbye ")
            Console.CursorTop = row         'Locate to saved row & column
            Console.CursorLeft = col
            Console.ForegroundColor = ConsoleColor.Yellow
            Console.Write("Now I'm back here.")
            Console.ResetColor()
            Console.ReadLine()
            Console.WindowWidth = 80            'Restore default screen size
            Console.WindowHeight = 25
            'Console.SetWindowSize(80, 25)      'Reset both width & height at once
            Console.SetCursorPosition(0, 22)    'Near bottom of screen
            Console.WriteLine("Color and screen size restored.  Press any key to continue...")
            Console.ReadKey(True)
            Console.Clear()
            Console.WriteLine("Normal loop:" & vbCrLf)
            Console.WriteLine("Loop will wait for a keypress. Esc to stop or any key to continue.")
            Console.Title = "Normal loop:  Press Esc to stop or any other key to continue..."
            Console.WriteLine()
            count = 0
            Do
                count += 1
                dat = Console.ReadKey(True).KeyChar     'Wait for user to press a key.
                Console.Write("This is Loop # " & count)
                If dat = Chr(13) Then dat = Chr(0) '    'Avoid confusing display if Enter is pressed.
                Console.WriteLine(vbTab & "You pressed the " & dat & " key.")
            Loop Until dat = Chr(27)
            Console.WriteLine()
            Console.WriteLine("Exited loop.  Repeated {0} times.", count)
            Console.WriteLine(vbCrLf & "Press any key for the continuous loop...")
            Console.ReadKey(True)
            Console.Clear()
            Console.Title = "Continuous loop:  Trap a keypress.  Continue until Esc key is pressed."
            Console.WriteLine("Continuous loop:" & vbCrLf)
            Console.WriteLine("Trap a keypress inside a loop. Repeat every half second.")
            Console.WriteLine("Press Esc key when ready to stop. Any other key will continue without pausing.")
            Console.WriteLine(vbCrLf & "Press any key to start...")
            Console.ReadKey(True)
            Console.WriteLine()
            count = 0
            Do
                count += 1
                Console.WriteLine("This is Loop # " & count & vbTab & "Waiting for a keypress...")
                Threading.Thread.Sleep(500)             'Pauses 1/2 second and then continues.
    
                'The following If block is used when a specified key is needed to stop the loop.
    
                If Console.KeyAvailable() Then          'Detects a key press but won't stop.
                    dat = Console.ReadKey(True).KeyChar 'Stop looping to get specified key.
                    If dat = Chr(13) Then dat = Chr(0) 'Avoid confusing display if Enter is pressed.
                    Console.WriteLine(vbTab & "You pressed the " & dat & " key.")
                    If dat = Chr(27) Then str = "Q" '   'Condition to end loop cannot be dat, 
                    '                                   'or it will keep pausing.
                    'If dat = Chr(27) then Exit Do   '   'Alternative exit used without the string.
                End If
    
                'If Console.KeyAvailable() Then Exit Do 'Will exit the loop with any keypress;
                '                                       'used if more code follows.
                'Loop Until Console.KeyAvailable()      'Will end the loop with any keypress.
    
            Loop Until str = "Q"                        'Loop with no condition if used with Exit Do.
            Console.WriteLine()
            Console.WriteLine("Exited loop.  Repeated {0} times.   Press any key to finish...", count)
            Console.ReadKey(True)                   'Pause for any keypress; keeps cursor on same line.
        End Sub
    
    End Module
    
    



    Solitaire

    Monday, June 16, 2014 3:51 PM
  • hi,

    I've entered some thing like a course (vb.net 2008)

    but the head master asks us to create a console application game can any body give some ideas?

     
    I have a suggestion: How about bingo and combining Cor's suggestion with Solitaires code? You generate random numbers into a txt file, database, or memory (not recommended unless you know what you are doing) and then recall them one at a time to check the users random generated numbers that he or she can see. MonkeyBoy, the professor is probably referring to word based games that used to appear in older DOS games.

    Once you eliminate the impossible, whatever remains, no matter how improbable, must be the truth. - "Sherlock holmes" "speak softly and carry a big stick" - theodore roosevelt. Fear leads to anger, anger leads to hate, hate leads to suffering - Yoda. Blog - http://www.computerprofessions.co.nr


    Monday, June 16, 2014 5:35 PM
  • First I would have to agree that this post almost certainly refers to Windows Console Application where the display is entirely text and/or ASCII art.

    The first program I ever had to turn in for a grade was Hangman, and the specification was to draw the output in screens of ASCII art.  This was in GW BASIC so not quite the same thing, but very similar.

    Many classic games like Space Invaders can also be implemented entirely in ASCII art; look to the Atari for inspiration.


    Reed Kimble - "When you do things right, people won't be sure you've done anything at all"

    Monday, June 16, 2014 8:19 PM
    Moderator
  • Many classic games like Space Invaders can also be implemented entirely in ASCII art; look to the Atari for inspiration.

    I remember that some guys came up with a way to make quite impressive "ASCII Art" that would print out on an IBM wide printer (dot matrix, I think 24-pin).

    It was impressive, really!


    Please call me Frank :)

    Monday, June 16, 2014 8:38 PM
  • How are you drawing graphics onto a console window?  
    Monday, June 16, 2014 8:44 PM
  • Don't forget text adventures like Zork and most MUD's have used ascii and other text based characters for their display for years.
    Monday, June 16, 2014 8:50 PM
  • Rock, Paper, Scissors.  ASCII art, running game-stats, nice and simple.  Tic-tac-toe is another possibility.  Or does it have to be something original?

    Is your headmaster a geek?  He might appreciate "Rock Paper Scissors Lizard Spock" if so.

    Monday, June 16, 2014 8:59 PM
  • Rock, Paper, Scissors.  ASCII art, running game-stats, nice and simple.  Tic-tac-toe is another possibility.  Or does it have to be something original?

    Is your headmaster a geek?  He might appreciate "Rock Paper Scissors Lizard Spock" if so.

    LOL I had to look that one up.  Not a TBBT fan and apparently that's what popularized it (also never been to a Comicon).

    *crawling back under my rock now* =P


    Reed Kimble - "When you do things right, people won't be sure you've done anything at all"

    Monday, June 16, 2014 9:25 PM
    Moderator
  • Rock, Paper, Scissors.  ASCII art, running game-stats, nice and simple.  Tic-tac-toe is another possibility.  Or does it have to be something original?

    Is your headmaster a geek?  He might appreciate "Rock Paper Scissors Lizard Spock" if so.

    LOL I had to look that one up.  Not a TBBT fan and apparently that's what popularized it (also never been to a Comicon).

    *crawling back under my rock now* =P


    Reed Kimble - "When you do things right, people won't be sure you've done anything at all"

    Haha, in all honesty?  I've never seen more than a 10s clip of that show on the 'tubes, but the RPSLP game has now entered into geek-lore far enough that even I became aware of it.  T-shirts are available from the usual sources, along with actual rules/cards for the game.

    Dontcha love geeks and their enterprising ways?!

    Tuesday, June 17, 2014 12:09 AM
  • ...

    Haha, in all honesty?  I've never seen more than a 10s clip of that show on the 'tubes, but the RPSLP game has now entered into geek-lore far enough that even I became aware of it.  T-shirts are available from the usual sources, along with actual rules/cards for the game.

    Dontcha love geeks and their enterprising ways?!

    Oh good, I don't have to drop your peg down a notch after all.  ;)

    And I do have to say that I was kinda surprised when one of the links in my search lead to merchandise and a creative commons license... haha I mean, the guy spun rock-paper-scissors for goodness sake... its not like he invented Yatzy!

    So yes, gotta love it.  =P


    Reed Kimble - "When you do things right, people won't be sure you've done anything at all"

    Tuesday, June 17, 2014 12:48 AM
    Moderator