General Car Related Discussion. To discuss anything that is related to cars and automotive technology that doesnt naturally fit into another forum catagory.

Visual Basic Gurus

Thread Tools
 
Search this Thread
 
Old Dec 29, 2006 | 09:35 PM
  #2  
Jim Galbally's Avatar
Jim Galbally
20K+ Super Poster.
 
Joined: May 2003
Posts: 20,599
Likes: 0
From: Ramsgate, Kent Drives: E39 530D Touring
Default

cant read the code properly... get it up



how do you want it to move, the red blob to more randomly? and you control the car to avoid it?
Reply
Old Dec 29, 2006 | 09:39 PM
  #3  
Hardeep_Singh's Avatar
Hardeep_Singh
PassionFord Post Troll
 
Joined: Jun 2003
Posts: 2,942
Likes: 0
Default

havent written in visual basic since college days but i think the positioning of the objects work on an x and y axis, so you must have to change the values to get the object where you want it.
Reply
Old Dec 29, 2006 | 09:53 PM
  #5  
Dannn's Avatar
Dannn
I've found that life I needed.. It's HERE!!
 
Joined: Aug 2006
Posts: 1,249
Likes: 0
From: UK
Default

Show us the code for car.vb.......
Reply
Old Dec 29, 2006 | 10:06 PM
  #7  
NUTS RuS's Avatar
NUTS RuS
15K+ Super Poster!!
iTrader: (35)
 
Joined: May 2003
Posts: 15,109
Likes: 0
From: Vimto Land Nr Warrington, Cheshire
Default

Reminds me of my old Sinclair ZX81

Sit for hours typing code to watch a square ball bounce across the screen
Reply

Trending Topics

Old Dec 29, 2006 | 10:15 PM
  #9  
Dannn's Avatar
Dannn
I've found that life I needed.. It's HERE!!
 
Joined: Aug 2006
Posts: 1,249
Likes: 0
From: UK
Default

fook me - I hate vb. Next time do it in c#!!LOL

zip up solution and projects dir and I will see if it compiles on my laptop...!
Reply
Old Dec 29, 2006 | 10:20 PM
  #11  
Dannn's Avatar
Dannn
I've found that life I needed.. It's HERE!!
 
Joined: Aug 2006
Posts: 1,249
Likes: 0
From: UK
Default

Originally Posted by Gary_R
If you manage to do this I'll never say a bad thing about you again

www.robster-lobster.co.uk/DodgeCar.rar

Cheers, all help apprecaited
don't have rar - zip it!
Reply
Old Dec 29, 2006 | 10:27 PM
  #13  
OvaBoost's Avatar
OvaBoost
I've found that life I needed.. It's HERE!!
 
Joined: Jul 2005
Posts: 1,112
Likes: 0
From: Cheltenham
Default

www.rarlab.com
Reply
Old Dec 29, 2006 | 11:03 PM
  #14  
Dannn's Avatar
Dannn
I've found that life I needed.. It's HERE!!
 
Joined: Aug 2006
Posts: 1,249
Likes: 0
From: UK
Default

Can't beleive your lecturer has not obfuscated the example program!!LOL

Reflector is a handy program for decompiling .NET exe's:

http://www.aisto.com/roeder/dotnet/

Its actually a very easy what they want you to do - all the difficult bits have been done in the classes! Took me a minute to get the car going scrolling in both directions across the screen!

I give you some pointers:

1. Drag a timer control onto form1 and then double click it in order for the event stub to appear
2. Delete existing code and Paste this into form1

Public Class Form1
Private draw As New Spike
Private newcar As New Car(20, 20, 100, 50, Color.Orange, 40)
Private drawarea As Graphics

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
drawarea = picArea.CreateGraphics
draw = New Spike(picArea.Width / 1 - 10, picArea.Height / 1 - 10, 20, Color.Red, Color.Black)
End Sub

Private Sub btnStart_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnStart.Click
btnStart.Enabled = False
newcar.drawcar(drawarea)
draw.Draw(drawarea)
Timer1.Enabled = True
Timer1.Interval = 100 'change this for different speed
End Sub

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick

If newcar.X = picArea.Size.Width Then 'not perfect but will do.....
newcar.Directions = Car.direction.Left
End If

If newcar.X <= 0 Then 'not perfect but will do.....
newcar.Directions = Car.direction.Right
End If

newcar.MoveCar(drawarea)

'you now need some code here to see if spike (draw) and Car (newcar) have hasCollided
'do this by looking at the x, y and width of spike and car.

End Sub
End Class


3. A clue to finish off the keyboard stuff....

keypress event on form1

Dan
Reply
Old Dec 29, 2006 | 11:11 PM
  #16  
Jim Galbally's Avatar
Jim Galbally
20K+ Super Poster.
 
Joined: May 2003
Posts: 20,599
Likes: 0
From: Ramsgate, Kent Drives: E39 530D Touring
Default

the thing about the VB they teach you for school is this... how many times have you been at work and thought "damn, i know what i need to solve this problem, a VB app witha car that moves and a blob i can control"
Reply
Old Dec 29, 2006 | 11:11 PM
  #17  
Dannn's Avatar
Dannn
I've found that life I needed.. It's HERE!!
 
Joined: Aug 2006
Posts: 1,249
Likes: 0
From: UK
Default

Originally Posted by Gary_R
Thanks very much for that Dan. Will give it ago in the morning
Tell you what give me your email address and I sent it over...
Reply
Related Topics
Thread
Thread Starter
Forum
Replies
Last Post
massivewangers
General Car Related Discussion.
30
Oct 1, 2015 07:40 PM
Fudgey
General Car Related Discussion.
21
Sep 30, 2015 06:19 PM
Maxwell
Fiesta ST
1
Sep 13, 2015 05:31 PM
RSmark84
General Car Related Discussion.
19
Sep 13, 2015 01:29 PM




All times are GMT. The time now is 04:27 AM.