3 Replies - 4003 Views - Last Post: 11 October 2008 - 03:42 AM Rate Topic: -----

#1 somy360  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 18-September 08

Space invaders game

Posted 10 October 2008 - 03:35 AM

I am trying to make a space invaders game, I am currently trying to make an image move back and forth across the screen.

'Moves invaders back and forth across the screen
Dim X As Integer
Dim left_side As Integer
Dim right_side As Integer
X = 50
Imginvader1.Left = Imginvader1.Left + X
left_side = Imginvader1.Left
right_side = Imginvader1.Left + Imginvader1.Width
If left_side < ScaleLeft Then
X = -X
End If
If right_side > ScaleWidth Then
X = -X
End If



the image continues in the same direction when it reaches the edge of the form. Any help would be greatly appreciated.

Is This A Good Question/Topic? 0
  • +

Replies To: Space invaders game

#2 Reverand Dave  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 3
  • View blog
  • Posts: 375
  • Joined: 27-July 08

Re: Space invaders game

Posted 10 October 2008 - 09:37 AM

are you doing this inside a picturebox control?
Was This Post Helpful? 0
  • +
  • -

#3 somy360  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 18-September 08

Re: Space invaders game

Posted 10 October 2008 - 10:48 AM

View Postsomy360, on 10 Oct, 2008 - 03:35 AM, said:

I am trying to make a space invaders game, I am currently trying to make an image move back and forth across the screen.

'Moves invaders back and forth across the screen
Dim X As Integer
Dim left_side As Integer
Dim right_side As Integer
X = 50
Imginvader1.Left = Imginvader1.Left + X
left_side = Imginvader1.Left
right_side = Imginvader1.Left + Imginvader1.Width
If left_side < ScaleLeft Then
X = -X
End If
If right_side > ScaleWidth Then
X = -X
End If



the image continues in the same direction when it reaches the edge of the form. Any help would be greatly appreciated.


No I'm not.
Was This Post Helpful? 0
  • +
  • -

#4 thava  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 180
  • View blog
  • Posts: 1,606
  • Joined: 17-April 07

Re: Space invaders game

Posted 11 October 2008 - 03:42 AM

when ever the procedure calls
X= 50 is invoked and your code
x = -x
is just like a dummy that's why not work well and more over
change the condition like this

If left_side > ScaleLeft Then

left side will be always greater than the scale left when it lies in the form
If right_side < ScaleWidth Then

right_side will be always Lessr than the scalewidth when it lies in the form

hope you clear now
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1