# Visual Basic > Games and Graphics Programming > Game Demos >  [VB.NET] Flappy Bird - By Jacob Roman

## Jacob Roman

Oh come on who didnt see this coming.  :big yellow:  I remade Flappy Bird from scratch based on the famous Android / iPhone app that got removed from the app store. It has realistic physics, very accurate collision detection, and the game is highly configurable from the menu. It even uses DirectX. The only thing that is missing is a title screen and a high score, which I plan to put in, in due time. So there will soon be an update. In the mean time, enjoy.


...Its not crack!!!  :Sick:

----------


## Jacob Roman

Also note that this is currently in its beta stages. I found a glitch tonight, which is an easy fix. Its just with the menus after fiddling with the physics and pipes, and when you goto Set Defaults, it wont erase the checks. Thats cause I completely forgot to put the code in to erase the checks. So to fix it, just replace the Set_Default_Settings sub with this code:


vb.net Code:
Public Sub Set_Default_Settings()        Collision_Disabled = False        frmMain.mnuNoCollision.Checked = Collision_Disabled         Scalar = 150        frmMain.mnuScalar50.Checked = False        frmMain.mnuScalar100.Checked = False        frmMain.mnuScalar150.Checked = True        frmMain.mnuScalar200.Checked = False         Flap_Velocity = -3.5        frmMain.mnuFlapVelocity1.Checked = False        frmMain.mnuFlapVelocity15.Checked = False        frmMain.mnuFlapVelocity2.Checked = False        frmMain.mnuFlapVelocity25.Checked = False        frmMain.mnuFlapVelocity3.Checked = False        frmMain.mnuFlapVelocity35.Checked = True        frmMain.mnuFlapVelocity4.Checked = False        frmMain.mnuFlapVelocity45.Checked = False        frmMain.mnuFlapVelocity5.Checked = False         GAME_SPEED = 3        frmMain.mnuGameSpeed1.Checked = False        frmMain.mnuGameSpeed2.Checked = False        frmMain.mnuGameSpeed3.Checked = True        frmMain.mnuGameSpeed4.Checked = False        frmMain.mnuGameSpeed5.Checked = False         GAP_X = 250        frmMain.mnuGapDistance150.Checked = False        frmMain.mnuGapDistance200.Checked = False        frmMain.mnuGapDistance250.Checked = True        frmMain.mnuGapDistance300.Checked = False         GAP_Y = 175        frmMain.mnuMouthGap100.Checked = False        frmMain.mnuMouthGap125.Checked = False        frmMain.mnuMouthGap150.Checked = False        frmMain.mnuMouthGap175.Checked = True        frmMain.mnuMouthGap200.Checked = False        frmMain.mnuMouthGap225.Checked = False         Gravity = clsPhysics.EARTH_GRAVITY        frmMain.mnuGravityEarth.Checked = True        frmMain.mnuGravityMoon.Checked = False        frmMain.mnuGravity0.Checked = False        frmMain.mnuGravity05.Checked = False        frmMain.mnuGravity1.Checked = False        frmMain.mnuGravity15.Checked = False        frmMain.mnuGravity2.Checked = False        frmMain.mnuGravity25.Checked = False        frmMain.mnuGravity3.Checked = False        frmMain.mnuGravity35.Checked = False        frmMain.mnuGravity4.Checked = False        frmMain.mnuGravity45.Checked = False        frmMain.mnuGravity5.Checked = False        frmMain.mnuGravity55.Checked = False        frmMain.mnuGravity6.Checked = False        frmMain.mnuGravity65.Checked = False        frmMain.mnuGravity7.Checked = False        frmMain.mnuGravity75.Checked = False        frmMain.mnuGravity8.Checked = False        frmMain.mnuGravity85.Checked = False        frmMain.mnuGravity9.Checked = False    End Sub

Also if you are frustrated getting through the pipes, the games easier with the flap velocity set at 3. Its currently 3.5  :big yellow:

----------


## Arve K.

Can't even get past the first pipe!!  :Mad:

----------


## Jacob Roman

For those getting transparency issues such as dclamp that look like this:



You quite possibly have an older DirectX installed. I managed to have the game working perfectly on a generic computer at college that had no DirectX at all by simply installing the DX runtime. So if you have this issue, follow these simple steps:

Download the offline DirectX Runtime:
http://www.microsoft.com/en-us/downl...s.aspx?id=8109

Next extract it into a temperary folder, and run DXSETUP.exe to install it, and boom, the game will work.  :Wink:

----------


## pedrorobinson

it look like the mario the popular one..

----------


## dday9

Something that I noticed in your code that's pretty basic is all your MenuItem clicks. You could shrink this:


```
    Private Sub mnuMouthGap100_Click(sender As Object, e As EventArgs) Handles mnuMouthGap100.Click
        GAP_Y = 100
        mnuMouthGap100.Checked = True
        mnuMouthGap125.Checked = False
        mnuMouthGap150.Checked = False
        mnuMouthGap175.Checked = False
        mnuMouthGap200.Checked = False
        mnuMouthGap225.Checked = False
    End Sub

    Private Sub mnuMouthGap125_Click(sender As Object, e As EventArgs) Handles mnuMouthGap125.Click
        GAP_Y = 125
        mnuMouthGap100.Checked = False
        mnuMouthGap125.Checked = True
        mnuMouthGap150.Checked = False
        mnuMouthGap175.Checked = False
        mnuMouthGap200.Checked = False
        mnuMouthGap225.Checked = False
    End Sub

    Private Sub mnuMouthGap150_Click(sender As Object, e As EventArgs) Handles mnuMouthGap150.Click
        GAP_Y = 150
        mnuMouthGap100.Checked = False
        mnuMouthGap125.Checked = False
        mnuMouthGap150.Checked = True
        mnuMouthGap175.Checked = False
        mnuMouthGap200.Checked = False
        mnuMouthGap225.Checked = False
    End Sub

    Private Sub mnuMouthGap175_Click(sender As Object, e As EventArgs) Handles mnuMouthGap175.Click
        GAP_Y = 175
        mnuMouthGap100.Checked = False
        mnuMouthGap125.Checked = False
        mnuMouthGap150.Checked = False
        mnuMouthGap175.Checked = True
        mnuMouthGap200.Checked = False
        mnuMouthGap225.Checked = False
    End Sub

    Private Sub mnuMouthGap200_Click(sender As Object, e As EventArgs) Handles mnuMouthGap200.Click
        GAP_Y = 200
        mnuMouthGap100.Checked = False
        mnuMouthGap125.Checked = False
        mnuMouthGap150.Checked = False
        mnuMouthGap175.Checked = False
        mnuMouthGap200.Checked = True
        mnuMouthGap225.Checked = False
    End Sub

    Private Sub mnuMouthGap225_Click(sender As Object, e As EventArgs) Handles mnuMouthGap225.Click
        GAP_Y = 225
        mnuMouthGap100.Checked = False
        mnuMouthGap125.Checked = False
        mnuMouthGap150.Checked = False
        mnuMouthGap175.Checked = False
        mnuMouthGap200.Checked = False
        mnuMouthGap225.Checked = True
    End Sub
```

Down to this:


```
Private Sub MouthToolStripSubMenuItem_Click(sender As Object, e As EventArgs) Handles mnuMouthGap100.Click, mnuMouthGap125.Click, mnuMouthGap150.Click, mnuMouthGap175.Click, mnuMouthGap200.Click, mnuMouthGap225.Click

    Dim menu_item As ToolStripMenuItem = DirectCast(sender, ToolStripMenuItem)

    For Each subItem As ToolStripMenuItem In MouthToolStripMenuItem.DropDownItems
        subItem.Checked = False
    Next

    menu_item.Checked = True

    GAP_Y = CInt(menu_item.Tag)
End Sub
```

Just set the tag property of each menu item to their represented GAP_Y number. So it's nothing really on performance, it's just on a matter of saving you typing. The same can be done for all of the dropdownitems that have a similar scenario.

----------


## evo74

It works on windows 8

But it looks like this on windows 8.1

Both have the exact directx installed

----------


## berny22

Wow you're a god.

----------


## Nightwalker83

> Oh come on who didnt see this coming.  I remade Flappy Bird from scratch based on the famous Android / iPhone app that got removed from the app store. It has realistic physics, very accurate collision detection, and the game is highly configurable from the menu. It even uses DirectX. The only thing that is missing is a title screen and a high score, which I plan to put in, in due time. So there will soon be an update. In the mean time, enjoy.


What a minute! That looks like it could be Mario Bros, that is if you put Mario in place of the bird. What is to stop Nintendo from suing?

----------


## Jacob Roman

> Wow you're a god.


Nah, I just have years of hardcore game programming experience  :big yellow: 




> What a minute! That looks like it could be Mario Bros, that is if you put Mario in place of the bird. What is to stop Nintendo from suing?


Good point. I could make Flappy Bird World, and add scrotum guns, lava pits, spikes, mushrooms, and epic boss battles o.O

----------


## Nightwalker83

> Nah, I just have years of hardcore game programming experience 
> 
> Good point. I could make Flappy Bird World, and add scrotum guns, lava pits, spikes, mushrooms, and epic boss battles o.O


Not sure if you remember the trouble the original creators for the Giana Sisters got in because Nintendo claimed it was a direct copy of Mario Brothers.

----------


## epicgamerspro

debug exe file is missing so i cant run it  :Frown:  plz email me the file <email removed by moderator>

----------


## dday9

> debug exe file is missing so i cant run it  plz email me the file <email removed by moderator>


The exe file is missing because in most of the forums in VBForums, binaries(exe's included) are not allowed. In the _Game Demos_ forums, exe's are allowed, but only by the OP's decision and should be downloaded with much skepticism. Instead, load the project in VS and debug the project. This will build the exe for you.

Also, I removed your email from the post because VBForum's does have a lot of webscrapers that scrape the forums for personal information. Once they get ahold of your email, they can spam the crud out of you!  :Spam:  :Spam:  :Spam:  :Spam:

----------


## Jacob Roman

It should be in the x86 folder, not the debug folder because when doing directx in vb, you set it to x86, therfore the compiled exe gets tossed in there.  :Wink:

----------


## Jacob Roman

> It works on windows 8
> 
> But it looks like this on windows 8.1
> 
> Both have the exact directx installed


Out of the bloom, I decided to tackle this issue because it is now happening on my modern piece of hardware as well.



and I found a solution. Just comment out one line of code in modDX in the method Set_Renderstates()

vb.net Code:
'Device.SetRenderState(RenderStates.BlendOperation, TextureOperation.Add)

And it worked like a charm.

----------

