Advertisement
Guest User

Untitled

a guest
May 1st, 2016
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.15 KB | None | 0 0
  1. #Include Once "fbgfx.bi"
  2. Using fb
  3. ScreenRes(640,480,32)
  4. Declare Sub collision
  5. Declare Sub check_direction
  6. Dim As Integer point_stop
  7. Dim Shared As Integer x1,x2,y1,y2,r,r2
  8. Dim Shared As Integer col 'collide
  9. Dim game_point As Integer
  10. Dim samx As Integer
  11. Dim samy As Integer
  12. Dim samx1 As Integer
  13. Dim samy1 As Integer
  14.  
  15. r = 20
  16. r2 = 10
  17. x1 = 200
  18. y1 = 200
  19.  
  20. Sub collision
  21. Dim tempx As Integer
  22. Dim tempy As Integer
  23. Dim tempz As Integer
  24. tempx = (x2 - x1)*(x2 - x1)
  25. tempy = (y2 - y1)*(y2 - y1)
  26. tempz = tempx + tempy
  27. If Sqr(tempz) < r+r2 Then col = 1 Else col = 0
  28. End Sub
  29.  
  30. Sub check_direction
  31. If x1 < x2 Then x1-=1 Else x1+=1
  32. If y1 < y2 Then y1-=1 Else y1+=1
  33. If x2 < x1 Then x2-=1 Else x2+=1
  34. If y2 < y1 Then y2-=1 Else y2+=1
  35. End Sub
  36.  
  37. Do While Not MultiKey(SC_ESCAPE)
  38. samx = x1 'Have to put the location store before the movement otherwise the samx will always be equal to x1
  39. samy = y1
  40. samx1 = x2
  41. samy1 = y2
  42. If MultiKey(SC_W) Then y1 -= 2
  43. If MultiKey(SC_S) Then y1 += 2
  44. If MultiKey(SC_A) Then x1 -= 2
  45. If MultiKey(SC_D) Then x1 += 2
  46. If MultiKey(SC_UP) Then y2 -= 2
  47. If MultiKey(SC_DOWN) Then y2 += 2
  48. If MultiKey(SC_LEFT) Then x2 -= 2
  49. If MultiKey(SC_RIGHT) Then x2 += 2
  50. If MultiKey(SC_R) Then r-=1
  51. If MultiKey(SC_T) Then r+=1
  52. If MultiKey(SC_Y) Then r2-=1
  53. If MultiKey(SC_U) Then r2+=1
  54. collision
  55. If col = 1 And samx <> x1 Then x1 = samx 'compares old x value to new x value and nulls the movement
  56. If col = 1 And samy <> y1 Then y1 = samy 'Compares old y value to new y value and nulls the movement
  57. If col = 1 And samx1 <> x2 Then x2 = samx1 'same as above
  58. If col = 1 And samy1 <> y2 Then y2 = samy1 'same as above
  59. If col = 1 Then check_direction
  60. If col = 1 Then Circle(x1,y1),r,RGBA(255,0,0,10),,,,F Else Circle(x1,y1),r,RGBA(100,100,100,10),,,,F
  61. If col = 1 Then Circle(x2,y2),r2,RGBA(255,0,0,10),,,,F Else Circle(x2,y2),r2,RGBA(100,100,100,10),,,,F
  62. 'If col = 1 And point_stop = 0 And samx - Then game_point +=1
  63. 'If col = 1 Then point_stop = 1 Else point_stop = 0
  64. Print col
  65. Sleep 10
  66. Cls
  67. Loop
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement