Comparing 2 types

Blitz3D Forums/Blitz3D Beginners Area/Comparing 2 types

The Forum Archive is locked. These are the original blitzbasic.com forums, kept so their posts can still be read and searched. No new topics, replies or edits can be made here. To join the conversation, head over to the Blitz3D+ forums.


How would I give the bullet a 'flag'?



Just a variable that indicates the type of bullet it is...

Type bullet

Field shottype%
Field collision%
Field X#,Y#
Field VX#,VY#

End Type


here shottype indicates the type of bullet...
so that:

1 = player basic bullet
2 = player power-up level 1
3 = player power-up level 2

4 = enemy weak type
5 = enemy medium type
6 = enemy powerfull type

then you can do a Select-Case statement to assign damage and such:

For shot.bullet = Each bullet

hit% = Shot\collision

If hit<>NULL Then

;if the bullet hits something
;hit is a pointer to the ship being hit

Select shot\shottype

 Case 1
  ;player weak shot damage
    hit\hitpoints = hit\hitpoints - 10
    delete shot
 Case 2
  ;player higher level damage
    hit\hitpoints = hit\hitpoints - 20
    delete shot
End Select
End If



X and Y are the current location of the bullet...VX and VY are the vector the bullet follows...so with each update shot\x = shot\x + shot\vx (and the same for y)...this keeps the bullet moveing onscreen...and when the bullet hits something the bullet vx and vy can be applied to the ships vx and vy inorder to "push" it in the direction that the bullet was traveling...this way when the player fires the bullet you can:

bull = new bullet

bull\shottype = player\weapon

bull\x = player\x
bull\y = player\y

bull\vx = player\vx
bull\vy = player\vy