drawing in picture box
drawing in picture box
drawing in picture box
drawing in picture box
drawing in picture box
drawing in picture box drawing in picture box drawing in picture box drawing in picture box drawing in picture box drawing in picture box drawing in picture box drawing in picture box
drawing in picture box drawing in picture box
drawing in picture box
Go Back  Xtreme Visual Basic Talk > > > drawing in picture box


Reply
 
Thread Tools Display Modes
  #1  
Old 09-07-2006, 03:04 PM
dynamically_pro dynamically_pro is offline
Newcomer
 
Join Date: Sep 2006
Posts: 2
Default drawing in picture box


hello,
I moved from vb 6 to vb.net 2005 and having trouble with a small game I am making I need to code to draw lines in a diagonal directions 4 ways.
I attached my project and if anyone can code one of my CMD diagonal buttons, with plenty of comments I sure appreciate it. thanks
Reply With Quote
  #2  
Old 09-07-2006, 03:42 PM
Gruff's Avatar
Gruffdrawing in picture box Gruff is offline
Bald Mountain Survivor

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

Welcome to the forum. Be sure to read the forum Posting Guidelines

This shouldn't be all that difficult.
Have you looked at the examples for line drawing with VB.NET help?

You derive a graphics object off of the picturebox then use its methods.
Code:
Public Class Form1 'Create a Picturebox and a button on a form then insert this code. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim oGraph As Graphics = PictureBox1.CreateGraphics Dim x1, y1, x2, y2 As Single x1 = 10.5 y1 = 10.5 x2 = 100.5 y2 = 100.5 With oGraph .DrawLine(Pens.BlueViolet, x1, y1, x2, y2) .DrawLine(Pens.BlueViolet, x2, y1, x1, y2) End With End Sub End Class

BTW you need a few more posts before you get the ability to attach files.
~T
__________________
Burn the land and boil the sea
You can't take the sky from me


~T

Last edited by Gruff; 09-07-2006 at 04:03 PM.
Reply With Quote
  #3  
Old 09-08-2006, 08:52 AM
dynamically_pro dynamically_pro is offline
Newcomer
 
Join Date: Sep 2006
Posts: 2
Default

Hello,
Thanks for the response. I read the rules, but didn't see anything about having a few post before I can attach something. I just read that size and what can be attached, so If I missed that part sorry about it. I will try the code and see how it goes, and report back. I am trying to make a small snake game to learn how draw lines using buttons, Like up, down, left, right, and diagonal.

Hi again,
ok I figured part of the program out
here is what I have for each cmd buttons except for 2 of the diagonals buttons which I am stuck on. Can't seem to get them to work.

Private Sub btnDown_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDown.Click
intXFactor = 0
intYFactor = 1
End Sub

Private Sub btnUp_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnUp.Click
intXFactor = 0
intYFactor = -1
End Sub

Private Sub btnLeft_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLeft.Click
intXFactor = -1
intYFactor = 0
End Sub

Private Sub btnRight_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRight.Click
intXFactor = 1
intYFactor = 0
End Sub

Private Sub btnLeftDiagonal_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLeftDiagonal.Click
intXFactor = -1
intYFactor = -1

End Sub

Private Sub bntRBDiagonal_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bntRBDiagonal.Click
intXFactor = 1
intYFactor = 1
End Sub

The buttons that go rightLeft diagonal and leftBottom diagonal, I can't seem to get to work.

Last edited by dynamically_pro; 09-08-2006 at 09:32 AM. Reason: adding more info
Reply With Quote
  #4  
Old 09-09-2006, 03:42 PM
Gruff's Avatar
Gruffdrawing in picture box Gruff is offline
Bald Mountain Survivor

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

1) I assume you have the actual code for drawing your lines as you do not post it here.

2) I assume you know that positive Y is down in the default Windows coordinate system.

3) If you are trying to make diagonal movements then there are four of them just like there are four orthographic movements.

The only difference is that the diagonals all would be some form of (1,1) positive or negative. Think of them as eminating from a center point as you would the normal movements.

(1,1) to bottom right
(-1,1) to bottom left
(-1,-1) Top Left
(1,-1) Top Right
__________________
Burn the land and boil the sea
You can't take the sky from me


~T
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
drawing in picture box
drawing in picture box
drawing in picture box drawing in picture box
drawing in picture box
drawing in picture box
drawing in picture box drawing in picture box drawing in picture box drawing in picture box drawing in picture box drawing in picture box drawing in picture box
drawing in picture box
drawing in picture box
 
drawing in picture box
drawing in picture box
 
-->