Side scrolling code
Side scrolling code
Side scrolling code
Side scrolling code
Side scrolling code
Side scrolling code Side scrolling code Side scrolling code Side scrolling code Side scrolling code Side scrolling code Side scrolling code Side scrolling code
Side scrolling code Side scrolling code
Side scrolling code
Go Back  Xtreme Visual Basic Talk > > > Side scrolling code


Reply
 
Thread Tools Display Modes
  #1  
Old 12-15-2013, 01: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 03:20 PM.
Reply With Quote
  #2  
Old 12-16-2013, 11:13 AM
passel's Avatar
passelSide scrolling code passel is offline
Sinecure Expert

Super Moderator
* Guru *
 
Join Date: Jun 2003
Location: Upstate New York, usa
Posts: 8,026
Default

Do you have three pictureboxes named Enemy1, Enemy2 and Enemy3, and do they contain an image?
__________________
There Is An Island Of Opportunity In The Middle of Every Difficulty.
Miss That, Though, And You're Pretty Much Doomed.
Reply With Quote
  #3  
Old 12-16-2013, 12:29 PM
Chazz85 Chazz85 is offline
Newcomer
 
Join Date: Dec 2013
Posts: 10
Default

No they are just color blocks in this example all black
Reply With Quote
  #4  
Old 12-16-2013, 03:48 PM
Gruff's Avatar
GruffSide scrolling code Gruff is offline
Bald Mountain Survivor

Retired Moderator
* Expert *
 
Join Date: Aug 2003
Location: Oregon, USA - deceased
Posts: 6,440
Default

When I pasted your code the Handles Statement at the end of the events did not paste.

After adding it things worked fine.

Also the KeyUp event seemed like overkill.
I used the following instead.
Code:
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' TimerRight.Enabled = False TimerLeft.Enabled = False End Sub
__________________
Burn the land and boil the sea
You can't take the sky from me


~T
Reply With Quote
  #5  
Old 12-17-2013, 10:21 AM
Chazz85 Chazz85 is offline
Newcomer
 
Join Date: Dec 2013
Posts: 10
Default

Thanks for shortening the keydown event but i'm still having issues with this on pc and idk why.
Reply With Quote
  #6  
Old 12-17-2013, 10:44 AM
Gruff's Avatar
GruffSide scrolling code Gruff is offline
Bald Mountain Survivor

Retired Moderator
* Expert *
 
Join Date: Aug 2003
Location: Oregon, USA - deceased
Posts: 6,440
Default

idk? (I don't know)

As I said the code ran and the picture boxes moved for me.
I have no idea what you are missing.
__________________
Burn the land and boil the sea
You can't take the sky from me


~T

Last edited by passel; 12-18-2013 at 10:28 AM.
Reply With Quote
  #7  
Old 12-17-2013, 12:03 PM
Chazz85 Chazz85 is offline
Newcomer
 
Join Date: Dec 2013
Posts: 10
Default

ok
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
Side scrolling code
Side scrolling code
Side scrolling code Side scrolling code
Side scrolling code
Side scrolling code
Side scrolling code Side scrolling code Side scrolling code Side scrolling code Side scrolling code Side scrolling code Side scrolling code
Side scrolling code
Side scrolling code
 
Side scrolling code
Side scrolling code
 
-->