Simple shooting game (click on the targets)

Do you need something made? then ask in here.
Forum rules
Please LOCK your topics once you have found the solution to your question so we know you no longer require help with your query.
4 posts Page 1 of 1
Contributors
User avatar
nopel
New Member
New Member
Posts: 19
Joined: Sun Oct 28, 2012 8:51 am

Hi all. I'm looking for tutorial to a game, like this: https://www.youtube.com/watch?v=JchYBOxNrAg
with using Pictureboxes (no DirectX).
Greetings.
I found this : http://www.youtube.com/watch?v=J0BlJuwA ... re=related, and that is that, but how to scroll a background?? Background will be form1 background image.
Scrolling, (this effect what i want) is shown in first link at 0:12
And how to do that the killed animal, is going up? Maybe some timer, and at ticks make picturebox postion up?
How to do label with score given (I mean this numbers up to the dead animal) position? Maybe picturebox postion x +1 or someting like this?
User avatar
clanc789
Coding Guru
Coding Guru
Posts: 786
Joined: Tue Nov 02, 2010 4:45 pm

Cody can show you how, he made something like that once.
Practice makes perfect!

VIP since: 6-10-2011
User avatar
CodenStuff
Site Admin
Site Admin
Posts: 4392
Joined: Tue Aug 04, 2009 1:47 am

You are best off making the game within a usercontrol which is then placed onto the form and used to pan/move the background.

Example if you add a usercontrol to your project and add your background image to it then resize it to fit the background image then add a timer to it and the following code:
Code: Select all
    Public Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Integer) As Integer

    Private Sub Gamepanel_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Timer1.Enabled = True
    End Sub

    Private Sub Timer1_Tick(sender As System.Object, e As System.EventArgs) Handles Timer1.Tick
        If CBool(GetAsyncKeyState(Keys.Left)) Then
            If Me.Location.X < 0 Then
                Me.Left += 5
            End If
        ElseIf CBool(GetAsyncKeyState(Keys.Right)) Then
            If Me.Location.X + Me.Width > Parent.Width Then
                Me.Left -= 5
            End If
        End If
    End Sub
After adding the usercontrol to your main form and running the project you can use the arrow keys to move it left or right.

As for the floating numbers etc you could make that in another usercontrol with a timer added to make it "float" upwards.

Heres a really quick example project I made and you may need to install Visual Studio 2012 to open it :?
WindowsApplication1.zip
Pictureboxes are good but for a game you are better off using GDI+ (paint events) so its nice and smooth.

Heres another old project of a game I made called BJungle which is a basic platform game and uses the paint events...code is messy lol.
Bjunglesource.zip
You do not have the required permissions to view the files attached to this post.
Welcome to CodenStuff.com Learn Code, Love Code. Thank you for being a member of the community.
User avatar
Usman55
VIP - Site Partner
VIP - Site Partner
Posts: 2821
Joined: Thu Dec 24, 2009 7:52 pm

If you're going to use a lot of pictureboxes, keep this in mind, VB.net transparency sucks. The flying birds won't be smooth at all. As Cody said, go with GDI+.
Image
4 posts Page 1 of 1
Return to “Tutorial Requests”