2player 2d game both people can't move at the same time

for some reason keychar and keydown doesn't can't have to peop

Page 1 of 1

2 Replies - 1330 Views - Last Post: 27 March 2007 - 06:26 AM Rate Topic: -----

#1 orangeslide8  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 3
  • View blog
  • Posts: 203
  • Joined: 29-December 06

2player 2d game both people can't move at the same time

Posted 26 March 2007 - 05:12 AM

ok what happens is i have almost finished a code with two stick figures battling. they can jump shoot (doesn't kill yet) move foward move back and jump to the sides. the problem is they can't both move at the same time. heres my code for the keydown event and the subroutines they call.
Private Sub space()

		graphics.FillRectangle(Brushes.Blue, blueguntopx + guntopwidth, blueguntopy, 3, 3)
		bulletx1 = blueguntopx + guntopwidth
		bullety1 = blueguntopy
		movebullet1.Start()
		freezeshoot = True
	End Sub
	Private Sub zero()
		graphics.FillRectangle(Brushes.Red, redguntopx - 3, redguntopy, 3, 3)
		bulletx2 = redguntopx - 3
		bullety2 = redguntopy
		freezeshoot = True

		Timer11.Start()
	End Sub
	Private Sub four()
		If jumped2 = False And j5 = False Then
			drawblack2()
			redbodyx = redbodyx - 7
			If redguntopx < Me.Width / 2 - 14 Then
				redbodyx = redbodyx + 7
				freeze3 = True
			Else
				freeze3 = False
			End If
			moveguy2()
		End If
		If j5 = True And jumped2 = False And jumpedleft2 = False And jumpedright2 = False Then
			Timer9.Start()
		End If
	End Sub
	Private Sub six()
		If jumped2 = False And j5 = False Then
			drawblack2()
			redbodyx = redbodyx + 7
			If redheadx + redheadwidth >= 986 Then
				redbodyx = redbodyx - 7
			End If
			moveguy2()
		End If
		If j5 = True And jumped2 = False And jumpedleft2 = False And jumpedright2 = False Then
			Timer10.Start()
		End If
	End Sub
	Private Sub eight()
		jumped2 = True
		Timer7.Start()
	End Sub
	Private Sub five()
		j5 = True
		Timer8.Start()
	End Sub
	Private Sub s1()
		s = True
		Timer6.Start()
	End Sub
	Private Sub d()
		If jumped = False And s = False Then
			drawblack()
			bluebodyx = bluebodyx + 7
			If blueguntopx + guntopwidth > Me.Width / 2 - 27 Then
				freeze = True
				bluebodyx = bluebodyx - 7
			Else
				freeze = False
			End If
			moveguy()
		End If
		If s = True And jumpedright = False And jumpedleft = False And jumped = False Then
			Timer4.Start()
		End If
	End Sub
	Private Sub a()
		If jumped = False And s = False Then
			drawblack()
			bluebodyx = bluebodyx - 7
			If blueheadx - (blueheadwidth / 2) + 10 <= 0 Then
				freeze1 = True
				bluebodyx = bluebodyx + 7
			Else
				freeze = False
			End If
			moveguy()
		End If
		If s = True And jumpedright = False And jumpedleft = False And jumped = False Then
			Timer5.Start()
		End If
	End Sub
	Private Sub w()
		If jumpedright = False And jumpedleft = False Then
			jumped = True
			Timer3.Start()
		End If
	End Sub

	Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
		If onground = True Then
			If e.KeyCode = Keys.Up And jumped2 = False And jumpedleft2 = False And jumpedright2 = False Then
				eight()
			End If
			If e.KeyCode = Keys.Right Then
				six()
			End If
			If e.KeyCode = Keys.Left Then
				four()
			End If
			If e.KeyCode = Keys.Down Then
				five()
			End If
			If e.KeyCode = Keys.Space And freezeshoot = False Then
				space()
			End If
			If e.KeyCode = Keys.Enter And freezeshoot2 = False Then
				zero()
			End If
			If e.KeyCode = Keys.S Then
				s1()
			End If
			If e.KeyCode = Keys.D Then
				d()
			End If
			If e.KeyCode = Keys.A Then
				a()
			End If
			If e.KeyCode = Keys.W And jumped = False And jumpedright = False And jumpedleft = False Then
				w()
			End If
		End If
	End Sub


and heres my full code for anyone who wants it
[code]
Imports Microsoft.DirectX
Imports Microsoft.DirectX.AudioVideoPlayback
Public Class Form1
Dim gunshot As Audio = Nothing
Dim graphics As Graphics
' blue guys body coordinates
Dim bluebodyx, bluebodyy, bluebodyx2, bluebodyy2 As Integer
' blue guys head coordinates
Dim blueheadx, blueheady, blueheadwidth, blueheadheight As Integer
' blue guys arm coordinates
Dim bluearmx, bluearmy, bluearmx2, bluearmy2 As Integer
Dim bluearm2x, bluearm2y, bluearm2x2, bluearm2y2 As Integer
' blue guys leg coordinates
Dim bluelegx, bluelegy, bluelegx2, bluelegy2 As Integer
Dim blueleg2x, blueleg2y, blueleg2x2, blueleg2y2 As Integer
' blue guys gun coordinates
Dim blueguntopx, blueguntopy, bluegunbottomx, bluegunbottomy As Integer
Dim blueguntopx2, blueguntopy2, bluegunbottomx2, bluegunbottomy2 As Integer
' top rectangle for gun width
Const guntopwidth = 20
' top rectangle for gun height
Const guntopheight = 5
' bottom rectangle for gun width
Const gunbottomwidth = 5
' bottom rectangle for gun height
Const gunbottomheight = 10
' where the ground is
Dim ground = 640
' see if you on the ground
Dim onground As Boolean
' used for when you jump to apply force of gravity
Dim jumptime, jumptime2 As Integer
' see if your int the air
Dim jumped, jumped2 As Boolean
' see if s is clicked which is used for jumping to the sides
Dim s As Boolean
' see if you jumped to the side for red guy and blue guy
Dim jumpedright, jumpedleft, jumpedright2, jumpedleft2 As Boolean
' coordinates for bullets
Dim bulletx1, bullety1, bulletx2, bullety2 As Integer
' see if your reloading
Dim freezeshoot, freezeshoot2 As Boolean
' how long you reload for
Dim reloadtime, reloadtime2 As Integer
' red guys body coordinates
Dim redbodyx, redbodyy, redbodyx2, redbodyy2 As Integer
' red guys head coordinates
Dim redheadx, redheady, redheadwidth, redheadheight As Integer
' red guys arm coordinates
Dim redarmx, redarmy, redarmx2, redarmy2 As Integer
Dim redarm2x, redarm2y, redarm2x2, redarm2y2 As Integer
' red guys leg coordinates
Dim redlegx, redlegy, redlegx2, redlegy2 As Integer
Dim redleg2x, redleg2y, redleg2x2, redleg2y2 As Integer
' red guys gun coordinates
Dim redguntopx, redguntopy, redgunbottomx, redgunbottomy As Integer
Dim redguntopx2, redguntopy2, redgunbottomx2, redgunbottomy2 As Integer
' same as s for blueguy
Dim j5 As Boolean
' randompen for line
Dim randompen As Pen
Dim freeze, freeze1, freeze2, freeze3 As Boolean
Private Sub moveguy()
bluebodyx2 = bluebodyx
bluebodyy2 = bluebodyy + 50
graphics.DrawLine(Pens.Blue, bluebodyx, bluebodyy, bluebodyx2, bluebodyy2)
blueheadwidth = 35
blueheadheight = 35
blueheadx = bluebodyx - blueheadwidth / 2
blueheady = bluebodyy - blueheadwidth
graphics.DrawEllipse(Pens.Blue, blueheadx, blueheady, blueheadwidth, blueheadheight)
bluearmx = bluebodyx
bluearmy = bluebodyy + 20
bluearmx2 = bluebodyx + 20
bluearmy2 = bluebodyy + 5
graphics.DrawLine(Pens.Blue, bluearmx, bluearmy, bluearmx2, bluearmy2)
bluearm2x = bluebodyx
bluearm2y = bluearmy - 5
bluearm2x2 = bluebodyx + 20
bluearm2y2 = bluebodyy + 5
graphics.DrawLine(Pens.Blue, bluearm2x, bluearm2y, bluearm2x2, bluearm2y2)
bluelegx = bluebodyx
bluelegy = bluebodyy2
bluelegx2 = bluearmx2
bluelegy2 = bluebodyy2 + 25
graphics.DrawLine(Pens.Blue, bluelegx, bluelegy, bluelegx2, bluelegy2)
blueleg2x = bluebodyx
blueleg2y = bluebodyy2
blueleg2x2 = blueleg2x - 20
blueleg2y2 = bluebodyy2 + 25
graphics.DrawLine(Pens.Blue, blueleg2x, blueleg2y, blueleg2x2, blueleg2y2)
bluegunbottomx = bluearmx2
bluegunbottomy = bluearmy2 - 2
graphics.FillRectangle(Brushes.White, bluegunbottomx, bluegunbottomy, gunbottomwidth, gunbottomheight)
blueguntopx = bluegunbottomx
blueguntopy = bluegunbottomy - guntopheight
graphics.FillRectangle(Brushes.White, blueguntopx, blueguntopy, guntopwidth, guntopheight)
End Sub
Private Sub drawblack()
graphics.DrawLine(Pens.Black, bluebodyx, bluebodyy, bluebodyx2, bluebodyy2)
graphics.DrawEllipse(Pens.Black, blueheadx, blueheady, blueheadwidth, blueheadheight)
graphics.DrawLine(Pens.Black, bluearmx, bluearmy, bluearmx2, bluearmy2)
graphics.DrawLine(Pens.Black, bluearm2x, bluearm2y, bluearm2x2, bluearm2y2)
graphics.DrawLine(Pens.Black, bluelegx, bluelegy, bluelegx2, bluelegy2)
graphics.DrawLine(Pens.Black, blueleg2x, blueleg2y, blueleg2x2, blueleg2y2)
graphics.FillRectangle(Brushes.Black, bluegunbottomx, bluegunbottomy, gunbottomwidth, gunbottomheight)
graphics.FillRectangle(Brushes.Black, blueguntopx, blueguntopy, guntopwidth, guntopheight)
End Sub
Private Sub drawblack2()
graphics.DrawLine(Pens.Black, redbodyx, redbodyy, redbodyx2, redbodyy2)
graphics.DrawEllipse(Pens.Black, redheadx, redheady, redheadwidth, redheadheight)
graphics.DrawLine(Pens.Black, redarmx, redarmy, redarmx2, redarmy2)
graphics.DrawLine(Pens.Black, redarm2x, redarm2y, redarm2x2, redarm2y2)
graphics.DrawLine(Pens.Black, redlegx, redlegy, redlegx2, redlegy2)
graphics.DrawLine(Pens.Black, redleg2x, redleg2y, redleg2x2, redleg2y2)
graphics.FillRectangle(Brushes.Black, redgunbottomx, redgunbottomy, gunbottomwidth, gunbottomheight)
graphics.FillRectangle(Brushes.Black, redguntopx, redguntopy, guntopwidth, guntopheight)
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
drawblack()
Dim x As Integer
x = x + 1
If x = 1 Then
Me.BackColor = Color.Black
graphics.DrawLine(Pens.Gray, 0, ground + 1, Me.Width, ground + 1)
graphics.DrawLine(Pens.Brown, 0, ground + 2, Me.Width, ground + 2)
graphics.DrawLine(Pens.Gray, 0, ground + 3, Me.Width, ground + 3)
graphics.DrawLine(Pens.Brown, 0, ground + 4, Me.Width, ground + 4)
graphics.DrawLine(Pens.Gray, 0, ground + 5, Me.Width, ground + 5)
End If
bluebodyx = bluebodyx
bluebodyy = bluebodyy + 1
moveguy()
If bluelegy2 = ground Then
Timer1.Stop()
onground = True
End If
End Sub
Private Sub space()

graphics.FillRectangle(Brushes.Blue, blueguntopx + guntopwidth, blueguntopy, 3, 3)
bulletx1 = blueguntopx + guntopwidth
bullety1 = blueguntopy
movebullet1.Start()
freezeshoot = True
End Sub
Private Sub zero()
graphics.FillRectangle(Brushes.Red, redguntopx - 3, redguntopy, 3, 3)
bulletx2 = redguntopx - 3
bullety2 = redguntopy
freezeshoot = True

Timer11.Start()
End Sub
Private Sub four()
If jumped2 = False And j5 = False Then
drawblack2()
redbodyx = redbodyx - 7
If redguntopx < Me.Width / 2 - 14 Then
redbodyx = redbodyx + 7
freeze3 = True
Else
freeze3 = False
End If
moveguy2()
End If
If j5 = True And jumped2 = False And jumpedleft2 = False And jumpedright2 = False Then
Timer9.Start()
End If
End Sub
Private Sub six()
If jumped2 = False And j5 = False Then
drawblack2()
redbodyx = redbodyx + 7
If redheadx + redheadwidth >= 986 Then
redbodyx = redbodyx - 7
End If
moveguy2()
End If
If j5 = True And jumped2 = False And jumpedleft2 = False And jumpedright2 = False Then
Timer10.Start()
End If
End Sub
Private Sub eight()
jumped2 = True
Timer7.Start()
End Sub
Private Sub five()
j5 = True
Timer8.Start()
End Sub
Private Sub s1()
s = True
Timer6.Start()
End Sub
Private Sub d()
If jumped = False And s = False Then
drawblack()
bluebodyx = bluebodyx + 7
If blueguntopx + guntopwidth > Me.Width / 2 - 27 Then
freeze = True
bluebodyx = bluebodyx - 7
Else
freeze = False
End If
moveguy()
End If
If s = True And jumpedright = False And jumpedleft = False And jumped = False Then
Timer4.Start()
End If
End Sub
Private Sub a()
If jumped = False And s = False Then
drawblack()
bluebodyx = bluebodyx - 7
If blueheadx - (blueheadwidth / 2) + 10 <= 0 Then
freeze1 = True
bluebodyx = bluebodyx + 7
Else
freeze = False
End If
moveguy()
End If
If s = True And jumpedright = False And jumpedleft = False And jumped = False Then
Timer5.Start()
End If
End Sub
Private Sub w()
If jumpedright = False And jumpedleft = False Then
jumped = True
Timer3.Start()
End If
End Sub

Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
If onground = True Then
If e.KeyCode = Keys.Up And jumped2 = False And jumpedleft2 = False And jumpedright2 = False Then
eight()
End If
If e.KeyCode = Keys.Right Then
six()
End If
If e.KeyCode = Keys.Left Then
four()
End If
If e.KeyCode = Keys.Down Then
five()
End If
If e.KeyCode = Keys.Space And freezeshoot = False Then
space()
End If
If e.KeyCode = Keys.Enter And freezeshoot2 = False Then
zero()
End If
If e.KeyCode = Keys.S Then
s1()
End If
If e.KeyCode = Keys.D Then
d()
End If
If e.KeyCode = Keys.A Then
a()
End If
If e.KeyCode = Keys.W And jumped = False And jumpedright = False And jumpedleft = False Then
w()
End If
End If
End Sub
Private Sub form1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles Me.KeyPress
End Sub
Private Sub moveguy2()
redbodyx2 = redbodyx
redbodyy2 = redbodyy + 50
graphics.DrawLine(Pens.Red, redbodyx, redbodyy, redbodyx2, redbodyy2)
redheadwidth = 35
redheadheight = 35
redheadx = redbodyx - redheadwidth / 2
redheady = redbodyy - redheadwidth
graphics.DrawEllipse(Pens.Red, redheadx, redheady, redheadwidth, redheadheight)
redarmx = redbodyx
redarmy = redbodyy + 20
redarmx2 = redbodyx - 20
redarmy2 = redbodyy - 5
graphics.DrawLine(Pens.Red, redarmx, redarmy, redarmx2, redarmy2)
redarm2x = redbodyx
redarm2y = redarmy - 5
redarm2x2 = redbodyx - 20
redarm2y2 = redbodyy - 5
graphics.DrawLine(Pens.Red, redarm2x, redarm2y, redarm2x2, redarm2y2)
redlegx = redbodyx
redlegy = redbodyy2
redlegx2 = redbodyx + 20
redlegy2 = redbodyy2 + 25
graphics.DrawLine(Pens.Red, redlegx, redlegy, redlegx2, redlegy2)
redleg2x = redbodyx
redleg2y = redbodyy2
redleg2x2 = redleg2x - 20
redleg2y2 = redbodyy2 + 25
graphics.DrawLine(Pens.Red, redleg2x, redleg2y, redleg2x2, redleg2y2)
redgunbottomx = redarmx2
redgunbottomy = redarmy2 - 2
graphics.FillRectangle(Brushes.White, redgunbottomx, redgunbottomy, gunbottomwidth, gunbottomheight)
redguntopx = redgunbottomx + gunbottomwidth - guntopwidth
redguntopy = redgunbottomy - guntopheight
graphics.FillRectangle(Brushes.White, redguntopx, redguntopy, guntopwidth, guntopheight)
End Sub
Private Sub form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Randomize()
onground = False
Timer1.Interval = (1)
Timer2.Interval = (1)
Timer3.Interval = (1)
Timer4.Interval = (1)
Timer5.Interval = (1)
Timer6.Interval = (100)
Timer8.Interval = (100)
Timer7.Interval = (1)
Timer9.Interval = (1)
Timer10.Interval = (1)
Timer11.Interval = (1)
Timer12.Interval = (1)
Timer13.Interval = (1)
movebullet1.Interval = (1)
graphics = Me.CreateGraphics()
graphics.Clear(Color.Black)
' set body places
bluebodyx = Me.Width / 7 - 90
bluebodyy = Me.Height / 2 + 120
redbodyx = Me.Width / 7 * 6 + 90
redbodyy = Me.Height / 2 + 120
Timer2.Start()
Timer1.Start()
lines.Interval = (100)
lines.Start()
End Sub

Private Sub Timer3_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer3.Tick
jumptime = jumptime + 1
drawblack()
If jumptime < 10 Then
bluebodyy = bluebodyy - 15
End If
If jumptime > 9 And jumptime < 20 Then
bluebodyy = bluebodyy - 10
End If
If jumptime > 19 And jumptime < 30 Then
bluebodyy = bluebodyy - 5
End If
If jumptime > 29 And jumptime < 40 Then
bluebodyy = bluebodyy - 1
End If
If jumptime > 39 And jumptime < 50 Then
bluebodyy = bluebodyy + 1
End If
If jumptime > 49 And jumptime < 60 Then
bluebodyy = bluebodyy + 5
End If
If jumptime > 59 And jumptime < 70 Then
bluebodyy = bluebodyy + 10
End If
If jumptime > 69 And jumptime < 79 Then
bluebodyy = bluebodyy + 15
End If
If jumptime > 78 Then
jumptime = 0
jumped = False
Timer3.Stop()
End If
moveguy()
End Sub

Private Sub Timer4_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer4.Tick
jumpedright = True
jumptime = jumptime + 1
drawblack()
If blueguntopx + guntopwidth >= Me.Width / 2 - 27 Then
jumptime = 0
s = False
jumpedright = False
Timer12.Start()
Timer4.Stop()
End If
If jumptime < 10 Then
bluebodyy = bluebodyy - 15
bluebodyx = bluebodyx + 5
End If
If jumptime > 9 And jumptime < 20 Then
bluebodyy = bluebodyy - 10
bluebodyx = bluebodyx + 5
End If
If jumptime > 19 And jumptime < 30 Then
bluebodyy = bluebodyy - 5
bluebodyx = bluebodyx + 5
End If
If jumptime > 29 And jumptime < 40 Then
bluebodyy = bluebodyy - 1
bluebodyx = bluebodyx + 5
End If
If jumptime > 39 And jumptime < 50 Then
bluebodyy = bluebodyy + 1
bluebodyx = bluebodyx + 5
End If
If jumptime > 49 And jumptime < 60 Then
bluebodyy = bluebodyy + 5
bluebodyx = bluebodyx + 5
End If
If jumptime > 59 And jumptime < 70 Then
bluebodyy = bluebodyy + 10
bluebodyx = bluebodyx + 5
End If
If jumptime > 69 And jumptime < 78 Then
bluebodyy = bluebodyy + 15
bluebodyx = bluebodyx + 5
End If
If jumptime = 78 Then
bluebodyy = bluebodyy + 15
End If
If jumptime > 78 Then
jumptime = 0
s = False
jumpedright = False
Timer4.Stop()
End If
moveguy()
End Sub
Private Sub Timer5_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer5.Tick
jumpedleft = True
jumptime = jumptime + 1
drawblack()
If blueheadx - (blueheadwidth / 2) + 10 <= 0 Then
jumptime = 0
s = False
jumpedleft = False
Timer5.Stop()
Timer12.Start()
End If
If jumptime < 10 Then
bluebodyy = bluebodyy - 15
bluebodyx = bluebodyx - 5
End If
If jumptime > 9 And jumptime < 20 Then
bluebodyy = bluebodyy - 10
bluebodyx = bluebodyx - 5
End If
If jumptime > 19 And jumptime < 30 Then
bluebodyy = bluebodyy - 5
bluebodyx = bluebodyx - 5
End If
If jumptime > 29 And jumptime < 40 Then
bluebodyy = bluebodyy - 1
bluebodyx = bluebodyx - 5
End If
If jumptime > 39 And jumptime < 50 Then
bluebodyy = bluebodyy + 1
bluebodyx = bluebodyx - 5
End If
If jumptime > 49 And jumptime < 60 Then
bluebodyy = bluebodyy + 5
bluebodyx = bluebodyx - 5
End If
If jumptime > 59 And jumptime < 70 Then
bluebodyy = bluebodyy + 10
bluebodyx = bluebodyx - 5
End If
If jumptime > 69 And jumptime < 78 Then
bluebodyy = bluebodyy + 15
bluebodyx = bluebodyx - 5
End If
If jumptime = 78 Then
bluebodyy = bluebodyy + 15
End If
If jumptime > 78 Then
jumptime = 0
s = False
jumpedleft = False
Timer5.Stop()
End If

moveguy()
End Sub

Private Sub Timer6_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer6.Tick
s = False
Timer6.Stop()
End Sub

Private Sub movebullet1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles movebullet1.Tick
graphics.FillRectangle(Brushes.Black, bulletx1, bullety1, 3, 3)
bulletx1 = bulletx1 + 7
graphics.FillRectangle(Brushes.Blue, bulletx1, bullety1, 3, 3)
If bulletx1 > Me.Width Then
movebullet1.Stop()
End If
End Sub
Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick
drawblack2()
redbodyx = redbodyx
redbodyy = redbodyy + 1
moveguy2()
If redlegy2 = ground Then
Timer2.Stop()
onground = True
End If
End Sub

Private Sub Timer7_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer7.Tick
jumptime2 = jumptime2 + 1
drawblack2()
If jumptime2 < 10 Then
redbodyy = redbodyy - 15
End If
If jumptime2 > 9 And jumptime2 < 20 Then
redbodyy = redbodyy - 10
End If
If jumptime2 > 19 And jumptime2 < 30 Then
redbodyy = redbodyy - 5
End If
If jumptime2 > 29 And jumptime2 < 40 Then
redbodyy = redbodyy - 1
End If
If jumptime2 > 39 And jumptime2 < 50 Then
redbodyy = redbodyy + 1
End If
If jumptime2 > 49 And jumptime2 < 60 Then
redbodyy = redbodyy + 5
End If
If jumptime2 > 59 And jumptime2 < 70 Then
redbodyy = redbodyy + 10
End If
If jumptime2 > 69 And jumptime2 < 79 Then
redbodyy = redbodyy + 15
End If
If jumptime2 > 78 Then
jumptime2 = 0
jumped2 = False
Timer7.Stop()
End If
moveguy2()
End Sub

Private Sub lines_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lines.Tick
Dim x As Integer
Dim y As Integer
Dim z As Integer
x = Int(Rnd() * 5) + 1
If x = 1 Then
randompen = Pens.Yellow
End If
If x = 2 Then
randompen = Pens.Pink
End If
If x = 3 Then
randompen = Pens.LightGreen
End If
If x = 4 Then
randompen = Pens.LightBlue
End If
If x = 5 Then
randompen = Pens.Red
End If
If x = 6 Then
randompen = Pens.Turquoise
End If
y = Me.Width / 2 - 20
z = Me.Height
graphics.DrawLine(randompen, y, 0, y, z)
End Sub

Private Sub Timer8_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer8.Tick
j5 = False
Timer8.Stop()
End Sub

Private Sub Timer9_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer9.Tick
jumpedleft2 = True
jumptime2 = jumptime2 + 1
drawblack2()
If redguntopx <= Me.Width / 2 - 11 Then
jumptime2 = 0
j5 = False
jumpedleft2 = False
Timer9.Stop()
Timer13.Start()
End If
If jumptime2 < 10 Then
redbodyy = redbodyy - 15
redbodyx = redbodyx - 5
End If
If jumptime2 > 9 And jumptime2 < 20 Then
redbodyy = redbodyy - 10
redbodyx = redbodyx - 5
End If
If jumptime2 > 19 And jumptime2 < 30 Then
redbodyy = redbodyy - 5
redbodyx = redbodyx - 5
End If
If jumptime2 > 29 And jumptime2 < 40 Then
redbodyy = redbodyy - 1
redbodyx = redbodyx - 5
End If
If jumptime2 > 39 And jumptime2 < 50 Then
redbodyy = redbodyy + 1
redbodyx = redbodyx - 5
End If
If jumptime2 > 49 And jumptime2 < 60 Then
redbodyy = redbodyy + 5
redbodyx = redbodyx - 5
End If
If jumptime2 > 59 And jumptime2 < 70 Then
redbodyy = redbodyy + 10
redbodyx = redbodyx - 5
End If
If jumptime2 > 69 And jumptime2 < 78 Then
redbodyy = redbodyy + 15
redbodyx = redbodyx - 5
End If
If jumptime2 = 78 Then
redbodyy = redbodyy + 15
End If
If jumptime2 > 78 Then
jumptime2 = 0
j5 = False
jumpedleft2 = False
Timer9.Stop()

Is This A Good Question/Topic? 0
  • +

Replies To: 2player 2d game both people can't move at the same time

#2 orangeslide8  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 3
  • View blog
  • Posts: 203
  • Joined: 29-December 06

Re: 2player 2d game both people can't move at the same time

Posted 26 March 2007 - 06:15 AM

could i use do events to fix that problem? how do you use do events.
thnx
john
Was This Post Helpful? 0
  • +
  • -

#3 orangeslide8  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 3
  • View blog
  • Posts: 203
  • Joined: 29-December 06

Re: 2player 2d game both people can't move at the same time

Posted 27 March 2007 - 06:26 AM

nvr mind i fixed it. what i did was in the key_down sub when a key was presed the boolean i dimensioned for that key was changed to true. and when the key_up it changed to false. then i had a timer going every millisecond that checked for the booleans and did the events. this was just for anyone who has a somewhat similar problem.
john
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1