View Single Post
 
Old 12-15-2013, 12:49 PM
Chazz85 Chazz85 is offline
Newcomer
 
Join Date: Dec 2013
Posts: 10
Default Side scrolling code

Ok i'm planing to begin making a 2d rpg game for steam in in like 8months so i tried to get side scrolling working just to test . So i went on youtube and used a tutorial i fully understood what the code should do and how it functions. Then it didn't work the guy was using vb 2010 just like me and nothing i retyped it like 3 times. So if anyone here could spot a error or fix my code please help.

Code:
Public Class Form1 Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown 'Starts right and left etc etc' Select Case e.KeyCode Case Keys.Right TimerRight.Enabled = True TimerLeft.Enabled = False Case Keys.Left TimerLeft.Enabled = True TimerRight.Enabled = False End Select End Sub Private Sub Form1_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyUp 'Allows movement to stop if key is released' Select Case e.KeyCode Case Keys.Right TimerRight.Enabled = False Case Keys.Left TimerLeft.Enabled = False End Select End Sub Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load 'Disabled scroll bar' Me.AutoScroll = False End Sub Private Sub TimerRight_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TimerRight.Tick Dim Objects() As PictureBox = {Enemy1, Enemy2, Enemy3} For x = 0 To Objects.Length - 1 Objects(x).Left() -= 3 Next End Sub Private Sub TimerLeft_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TimerLeft.Tick Dim Objects() As PictureBox = {Enemy1, Enemy2, Enemy3} For x = 0 To Objects.Length - 1 Objects(x).Left() += 3 Next End Sub

If it's in incorrect format sorry and thank you for your time.

Last edited by Gruff; 12-15-2013 at 02:20 PM.
Reply With Quote