Visual Basic.NET - problema de graficas vb.net

   
Vista:

problema de graficas vb.net

Publicado por erick (2 intervenciones) el 08/03/2010 22:31:01
bueno adelante tengo un codigo pero tengo que hacer que cada vez que le de para la derecha o para la izquierda se traslade y camine en la direccion del boton pero cada vez que uno el boton se queda cambiando de lugar y no se como ponerlo, alguna sugerencia???
Option Strict Off
Option Explicit On
Imports System.Math
Friend Class Form1
Dim g As Graphics
Dim x1, x2 As Short
Dim y1, y2 As Short
Dim dinosauriox(58) As Single
Dim dinosaurioy(58) As Single
Dim angulorotacion As Double
Dim limitearreglo As Single = 27
Dim xtemporera As Double
Const ampliardiezporciento As Double = 1.1
Const reducirdiezporciento As Double = 0.909091
Const desplazamiento As Short = 5
Const shx As Double = -0.1
Dim desicion As Boolean
Private Sub Form1_Load(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles MyBase.Load
g = DibujoDino.CreateGraphics
g.TranslateTransform(DibujoDino.Width / 2, DibujoDino.Height / 2)
End Sub

Private Sub reflexion(ByVal limitearreglo As Single, ByRef x() As Single, ByRef y() As Single, ByRef xp As Single, ByRef yp As Single)
Dim nx As Single
Dim ny As Single
For i = 0 To limitearreglo
nx = (x(i) * -1) + 2 * x(0)
ny = y(i)
x(i) = nx
y(i) = ny
Next i

End Sub
Private Sub desiciona(ByRef y() As Single, ByRef x() As Single, ByRef arreglolimite As Single, ByRef decision As Boolean)

If decision Then
decision = False
Else
decision = True

End If

If decision Then
Call reflexion(58, dinosauriox, dinosaurioy, dinosauriox(0), dinosaurioy(0))

Else
End If



End Sub

' Private Sub reflejardino(ByVal limitearreglo As Single, ByRef xp As Single, ByRef yp As Single)
'Dim i As Integer

' For i = 0 To limitearreglo
' Call reflexion(58, dinosauriox, dinosaurioy, xp, yp)
' Next i

'End Sub
'rotacion de dibujo con los botones
Private Sub rotacion(ByRef x As Single, ByRef y As Single, ByRef ang As Single, ByRef xp As Single, ByRef yp As Single)
Dim nx As Double
Dim ny As Double

nx = ((x - xp) * System.Math.Cos(ang) - (y - yp) * System.Math.Sin(ang)) + xp
ny = ((x - xp) * System.Math.Sin(ang) + (y - yp) * System.Math.Cos(ang)) + yp
x = nx
y = ny
End Sub
Private Sub rotarDino(ByVal angulorotacion As Double, ByVal limitearreglo As Single, ByRef xp As Single, ByRef yp As Single)
Dim i As Integer

For i = 1 To limitearreglo
Call rotacion(dinosauriox(i), dinosaurioy(i), angulorotacion, xp, yp)
Next i

End Sub

Private Sub botonrotarderecha_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles botonrotarderecha.Click
Call rotarDino(0.0872664626, 58, dinosauriox(0), dinosaurioy(0))
g.Clear(Color.White)
Call dibujaDino(dinosauriox, dinosaurioy, g)
End Sub

Private Sub botonrotarizquierda_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles botonrotarizquierda.Click
Call rotarDino(-0.0872664626, 58, dinosauriox(0), dinosaurioy(0))
g.Clear(Color.White)
Call dibujaDino(dinosauriox, dinosaurioy, g)
End Sub
'movimiento de letra
Private Sub moverletraEvertical(ByRef disp As Double, ByVal limitearreglo As Integer)
Dim i As Short
For i = 0 To limitearreglo
dinosaurioy(i) = dinosaurioy(i) + disp
Next i

End Sub

Private Sub moverletraEhorizontal(ByRef x() As Single, ByRef disp As Single, ByVal limitearreglo As Integer)
Dim i As Short
For i = 0 To limitearreglo
x(i) = x(i) + disp
Next i
End Sub
Private Sub moverizquierda()
Call moverletraEhorizontal(dinosauriox, -desplazamiento, 58)
g.Clear(Color.White)
Call dibujaDino(dinosauriox, dinosaurioy, g)
End Sub
Private Sub moverderecha(ByRef dinosauriox() As Single, ByRef dinosaurioy() As Single)

Call desiciona(dinosaurioy, dinosauriox, 58, True)
Call moverletraEhorizontal(dinosauriox, desplazamiento, 58)
g.Clear(Color.White)
Call dibujaDino(dinosauriox, dinosaurioy, g)
End Sub

'botones de movimiento de Dino
Private Sub botonmoverderecha_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles botonmoverderecha.Click
Call moverderecha(dinosauriox, dinosaurioy)

End Sub

Private Sub botonmoverizquierda_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles botonmoverizquierda.Click
Call moverizquierda()
End Sub

'zoom de el dibujo
Private Sub ampliarDino(ByRef x() As Single, ByRef y() As Single, ByRef Ax As Single, ByRef Ay As Single, ByVal limitearreglo As Integer, ByRef xp As Single, ByRef yp As Single)
Dim i As Integer
For i = 0 To limitearreglo
Call ampliarsobrepunto(x(i), y(i), Ax, Ay, xp, yp)
Next i
End Sub
Private Sub ampliarsobrepunto(ByRef x As Single, ByRef y As Single, ByRef Ax As Single, ByRef Ay As Single, ByRef px As Single, ByRef py As Single)
Dim nx As Double
Dim ny As Double
nx = (x - px) * Ax + px
ny = (y - py) * Ay + py
x = nx
y = ny
End Sub

Private Sub botonampliar_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles botonagrandar.Click
Call ampliarDino(dinosauriox, dinosaurioy, ampliardiezporciento, ampliardiezporciento, 58, dinosauriox(0), dinosaurioy(0))
g.Clear(Color.White)
Call dibujaDino(dinosauriox, dinosaurioy, g)
End Sub

Private Sub botonalejar_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles botonreducir.Click
Call ampliarDino(dinosauriox, dinosaurioy, reducirdiezporciento, reducirdiezporciento, 58, dinosauriox(0), dinosaurioy(0))
g.Clear(Color.White)
Call dibujaDino(dinosauriox, dinosaurioy, g)
End Sub
Private Sub DibujoDino_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DibujoDino.Click

End Sub
Private Sub DibujoDino_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DibujoDino.Click

End Sub
Private Sub botondibuja_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles botondibuja.Click
g.Clear(Color.White)
Call coordenadasdino(dinosauriox, dinosaurioy)
Call dibujaDino(dinosauriox, dinosaurioy, g)
End Sub
End Class
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder

RE:problema de graficas vb.net

Publicado por erick (2 intervenciones) el 08/03/2010 22:32:04
Private Sub coordenadasdino(ByRef dinosauriox() As Single, ByRef dinosaurioy() As Single)
dinosauriox(0) = 0 : dinosaurioy(0) = 0

dinosauriox(1) = -102 : dinosaurioy(1) = -137
dinosauriox(2) = -152 : dinosaurioy(2) = -137
dinosauriox(3) = -197 : dinosaurioy(3) = -117
'punto medio boca
dinosauriox(4) = -150 : dinosaurioy(4) = -110

dinosauriox(5) = -197 : dinosaurioy(5) = -103
dinosauriox(6) = -124 : dinosaurioy(6) = -86
dinosauriox(7) = -110 : dinosaurioy(7) = -80
dinosauriox(8) = -100 : dinosaurioy(8) = -50
'
dinosauriox(9) = -74 : dinosaurioy(9) = -53
dinosauriox(10) = -135 : dinosaurioy(10) = -47
dinosauriox(11) = -154 : dinosaurioy(11) = -54
dinosauriox(12) = -141 : dinosaurioy(12) = -41
dinosauriox(13) = -154 : dinosaurioy(13) = -32
dinosauriox(14) = -131 : dinosaurioy(14) = -40
dinosauriox(15) = -61 : dinosaurioy(15) = -29
'
dinosauriox(16) = -88 : dinosaurioy(16) = -33
dinosauriox(17) = -49 : dinosaurioy(17) = 26
dinosauriox(18) = -29 : dinosaurioy(18) = 26
'
dinosauriox(19) = -24 : dinosaurioy(19) = 2
dinosauriox(20) = -39 : dinosaurioy(20) = 77
dinosauriox(21) = -75 : dinosaurioy(21) = 90
dinosauriox(22) = -27 : dinosaurioy(22) = 91
dinosauriox(23) = 29 : dinosaurioy(23) = 5
'
dinosauriox(24) = 10 : dinosaurioy(24) = 36
dinosauriox(25) = 56 : dinosaurioy(25) = 82
'
dinosauriox(26) = 67 : dinosaurioy(26) = 78
dinosauriox(27) = 33 : dinosaurioy(27) = 91
dinosauriox(28) = 86 : dinosaurioy(28) = 92
dinosauriox(29) = 50 : dinosaurioy(29) = 25
'
dinosauriox(30) = 15.5 : dinosaurioy(30) = 25
dinosauriox(31) = 79 : dinosaurioy(31) = 25
dinosauriox(32) = 258 : dinosaurioy(32) = 15
dinosauriox(33) = 81 : dinosaurioy(33) = -12
dinosauriox(34) = -66 : dinosaurioy(34) = -86
'
dinosauriox(35) = -63 : dinosaurioy(35) = -72
'
dinosauriox(36) = -102 : dinosaurioy(36) = -137
'lineas
dinosauriox(37) = -97 : dinosaurioy(37) = -74
dinosauriox(38) = -85 : dinosaurioy(38) = -72
'
dinosauriox(39) = -44 : dinosaurioy(39) = -51
dinosauriox(40) = -26 : dinosaurioy(40) = -38
'
dinosauriox(41) = -9 : dinosaurioy(41) = -12
dinosauriox(42) = 13 : dinosaurioy(42) = -23
'
dinosauriox(43) = 30 : dinosaurioy(43) = -18
dinosauriox(44) = 33 : dinosaurioy(44) = -7
'
dinosauriox(45) = 110 : dinosaurioy(45) = 1
dinosauriox(46) = 122 : dinosaurioy(46) = 2
'
dinosauriox(47) = 134 : dinosaurioy(47) = 15
dinosauriox(48) = 156 : dinosaurioy(48) = 15

dinosauriox(49) = -140 : dinosaurioy(49) = -127
dinosauriox(50) = -127 : dinosaurioy(50) = -131

dinosauriox(51) = -126 : dinosaurioy(51) = -127
dinosauriox(52) = -138 : dinosaurioy(52) = -122

dinosauriox(53) = -126 : dinosaurioy(53) = -118
dinosauriox(54) = -117 : dinosaurioy(54) = -122

dinosauriox(55) = -130 : dinosaurioy(55) = -124
dinosauriox(56) = -130 : dinosaurioy(56) = -121

dinosauriox(57) = -125 : dinosaurioy(57) = -121
dinosauriox(58) = -125 : dinosaurioy(58) = -124
End Sub

Private Sub dibujaDino(ByRef dinosauriox() As Single, ByRef dinosaurioy() As Single, ByRef g As Graphics)

g.DrawLine(Pens.Black, dinosauriox(1), dinosaurioy(1), dinosauriox(2), dinosaurioy(2))
g.DrawLine(Pens.Black, dinosauriox(2), dinosaurioy(2), dinosauriox(3), dinosaurioy(3))
g.DrawLine(Pens.Black, dinosauriox(3), dinosaurioy(3), dinosauriox(4), dinosaurioy(4))
g.DrawLine(Pens.Black, dinosauriox(4), dinosaurioy(4), dinosauriox(5), dinosaurioy(5))
g.DrawLine(Pens.Black, dinosauriox(5), dinosaurioy(5), dinosauriox(6), dinosaurioy(6))
g.DrawLine(Pens.Black, dinosauriox(6), dinosaurioy(6), dinosauriox(7), dinosaurioy(7))

g.DrawLine(Pens.Black, dinosauriox(6), dinosaurioy(6), dinosauriox(8), dinosaurioy(8))

g.DrawLine(Pens.Black, dinosauriox(9), dinosaurioy(9), dinosauriox(10), dinosaurioy(10))
g.DrawLine(Pens.Black, dinosauriox(10), dinosaurioy(10), dinosauriox(11), dinosaurioy(11))
g.DrawLine(Pens.Black, dinosauriox(11), dinosaurioy(11), dinosauriox(12), dinosaurioy(12))
g.DrawLine(Pens.Black, dinosauriox(12), dinosaurioy(12), dinosauriox(13), dinosaurioy(13))
g.DrawLine(Pens.Black, dinosauriox(13), dinosaurioy(13), dinosauriox(14), dinosaurioy(14))
g.DrawLine(Pens.Black, dinosauriox(14), dinosaurioy(14), dinosauriox(15), dinosaurioy(15))

g.DrawLine(Pens.Black, dinosauriox(16), dinosaurioy(16), dinosauriox(17), dinosaurioy(17))
g.DrawLine(Pens.Black, dinosauriox(17), dinosaurioy(17), dinosauriox(18), dinosaurioy(18))

g.DrawLine(Pens.Black, dinosauriox(19), dinosaurioy(19), dinosauriox(20), dinosaurioy(20))
g.DrawLine(Pens.Black, dinosauriox(20), dinosaurioy(20), dinosauriox(21), dinosaurioy(21))
g.DrawLine(Pens.Black, dinosauriox(21), dinosaurioy(21), dinosauriox(22), dinosaurioy(22))
g.DrawLine(Pens.Black, dinosauriox(22), dinosaurioy(22), dinosauriox(23), dinosaurioy(23))

g.DrawLine(Pens.Black, dinosauriox(24), dinosaurioy(24), dinosauriox(25), dinosaurioy(25))

g.DrawLine(Pens.Black, dinosauriox(26), dinosaurioy(26), dinosauriox(27), dinosaurioy(27))
g.DrawLine(Pens.Black, dinosauriox(27), dinosaurioy(27), dinosauriox(28), dinosaurioy(28))
g.DrawLine(Pens.Black, dinosauriox(28), dinosaurioy(28), dinosauriox(29), dinosaurioy(29))

g.DrawLine(Pens.Black, dinosauriox(30), dinosaurioy(30), dinosauriox(31), dinosaurioy(31))
g.DrawLine(Pens.Black, dinosauriox(31), dinosaurioy(31), dinosauriox(32), dinosaurioy(32))
g.DrawLine(Pens.Black, dinosauriox(32), dinosaurioy(32), dinosauriox(33), dinosaurioy(33))
g.DrawLine(Pens.Black, dinosauriox(33), dinosaurioy(33), dinosauriox(34), dinosaurioy(34))

g.DrawLine(Pens.Black, dinosauriox(34), dinosaurioy(34), dinosauriox(35), dinosaurioy(35))
g.DrawLine(Pens.Black, dinosauriox(34), dinosaurioy(34), dinosauriox(36), dinosaurioy(36))

g.DrawLine(Pens.Black, dinosauriox(37), dinosaurioy(37), dinosauriox(38), dinosaurioy(38))

g.DrawLine(Pens.Black, dinosauriox(39), dinosaurioy(39), dinosauriox(40), dinosaurioy(40))

g.DrawLine(Pens.Black, dinosauriox(41), dinosaurioy(41), dinosauriox(42), dinosaurioy(42))

g.DrawLine(Pens.Black, dinosauriox(43), dinosaurioy(43), dinosauriox(44), dinosaurioy(44))

g.DrawLine(Pens.Black, dinosauriox(45), dinosaurioy(45), dinosauriox(46), dinosaurioy(46))
g.DrawLine(Pens.Black, dinosauriox(47), dinosaurioy(47), dinosauriox(48), dinosaurioy(48))

g.DrawLine(Pens.Black, dinosauriox(49), dinosaurioy(49), dinosauriox(50), dinosaurioy(50))

g.DrawLine(Pens.Black, dinosauriox(51), dinosaurioy(51), dinosauriox(52), dinosaurioy(52))
g.DrawLine(Pens.Black, dinosauriox(52), dinosaurioy(52), dinosauriox(53), dinosaurioy(53))
g.DrawLine(Pens.Black, dinosauriox(53), dinosaurioy(53), dinosauriox(54), dinosaurioy(54))
g.DrawLine(Pens.Black, dinosauriox(54), dinosaurioy(54), dinosauriox(51), dinosaurioy(51))

g.DrawLine(Pens.Black, dinosauriox(55), dinosaurioy(55), dinosauriox(56), dinosaurioy(56))
g.DrawLine(Pens.Black, dinosauriox(56), dinosaurioy(56), dinosauriox(57), dinosaurioy(57))
g.DrawLine(Pens.Black, dinosauriox(57), dinosaurioy(57), dinosauriox(58), dinosaurioy(58))
g.DrawLine(Pens.Black, dinosauriox(58), dinosaurioy(58), dinosauriox(55), dinosaurioy(55))


End Sub
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar