Random Movement

BlitzPlus Forums/BlitzPlus Beginners Area/Random Movement

To answer your questions...

1. My computer didn't freeze up when the enemy ship hit an edge, but I do have a suggestion:

Whenever checking for collisions on an edge, you want to move the ship to the same number you're checking. For example, you have;
If enemy\x <= 0
enemy\x = 10
enemy\directionx = enemy\directionx * -1
enemy\directionx = enemy\directionx + Rand(1,-1)
End If


You want to change the 10 to a zero. What you have now causes the ship to "jump" to x=10, when it should appear to bounce.

Also, the line "enemy\directionx = enemy\directionx + Rand(1,-1)" is not needed, because it basically counter acts the previous line.

2 and 3. You have the idea of checking of both x's and y's are equal, but this will only register a collision if the points meet exactly, as I'm sure you already know. What you need to do is check if the strings themselves are colliding, and you do this using the StringWidth command. This should help:
If player\x >= enemy\x And player\x <= enemey\x+StringWidth("<|>">
If player\y >= enemy\y And player\y <= enemy\y+12
player\hitpoints=player\hitpoints-1
Endif
Endif


Basically here you want to see if your x is between the enemy's x and the point that is x+ the width of the enemy, and the y is between the enemy y and the y+ the height of the font. When your x and y is between these points, you have a collision.

4. You're getting into some type manipulation, which you'll get with more experience. Focus on getting this off the ground :)

So far you have a solid start for a game, I hope this helped.