Wall (edge of form) Detection and movement

Heres your chance to share your own tutorials with the community. Just post them on here. If your lucky they may even be posted on the main site.
6 posts Page 1 of 1
Contributors
User avatar
Snyper345
VIP - Donator
VIP - Donator
Posts: 471
Joined: Mon Nov 01, 2010 1:53 am

First add a picturebox and make sure to name it Player
then simply add this to the code (not form load :P )
Code: Select all
    Private Sub frmMain_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown



        'Mover Player # Option 1

        Dim Loc As Point

        Select Case e.KeyCode

            Case Keys.A

                If Not Player.Location.X - 3 < 0 Then

                    Loc = New Point(Player.Location.X - 5, Player.Location.Y)

                    Player.Location = Loc

                End If

            Case Keys.D

                If Not Player.Location.X + 10 > Me.Width - Player.Width - 10 Then

                    Loc = New Point(Player.Location.X + 5, Player.Location.Y)

                    Player.Location = Loc

                End If

            Case Keys.W

                If Not Player.Location.Y - 5 < 0 Then

                    Loc = New Point(Player.Location.X, Player.Location.Y - 5)

                    Player.Location = Loc

                End If

            Case Keys.S

                If Not Player.Location.Y + 30 > Me.Height - Player.Height * 1.5 Then

                    Loc = New Point(Player.Location.X, Player.Location.Y + 5)

                    Player.Location = Loc

                End If

        End Select


    End Sub
End Class
Credits to : oyyou from Dreamincode
Original post:http://www.dreamincode.net/forums/topic ... maze-game/
Image
Image
User avatar
hungryhounduk
VIP - Site Partner
VIP - Site Partner
Posts: 2870
Joined: Mon Jul 27, 2009 11:58 am

Nice little snip that Snyper cooll;
Maybe i can finish my Dog Poop Game :)

Chris
Image
User avatar
Snyper345
VIP - Donator
VIP - Donator
Posts: 471
Joined: Mon Nov 01, 2010 1:53 am

hungryhounduk wrote:
Nice little snip that Snyper cooll;
Maybe i can finish my Dog Poop Game :)

Chris
lololoolol your WHAT!!?!?! hahaha this game sounds "interesting"
Image
Image
User avatar
hungryhounduk
VIP - Site Partner
VIP - Site Partner
Posts: 2870
Joined: Mon Jul 27, 2009 11:58 am

lololoolol your WHAT!!?!?! hahaha this game sounds "interesting"
Hey

Last Year i was making a game where You (as a Dog) by Keypress (arrow Keys) move around a Park, as the Dog goes round the Park it produces POOP :) (PictureBox POOP) you then have double click the POOP to pick it up and do all that against a Timer cooll;

I did use a 3D Dog and the game was Played as you are Looking down from above, BUT the Issue i had was the Picturebox that the Dog iMAGE was in used to make Trails across the Image :roll: So i never figured that out, So maybe i hill hunt down my Unfinished Game and try the Code above...

Chris
Image
User avatar
Snyper345
VIP - Donator
VIP - Donator
Posts: 471
Joined: Mon Nov 01, 2010 1:53 am

hungryhounduk wrote:
lololoolol your WHAT!!?!?! hahaha this game sounds "interesting"
Hey

Last Year i was making a game where You (as a Dog) by Keypress (arrow Keys) move around a Park, as the Dog goes round the Park it produces POOP :) (PictureBox POOP) you then have double click the POOP to pick it up and do all that against a Timer cooll;

I did use a 3D Dog and the game was Played as you are Looking down from above, BUT the Issue i had was the Picturebox that the Dog iMAGE was in used to make Trails across the Image :roll: So i never figured that out, So maybe i hill hunt down my Unfinished Game and try the Code above...

Chris

ohhh sounds good make sure to upload it up to codenstuf for sure id love to play it :P
Image
Image
User avatar
applezoom
New Member
New Member
Posts: 10
Joined: Thu Apr 12, 2012 12:31 am

Snyper345 wrote:
hungryhounduk wrote:
Nice little snip that Snyper cooll;
Maybe i can finish my Dog Poop Game :)

Chris
lololoolol your WHAT!!?!?! hahaha this game sounds "interesting"
LOL
Image
:3
ROBLOX
6 posts Page 1 of 1
Return to “Tutorials”